CodeForces 69D Dot (博弈+记忆化)
2014-08-07 10:05
267 查看
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
Output
Input
Output
题意:有一个移点的游戏,Anton先移,有n个移动选择,也可以沿着直线y=x对称且只能一次,如果有人先移动到距离原点>=d的时候为输
思路:对于直线y=x对称的情况,没有考虑,因为如果有人下一步一定移到>=d的位置的话,那对称是解决不了问题的,所以我们不考虑,现在设dfs(x, y)表示当前移动人是否能赢,一旦有必赢的情况就返回赢
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 - 662A. Gambling Nim - 博弈
- Codeforces 388C Fox and Card Game 博弈
- Codeforces 151C Win or Freeze 简单博弈+唯一分解
- [博弈 杂题] Codeforces 794E Round #414 E. Choosing Carrot
- CodeForces 346A--博弈
- Codeforces_388C_Fox and Card Game(博弈、贪心、排序)
- Bag of mice CodeForces - 148D (概率) (记忆化深搜)题解
- poj 1143 Number Game 博弈 记忆化状态压缩搜索
- Codeforces - 841B Godsend(博弈)
- CodeForces 69D Dot
- 【Codeforces 738F】 Financiers Game【记忆化DP】
- Codeforces 549C The Game Of Parity(博弈)
- codeforces 549C C. The Game Of Parity(博弈)
- CodeForces - 755B PolandBall and Game ( 贪心 博弈 )
- 【CodeForces】445B A Lot of Games 字典树博弈
- codeforces 594A Warrior and Archer [对称博弈]【博弈】
- Codeforces 15C 博弈
- codeforces 919D 记忆化+判环
- [Codeforces 451A] Game With Sticks (博弈)
- Codeforces - 299C. Weird Game - 贪心、博弈