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. windows phone 7 客户端和web的交互(WebBrowser的使用)

    原文:windows phone 7 客户端和web的交互(WebBrowser的使用) 前几天看到淘宝的Android客户端,有种促销的功能,当点击促销的时候连接的淘宝促销wap页面,然后点击商品后 ...

  2. 正則表達式 取出img标签 保存于指定路径

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...

  3. altKey,ctrlKey,shiftKey

    <1> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>< ...

  4. Objective-C路成魔【18-复制对象】

    郝萌主倾心贡献,尊重作者的劳动成果,请勿转载. 假设文章对您有所帮助,欢迎给作者捐赠,支持郝萌主,捐赠数额任意.重在心意^_^ 我要捐赠: 点击捐赠 Cocos2d-X源代码下载:点我传送 将一个变量 ...

  5. Codeforces Round#309 C Kyoya and Colored Balls

    给定一个k表示颜色的种类从1到k 然后接下来k行, 每行一个数字, 代表该颜色的球有多少个 这些球都放在一个包中,然后依次拿出.  要求颜色i的最后一个球, 必须要排在颜色i+1的最后一个球前面,   ...

  6. Java学习之路:详细解释Java解析XML四种方法

    XML如今已经成为一种通用的数据交换格式,它的平台无关性,语言无关性,系统无关性,给数据集成与交互带来了极大的方便. 对于XML本身的语法知识与技术细节,须要阅读相关的技术文献,这里面包含的内容有DO ...

  7. HTTP2.0协议

    HTTP2.0协议 http2协议的草案已经出来了,阅读了一下网上的中文版,http2尽可能的兼容http1.1.改进了http1.1协议的不足. http1.0和http1.1的缺点: 1.http ...

  8. [转载]起动service保存android系统log( logcat服务)

    原文链接:http://www.myexception.cn/android/1904013.html 启动service保存android系统log 作为android开发工程师,出现了BUG是否苦 ...

  9. Android 动画具体解释View动画

    为了让用户更舒适的在某些情况下,利用动画是那么非常有必要的.Android在3.0一旦支持两种动画Tween动漫Frame动画.Tween动画支持简单的平移,缩放,旋转,渐变.Frame动画就像Gif ...

  10. EF 主键自增、级联删除

    一.主键自增 1.设置数据库中,主键自增 2.设置VS中Model1.edmx