CodeForces 69D Dot (游戏+记忆)

时间:2021-12-21 10:19:29

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&num;0&num;-----com&period;yuming&period;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 传球游戏&lpar;记忆化搜索&rpar;

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

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

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

  6. CodeForces 132C Logo Turtle &lpar;记忆化搜索&rpar;

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

  7. CodeForces 918D MADMAX&lpar;博弈&plus;记忆化搜索&rpar;

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

  8. python 游戏&lpar;记忆拼图Memory&lowbar;Puzzle&rpar;

    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. 谷歌浏览器下载地址 chrome最新版本 百度云地址

    每次下载更新谷歌浏览器是一件很蛋疼的事情.百度搜索"谷歌浏览器下载地址",居然有很多骗子网站,相信有很多不知所以的人中招了.收集了一些chrome的安装包,放在了百度云里面(打不开 ...

  2. 关于android&period;view&period;WindowManager&dollar;BadTokenException问题出现以及解决的一些记录

    1.出现 在app showdialog()时偶尔会出现,根据*.com的描述,貌似是show的时候用作context的activity以及destroy了,,,一些异步操作会 ...

  3. cowboy使用restful的例子

    直接贴代码,一切尽在不言中 %% cowboy的restful的文档,一定要好好阅读http://ninenines.eu/docs/en/cowboy/HEAD/manual/cowboy_rest ...

  4. NFC Forum &colon; Frequently Asked Questions &lpar;NFC 论坛:FAQ&rpar;

    NFC for Business What is the NFC Forum? The NFC Forum is a not-for-profit industry organization whos ...

  5. Jetty支持Windows认证

    WAFFLE是什么? Jetty增加WAFFLE支持 DEMO 小结 WAFFLE是什么? WAFFLE是一个Windows认证框架,支持Negotiate, NTLM和Kerberos认证.WAFF ...

  6. iOS sourceTree忽略掉必要的xcuserdata文件

    1.找到git对应的文件 git status 结果 会得到已经修改的文件. modified: Zing.xcodeproj/xcuserdata/tiny.xcuserdatad/xcscheme ...

  7. POJ&lowbar;2318&lowbar;TOYS&amp&semi;&amp&semi;POJ&lowbar;2398&lowbar;Toy Storage&lowbar;二分&plus;判断直线和点的位置关系

    POJ_2318_TOYS&&POJ_2398_Toy Storage_二分+判断直线和点的位置 Description Calculate the number of toys th ...

  8. 数据仓库之Data Vault模型总结

    一,Data Vault模型有几个主要的组件,这里先总结一下: 1.Hub组件,是一个数据表,用于记录在业务应用中常用到的业务实体键值,如员工ID,发票号.客户编号.车辆号等. 表内包括几个关键字段: ...

  9. Linux内核线程的思考与总结

    1.内核线程,只是一个称呼,实际上就是一个进程,有自己独立的TCB,参与内核调度,也参与内核抢占. 这个进程的特别之处有两点,第一.该进程没有前台.第二.永远在内核态中运行. 2.创建内核线程有两种方 ...

  10. redis 配置文件示例

    # redis 配置文件示例 # 当你需要为某个配置项指定内存大小的时候,必须要带上单位,# 通常的格式就是 1k 5gb 4m 等酱紫:## 1k  => 1000 bytes# 1kb =& ...