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 ...
随机推荐
- python中print,return和yield的区别
def func1(): for i in range(1, 5): print i def func2(): for i in range(1, 5): return i def func3(): ...
- Jetty:开发指导Handlers
Rewrite Handler RewriteHandler匹配一个基于该请求的规则集合,然后根据匹配规则的变更请求. 最常见的要求是改写URI.但不限于:规则可以被配置为重定向响应.设置cookie ...
- Android HAL
- 【足迹C++primer】40、动态数组
动态数组 C++语言定义了第二种new表达式语法.能够分配并初始化一个对象数组.标准库中包括 一个名为allocator的类.同意我们将分配和初始化分离. 12.2.1 new和数组 void fun ...
- 【android自己定义控件】自己定义View属性
1.自己定义View的属性 2.在View的构造方法中获得我们自己定义的属性 3.重写onMesure 4.重写onDraw 3这个步骤不是必须,当然了大部分情况下还是须要重写的. 1.自己定义Vie ...
- 循环多少次? 【杭电--HDOJ-1799】 附题+具体解释
循环多少次? Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Sub ...
- 通过 HTTP 头进行 SQL 注入(转)
英文原文:DatabaseTube,翻译:开源中国 在漏洞评估和渗透测试中,确定目标应用程序的输入向量是第一步.这篇文章解释了别人是如何通过HTTP头部对你的数据库进行SQL注入攻击的,以及讨论下选择 ...
- JS学习笔记-OO疑问之对象创建
问一.引入工厂,解决反复代码 前面已经提到,JS中创建对象的方法,不难发现,主要的创建方法中,创建一个对象还算简单,假设创建多个类似的对象的话就会产生大量反复的代码. 解决:工厂模式方法(加入一个专门 ...
- [置顶] 如何vs在cocos2dx项目中打印中文
一开始不是很理解,查了半天资料,终于找到解决方法,但是有部分中文还是不能打印出来,如 会出现部分的中文, 一开始都是问号的解决方法是 点击高级保存选项 设置成Unicode(UTF-8无签名) 这样就 ...
- OpenMp高速分拣
#include <stdio.h> #include<stdafx.h> #include<iostream> #include <stdlib.h> ...