Codeforces 69D Dot(DFS)

Codeforces 69D Dot

链接:


题目

“““
Description
Anton and Dasha like to play different games during breaks on checkered paper. By the 11th grade they managed to play all the games of this type and asked Vova the programmer to come up with a new game. Vova suggested to them to play a game under the code name “dot” with the following rules:

  • On the checkered paper a coordinate system is drawn. A dot is initially put in the position (x, y).
  • A move is shifting a dot to one of the pre-selected vectors. Also each player can once per game symmetrically reflect a dot relatively to the line y = x.
  • Anton and Dasha take turns. Anton goes first.
  • The player after whose move the distance from the dot to the coordinates’ origin exceeds d, loses.

Help them to determine the winner.

Input
The first line of the input file contains 4 integers x, y, n, d ( - 200 ≤ x, y ≤ 200, 1 ≤ d ≤ 200, 1 ≤ n ≤ 20) — the initial coordinates of the dot, the distance d and the number of vectors. It is guaranteed that the initial dot is at the distance less than d from the origin of the coordinates. The following n lines each contain two non-negative numbers xi and yi (0 ≤ xi, yi ≤ 200) — the coordinates of the i-th vector. It is guaranteed that all the vectors are nonzero and different.

Output
You should print “Anton”, if the winner is Anton in case of both players play the game optimally, and “Dasha” otherwise.

Sample Input
0 0 2 3
1 1
1 2
Sample Output
Anton

Sample Input
0 0 2 4
1 1
1 2
Sample Output
Dasha


题意

给定初始坐标和极限区域的坐标,然后给一些向量,两人可以选择某个向量来走,最先走出极限边界的人输。问谁会输


分析

使用dfs搜索,返回值为1代表当前dfs的人输。


源码

#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<utility>
#include<sstream>
#define mem0(x) memset(x,0,sizeof x)
#define mem1(x) memset(x,1,sizeof x)
#define mem11(x) memset(x,-1,sizeof x)
#define dbug cout<<"here"<<endl;
//#define debug

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x7fffffff;
const int MAXN = 1e6+10;
const int MOD = 1000000007;

struct Point{
    int x,y;
};

Point p[30];
int f[1000][1000];
int n,d;

bool dfs(int x, int y){
    if(~f[x][y])
        return f[x][y];
    if((x-200)*(x-200) + (y-200)*(y-200) >= d*d)
        return 1;
    for(int i = 0; i < n; ++i)
        if(!dfs(x+p[i].x, y+p[i].y))
            return f[x][y]=1;

    return f[x][y]=0;
}

int main(){
    #ifdef debug
        freopen("C:\Users\asus-z\Desktop\input.txt","r",stdin);
        freopen("C:\Users\asus-z\Desktop\output.txt","w",stdout);
    #endif
    int x,y;
    cin >> x >> y >> n >> d;
    memset(f,-1,sizeof f);
    for(int i = 0; i < n; ++i){
        cin >> p[i].x >> p[i].y;
    }
    if(dfs(x+200,y+200))
        cout << "Anton" << endl;
    else
        cout << "Dasha" << endl;
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值