coderforce 69D.Dot



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

DFS记录路径的博弈,很好的一道题。

Input
0 0 2 3
1 1
1 2
Output
Anton
Input
0 0 2 4
1 1
1 2
Output
Dasha
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int mapp[500][500];
int a[300],b[300],bx,by,d,n;
int dfs(int x,int y)
{
    if((x-250)*(x-250)+(y-250)*(y-250)>=d*d)
        return 1;
    if(mapp[x][y]!=-1)
        return mapp[x][y];
    for(int i=0; i<n; i++)
    {
        if(dfs(x+a[i],y+b[i])==0)
            return mapp[x][y]=1;
    }
    return mapp[x][y]=0;
}
int main()
{
    cin>>bx>>by>>n>>d;
    bx+=250;
    by+=250;
    for(int i=0; i<n; i++)
        scanf("%d%d",&a[i],&b[i]);
    memset(mapp,-1,sizeof(mapp));
    if(dfs(bx,by))
        printf("Anton\n");
    else
        printf("Dasha\n");
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值