CodeForces 69D Dot (游戏+记忆)
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
0 0 2 3
1 1
1 2
Anton
0 0 2 4
1 1
1 2
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 (游戏+记忆)的更多相关文章
- 123457123457#0#-----com.yuming.YiZhiFanPai01--前拼后广--益智早教游戏记忆翻牌cym
com.yuming.YiZhiFanPai01--前拼后广--益智早教游戏记忆翻牌cym
- CodeForces 173C Spiral Maximum 记忆化搜索 滚动数组优化
Spiral Maximum 题目连接: http://codeforces.com/problemset/problem/173/C Description Let's consider a k × ...
- CodeForces 398B 概率DP 记忆化搜索
题目:http://codeforces.com/contest/398/problem/B 有点似曾相识的感觉,记忆中上次那个跟这个相似的 我是用了 暴力搜索过掉的,今天这个肯定不行了,dp方程想了 ...
- 洛谷P1057 传球游戏(记忆化搜索)
点我进入题目 题目大意:n个小孩围一圈传球,每个人可以给左边的人或右边的人传球,1号小孩开始,一共传m次,请问有多少种可能的路径使球回到1号小孩. 输入输出:输入n,m,输出路径的数量. 数据范围:4 ...
- Codeforces 667C Reberland Linguistics 记忆化搜索
链接 Codeforces 667C Reberland Linguistics 题意 给你一个字符串,除去前5个字符串后,使剩下的串有长度为2或3的词根组成,相邻的词根不能重复.找到所有的词根 思路 ...
- CodeForces 132C Logo Turtle (记忆化搜索)
Description A lot of people associate Logo programming language with turtle graphics. In this case t ...
- CodeForces 918D MADMAX(博弈+记忆化搜索)
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- python 游戏(记忆拼图Memory_Puzzle)
1. 游戏功能和流程图 实现功能:翻开两个一样的牌子就显示,全部翻开游戏结束,设置5种图形,7种颜色,游戏开始提示随机8个牌子 游戏流程图 2. 游戏配置 配置游戏目录 配置游戏(game_conf. ...
- tyvj1014 - 乘法游戏 ——记忆化搜索DP
题目链接:https://www.tyvj.cn/Problem_Show.aspx?id=1014 f[i][j]表示区间[i,j]所得到的最小值. 不断地划分区间,把结果保存起来. #includ ...
随机推荐
- (转)ikvmc的使用
IKVM.NET是一个针对Mono和微软.net框架的java实现,其设计目的是在.NET平台上运行java程序.本文将比较详细的介绍这个工具的原理.使用入门(如何java应用转换为.NET应用.), ...
- 在静态方法里调用spring注入的方法
在静态方法里直接调用非静态方法是不行的. 那如何调用spring注入的方法呢? @Component public class AutoLoginUtil { @Autowired p ...
- error C2471: 无法更新程序数据库
这段时间在使用VS做一个项目.在使用过程中,今天遇到了一个问题,也就是题目所说的那样: error C2471: 无法更新程序数据库.之后在网上搜了一下,得到了两种解决方案,两种方案分别如下: (一) ...
- java.lang.NullPointerException错误分析
java.lang.NullPointerException是什么错误 你使用了空的指针.在java中虽然号称抛弃了C++中不安全的指针,但其实他所有的东西你都可以理解为指针.这种情况一般发生在你使用 ...
- Visual Studio Code中配置GO开发环境
在Visual Studio Code中配置GO开发环境 一.GO语言安装 详情查看:GO语言下载.安装.配置 二.GoLang插件介绍 对于Visual Studio Code开发工具,有一款优秀的 ...
- QTP脚本--应用参数化来测试某个输入框
以前一直觉得自己没有写代码的资质,太急于求成,以为一天就能写好几个功能,几千行代码,于是就没耐心了,没心情学下去了....但是最近发现其实写代码是一个漫长的过程,都是在修修改改中成长起来的.于是今天试 ...
- openGL点精灵PointSprite具体解释: 纹理映射,旋转,缩放,移动
第一,什么是点精灵 openGL的图形由顶点构成,以后利用顶点进行纹理的映射.点精灵就是,一个顶点被当作一个精灵来处理.特别之处就是,一个顶点也可进行纹理贴出.比如,原来是个顶点构成的一个矩形,如今一 ...
- LAMBDA表达式常用 (全)
这里主要是将数据库中的常用操作用LAMBDA表达式重新表示了下,用法不多,但相对较常用,等有时间了还会扩展,并将查询语句及LINQ到时也一并重新整理下: 1.select语句:books.Select ...
- Java的Log系统介绍和切换(转)
Java的log系统比较繁杂.在这里梳理一下.本文只涉及log系统介绍和处理log系统之间的切换.不涉及如何配置和使用. 具体的log系统 Log4j:准确的说是log4j 1.x版.是之前使用最广泛 ...
- Ubuntu 组态 Tomcat而每天的错误解决
统环境:Ubuntu 14.10 安装版本号:apache-tomcat-7.0.54.tar.gz 安装步骤: 1.下载 Tomcat 下载 apache-tomcat-7.0.54.tar.gz ...