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 into rically 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 IntegersX,Y,N,D(? -? 200? ≤?X,?Y? ≤? 200 ,? 1? ≤?D? ≤? 200 ,? 1? ≤?N? ≤? 20)-the initial coordinates of the dot, the distanceDAnd the number of vectors. it is guaranteed that the initial dot is at the distance lessDFrom the origin of the coordinates. The followingNLines each contain two non-negative numbersXIAndYI(0? ≤?XI,?YI? ≤? (200)-the coordinates of the I-th vector. it is guaranteed that all the vectors are nonzero and different.
Output
You shoshould 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 31 11 2
Output
Anton
Input
0 0 2 41 11 2
Output
Dasha
Question: There is a point shifting game. Anton moves first. There are n options for moving. You can also follow the straight line y = x symmetric and only once, if someone first moves to the distance from the origin> = D
Thought: I did not consider the case of line y = x symmetry, because if someone must move to the position> = D next, the symmetry will not solve the problem, so we will not consider it, if DFS (X, Y) is set, it indicates whether the current mobile operator can win the game. If yes, it returns to win.
#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;}