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

Input
0 0 2 3
1 1
1 2
Output
Anton
Input
0 0 2 4
1 1
1 2
Output
Dasha

题意:有一个移点的游戏,Anton先移,有n个移动选择。也能够沿着直线y=x对称且仅仅能一次,假设有人先移动到距离原点>=d的时候为输

思路:对于直线y=x对称的情况,没有考虑。由于假设有人下一步一定移到>=d的位置的话。那对称是解决不了问题的,所以我们不考虑,如今设dfs(x, y)表示当前移动人能否赢,一旦有必赢的情况就返回赢

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn = 500; int n, d;
int dx[maxn], dy[maxn];
int vis[maxn][maxn]; int dfs(int x, int y) {
if ((x-200)*(x-200) + (y-200)*(y-200) >= d*d)
return 1;
if (vis[x][y] != -1)
return vis[x][y];
for (int i = 0; i < n; i++)
if (dfs(x+dx[i], y+dy[i]) == 0)
return vis[x][y] = 1;
return vis[x][y] = 0;
} int main() {
int x, y;
scanf("%d%d%d%d", &x, &y, &n, &d);
x += 200, y += 200;
for (int i = 0; i < n; i++)
scanf("%d%d", &dx[i], &dy[i]);
memset(vis, -1, sizeof(vis));
if (dfs(x, y))
printf("Anton\n");
else printf("Dasha\n");
return 0;
}

版权声明:本文博主原创文章,博客,未经同意不得转载。

CodeForces 69D Dot (游戏+记忆)的更多相关文章

  1. 123457123457#0#-----com.yuming.YiZhiFanPai01--前拼后广--益智早教游戏记忆翻牌cym

    com.yuming.YiZhiFanPai01--前拼后广--益智早教游戏记忆翻牌cym

  2. CodeForces 173C Spiral Maximum 记忆化搜索 滚动数组优化

    Spiral Maximum 题目连接: http://codeforces.com/problemset/problem/173/C Description Let's consider a k × ...

  3. CodeForces 398B 概率DP 记忆化搜索

    题目:http://codeforces.com/contest/398/problem/B 有点似曾相识的感觉,记忆中上次那个跟这个相似的 我是用了 暴力搜索过掉的,今天这个肯定不行了,dp方程想了 ...

  4. 洛谷P1057 传球游戏(记忆化搜索)

    点我进入题目 题目大意:n个小孩围一圈传球,每个人可以给左边的人或右边的人传球,1号小孩开始,一共传m次,请问有多少种可能的路径使球回到1号小孩. 输入输出:输入n,m,输出路径的数量. 数据范围:4 ...

  5. Codeforces 667C Reberland Linguistics 记忆化搜索

    链接 Codeforces 667C Reberland Linguistics 题意 给你一个字符串,除去前5个字符串后,使剩下的串有长度为2或3的词根组成,相邻的词根不能重复.找到所有的词根 思路 ...

  6. CodeForces 132C Logo Turtle (记忆化搜索)

    Description A lot of people associate Logo programming language with turtle graphics. In this case t ...

  7. CodeForces 918D MADMAX(博弈+记忆化搜索)

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  8. python 游戏(记忆拼图Memory_Puzzle)

    1. 游戏功能和流程图 实现功能:翻开两个一样的牌子就显示,全部翻开游戏结束,设置5种图形,7种颜色,游戏开始提示随机8个牌子 游戏流程图 2. 游戏配置 配置游戏目录 配置游戏(game_conf. ...

  9. tyvj1014 - 乘法游戏 ——记忆化搜索DP

    题目链接:https://www.tyvj.cn/Problem_Show.aspx?id=1014 f[i][j]表示区间[i,j]所得到的最小值. 不断地划分区间,把结果保存起来. #includ ...

随机推荐

  1. SQL语句查询数据库的触发器、存储过程、视图以及表的SQL语句

    Sql Server数据库用SQL语句查询方法如下: select name from sysobjects where xtype='TR' --所有触发器 select name from sys ...

  2. Knockout应用开发指南 第四章:模板绑定

    原文:Knockout应用开发指南 第四章:模板绑定 模板绑定The template binding 目的 template绑定通过模板将数据render到页面.模板绑定对于构建嵌套结构的页面非常方 ...

  3. linux--shell script

    下面是最近学习shell script的一些知识点总结 ***博客园-邦邦酱好***   1.介绍shell是一个文字接口,让我们与系统沟通.shell script就是针对shell所写的脚本.它就 ...

  4. Android它Service

    服务是一段代码的后台执行. 无法处理,也不是螺纹,但它是在进程和线程的执行. Android该服务与Activity不同,不能与用户交互,无法启动自己. 媒体播放服务.当用户退出媒体选择用户界面,不过 ...

  5. Python学习入门基础教程(learning Python)--3.1Python的if分支语句

    本节研究一下if分支语句. if分支语句是Python下逻辑条件控制语句,用于条件执行某些语句的控制操作,当if后的条件conditon满足时,if其下的语句块被执行,但当if的控制条件condito ...

  6. Windows Phone开发(36):动画之DoubleAnimation

    原文:Windows Phone开发(36):动画之DoubleAnimation 从本节开始,我们将围绕一个有趣的话题展开讨论--动画. 看到动画一词,你一定想到Flash,毕竟WP应用的一个很重要 ...

  7. TCP header

    watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc3Vzc2VyNDM=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA ...

  8. 概率dp专辑

    求概率 uva11021 http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...

  9. Spring与Hibernate整合中,使用OpenSessionInViewFilter后出现sessionFactory未注入问题

    近期在知乎看到一句话,保持学习的有一种是你看到了很多其它的牛人,不甘心,真的不甘心. Spring和hibernate整合的时候,jsp页面做展现,发现展现属性出现: org.apache.jaspe ...

  10. OPENVPN开启用户password认证

    一.服务端配置 1.改动openvpn的主配置文件,加入例如以下内容 [root@ttt openvpn]# cat /etc/openvpn/server.conf |more #########a ...