博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CF533C:Board Game(博弈)
阅读量:6578 次
发布时间:2019-06-24

本文共 1967 字,大约阅读时间需要 6 分钟。

C. Board Game
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (x, y) to (x - 1, y) or (x, y - 1). Vasiliy can move his pawn from (x, y) to one of cells: (x - 1, y), (x - 1, y - 1) and (x, y - 1)Both players are also allowed to skip move.

There are some additional restrictions — a player is forbidden to move his pawn to a cell with negative x-coordinate or y-coordinate or to the cell containing opponent's pawn The winner is the first person to reach cell (0, 0).

You are given the starting coordinates of both pawns. Determine who will win if both of them play optimally well.

Input

The first line contains four integers: xp, yp, xv, yv (0 ≤ xp, yp, xv, yv ≤ 105) — Polycarp's and Vasiliy's starting coordinates.

It is guaranteed that in the beginning the pawns are in different cells and none of them is in the cell (0, 0).

Output

Output the name of the winner: "Polycarp" or "Vasiliy".

Examples
input
2 1 2 2
output
Polycarp
input
4 7 7 4
output
Vasiliy
Note

In the first sample test Polycarp starts in (2, 1) and will move to (1, 1) in the first turn. No matter what his opponent is doing, in the second turn Polycarp can move to (1, 0) and finally to (0, 0) in the third turn.

思路:如果p的横纵坐标小于等于v坐标,则p必赢,因为p可以沿着v的斜路线进行拦截;否则判断谁的路径最短即可。

# include 
int main(){ int x1, y1, x2, y2, m1, m2; while(~scanf("%d%d%d%d",&x1,&y1,&x2,&y2)) { if(x1 <= x2 && y1 <= y2) puts("Polycarp"); else { m1 = x1 + y1; m2 = x2>y2?x2:y2; if(m1 <= m2) puts("Polycarp"); else puts("Vasiliy"); } } return 0;}

转载于:https://www.cnblogs.com/junior19/p/6729922.html

你可能感兴趣的文章
sed && awk (3)====awk 的十道逻辑题
查看>>
那些“躲避”微软autoruns工具的方法
查看>>
OPNsense用户手册-缓存代理
查看>>
关于Apache (httpd)服务器防DDOS模块mod_evasive的使用说明
查看>>
雕虫小技---仅复制可见单元格的技巧
查看>>
Python练手,封装日志模块,v2
查看>>
Android 屏幕适配
查看>>
暗黑3发布!又有多少人为之疯狂
查看>>
Android 照片墙
查看>>
20140419-MCSA 2012 Server R2 Command
查看>>
WEM, Citrix 桌面虚拟化方案之神器2号
查看>>
linux档案权限和目录配置
查看>>
面见袁总
查看>>
Golang学习笔记(1)---go程序一般结构
查看>>
Linux nc (netcat) 详解
查看>>
Redis——AOF持久化
查看>>
接口测试
查看>>
两表查询-其中一表查询出的结果为条件做为主查询的条件来查询(快客密码查询)...
查看>>
C# Dictionary 的几种遍历方法
查看>>
坑爹属性之【automaticallyAdjustsScrollViewInsets】
查看>>