Submit | All submissions | Best solutions | Back to list |
ADAGAME5 - Ada and Palace Game |
Ada the Ladybug is celebrating holidays with her good friend Velvet Mite Vinit. They were playing chess all the morning so they have decided to switch games. If you search in your memory (or in SPOJ archive), you'll find out, they invented a new chess-piece: palace. For those, who can't remember the rules of palace (and were not able to find it): The movement of palace is simple - it combines movement of King and Tower.
The game they invented is simple: A few palaces are placed onto chessboard. Ada and Vinit alternate in moves. In each move one can choose any palace on chessboard and move it toward bottom-left corner. Moving closer means, that the Manhattan distance from bottom-left corner will decrease. A player who can't make move will lose. Can you decide the winner?
NOTE: Two palaces can share a chess-field (they will just stack them above each other). Also note that as Ada is a lady she goes first!
Little Warning: The chessboard was a gift from Ada's good friend Flea Feodorv, who is indeed a great programmer yet not as good chess-player, so the bottom-left corner is not traditional "a1" but "[0,0]". Also the upper-right corner is not traditional "h8" but "[2999,2999]".
Input
The first line of input will contain 1 ≤ T ≤ 3*105, the number of test-cases.
The next T lines will contain 1 ≤ N ≤ 3*105, the number of palaces placed on chessboard.
Each test-case will contain N lines containing two integers: 0 ≤ x, y < 3000, the coordinates of palaces.
The sum of N over all test-cases will not exceed 3*105
Output
For each test-case output the name of winner, so either "Ada" or "Vinit".
Example Input
5 1 3 2 1 3 3 1 6 6 3 7 4 3 7 1 0 5 4 2 6 9 7 8 2 1 5 5
Example Output
Ada Vinit Vinit Vinit Ada
Added by: | Morass |
Date: | 2017-12-24 |
Time limit: | 2s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
hide comments
2018-08-17 08:36:13
How do I optimize the Grundy number function? |
|
2017-12-25 13:36:27
@sas1905: Good day to you. Nice to hear it actually helped someone. Wish you good holiday too! |
|
2017-12-25 12:25:31
After TLE's finally got AC.Learned something new.Merry Christmas..:) |
|
2017-12-25 11:19:54
@[Rampage] Blue.Mary: Thank you, fixed |
|
2017-12-25 03:23:52 [Rampage] Blue.Mary
The link to "palace" is wrong. It should be "spoj.com/problems/ADACHES2". |
|
2017-12-24 21:23:24
@Michael Kharitonov: Good day to you. Yes, thanx so much! I'll update it! |
|
2017-12-24 20:13:21 Michael Kharitonov
Ada makes a move first! |