51nod 1534 棋子游戏 博弈

题目来源: CodeForces
基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题
 收藏
 关注

波雷卡普和瓦西里喜欢简单的逻辑游戏。今天他们玩了一个游戏,这个游戏在一个很大的棋盘上进行,他们每个人有一个棋子。他们轮流移动自己的棋子,波雷卡普先开始。每一步移动中,波雷卡普可以将他的棋子从(x,y) 移动到 (x-1,y) 或者 (x,y-1)。而瓦西里可以将他的棋子从(x,y) 移动到 (x-1,y),(x-1,y-1) 或者 (x,y-1)。当然他们可以选择不移动。

还有一些其它的限制,他们不能把棋子移动到x或y为负的座标,或者移动到已经被对手占据的座标。最先到达(0,0)的人获胜。

现在给定他们棋子的座标,判断一下谁会获胜。

Input
单组测试数据。
第一行包含四个整数xp,yp,xv,yv (0≤xp,yp,xv,yv≤10^5) ,表示波雷卡普和瓦西里棋子的座标。
输入保证他们的棋子在不同位置,而且没有棋子在(0,0)。
Output
如果波雷卡普获胜,输出Polycarp,否则输出Vasiliy。
Input示例
样例输入1
2 1 2 2
Output示例
样例输出1
Polycarp


稍微在纸上画一下就可以发现关键是能不能卡住后者的棋子让他不能斜着走 根据这个判断一下就差不多了
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;
#define FIN     freopen("input.txt","r",stdin);
#define FOUT    freopen("output.txt","w",stdout);
#define INF     0x3f3f3f3f
#define INFLL   0x3f3f3f3f3f3f3f
#define lson    l,m,rt<<1
#define rson    m+1,r,rt<<1|1
typedef long long LL;
typedef pair<int, int> PII;
using namespace std;


int main() {
    //FIN
    int xp, yp, xv, yv;
    while(~scanf("%d%d%d%d", &xp, &yp, &xv, &yv)) {
        int minv = min(xv, yv);
        int maxv = max(xv, yv);
        if(xp + yp <= maxv) {
            printf("Polycarp\n");
            continue;
        }
        int flag = 0;
        if(xp > xv || yp > yv) {
            printf("Vasiliy\n");
            continue;
        } else {
            printf("Polycarp\n");
            continue;
        }

    }

    return 0;
}

  

posted @ 2017-08-10 13:05  Hyouka  阅读(387)  评论(0编辑  收藏  举报