Description
两个人博弈,给二维平面上的一点 以及 个向量 ,每步操作可以沿着这 个向量移动该点,每个人有一次机会可以将当前的点沿 对称,若某人移动之后该点离远点距离超过 则该人失败,问两人都采取最优策略的前提下谁必胜
Input
第一行四个整数 ,之后 行每行输入两个整数 表示一个移动的方向
Output
输出必胜者
Sample Input
0 0 2 3
1 1
1 2
Sample Output
Anton
Solution
离圆心距离 以内的状态很少,直接暴搜,注意到由于每人都有一次对称机会,那么通过对称取得胜利或扭转败局均会被对手对称回来,故不需要考虑对称
Code
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<ctime>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int INF=0x3f3f3f3f,maxn=1005;
int n,d,x[maxn],y[maxn],dp[maxn][maxn];
int dfs(int X,int Y)
{
if((X-200)*(X-200)+(Y-200)*(Y-200)>d*d)return 1;
if(~dp[X][Y])return dp[X][Y];
int sg=0;
for(int i=1;i<=n;i++)sg|=!dfs(X+x[i],Y+y[i]);
return dp[X][Y]=sg;
}
int main()
{
scanf("%d%d%d%d",&x[0],&y[0],&n,&d);
for(int i=1;i<=n;i++)scanf("%d%d",&x[i],&y[i]);
memset(dp,-1,sizeof(dp));
printf("%s\n",dfs(x[0]+200,y[0]+200)?"Anton":"Dasha");
return 0;
}