CodeForces 69 D.Dot(博弈论+dfs)

125 篇文章 0 订阅
38 篇文章 1 订阅

Description

两个人博弈,给二维平面上的一点 (x,y) ( x , y ) 以及 n n 个向量(xi,yi),每步操作可以沿着这 n n 个向量移动该点,每个人有一次机会可以将当前的点沿y=x对称,若某人移动之后该点离远点距离超过 d d 则该人失败,问两人都采取最优策略的前提下谁必胜

Input

第一行四个整数x,y,n,d,之后 n n 行每行输入两个整数xi,yi表示一个移动的方向

(200x,y200,1d200,1n20,0xi,yi200) ( − 200 ≤ x , y ≤ 200 , 1 ≤ d ≤ 200 , 1 ≤ n ≤ 20 , 0 ≤ x i , y i ≤ 200 )

Output

输出必胜者

Sample Input

0 0 2 3
1 1
1 2

Sample Output

Anton

Solution

离圆心距离 d d <script type="math/tex" id="MathJax-Element-11">d</script>以内的状态很少,直接暴搜,注意到由于每人都有一次对称机会,那么通过对称取得胜利或扭转败局均会被对手对称回来,故不需要考虑对称

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;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值