CodeForces 69D Dot
2015-02-13 14:48
274 查看
CodeForces 69D Dot
时间:2014-08-07 13:23:50 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 liney?=?x.
Anton and Dasha take turns. Anton goes first.
The player after whose move the distance from the dot to the coordinates‘ origin exceedsd, 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 distanced
and the number of vectors. It is guaranteed that the initial dot is at the distance less thand from the origin of the coordinates. The followingn lines each contain two non-negative
numbersxi andyi (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)表示当前移动人是否能赢,一旦有必赢的情况就返回赢
* Author: fisty * Created Time: 2015/2/9 21:43:24 * File Name : 7_C.cpp *********************************************** */ #include <iostream> #include <cstring> #include <deque> #include <cmath> #include <queue> #include <stack> #include <list> #include <map> #include <set> #include <string> #include <vector> #include <cstdio> #include <bitset> #include <algorithm> using namespace std; #define Debug(x) cout << #x << " " << x <<endl #define Memset(x, a) memset(x, a, sizeof(x)) const int INF = 0x3f3f3f3f; typedef long long LL; typedef pair<int, int> P; #define FOR(i, a, b) for(int i = a;i < b; i++) #define MAX_N 1000 int n, d; int dx[MAX_N],dy[MAX_N]; int vis[MAX_N][MAX_N]; 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])) return vis[x][y] = 1; } return vis[x][y] = 0; } int main() { //freopen("in.cpp", "r", stdin); cin.tie(0); ios::sync_with_stdio(false); int x, y; cin >> x >> y >> n >> d; x += 200; y += 200; for(int i = 0;i < n; i++){ cin >> dx[i] >> dy[i]; } Memset(vis, -1); if(dfs(x, y)) cout << "Anton\n"; else cout << "Dasha\n"; return 0; }
相关文章推荐
- CodeForces 69D Dot (博弈+记忆化)
- codeforces 305 我太水了,加把劲锕。
- codeforces 303 div2 E
- codeforces 658C C. Bear and Forgotten Tree 3(tree+乱搞)
- CodeForces 278A Circle Line
- Codeforces 574D Bear and Blocks【思维】
- codeforces 846A Curriculum Vitae
- CodeForces - 754D Fedor and coupons (优先队列)
- codeforces 302 B. Eugeny and Play List
- [思维]CodeForces 135B
- Codeforces 658D Bear and Polynomials【数学】
- codeforces 711C dp
- Codeforces 786C Till I Collapse[主席树][二分]
- CodeForces - 845G
- [Codeforces 176B]Word Cut
- codeforces 7B - Memory Manager
- 【codeforces】305C GCD,容斥
- codeforces 658D D. Bear and Polynomials(数学)
- Codeforces-396A - On Number of Decompositions into Multipliers-组合计数
- Codeforces 768 E. Game of Stones 博弈DP