P1512 Garden of Eden Calendar Game
Description
Adam and Eve play a game that starts from a date chosen uniformly at random from $1900.1.1$ to $2006.11.3$. They then take turns applying one of the following operations to the current date:
1. Add $1$ to the day. For example, $1900.1.1$ becomes $1900.1.2$.
2. Add $1$ to the month. For example, $1900.1.1$ becomes $1900.2.1$.
If the day exceeds the number of days in the current month, the date rolls over to the $1$st day of the next month. If the month exceeds $12$, it rolls over to January of the next year. Moreover, when performing operation 2, if the resulting date would be invalid (for example, $1900.1.31$ becoming $1900.2.31$), the operation is illegal and not allowed. All operations must respect calendar rules, including leap years.
Whoever first changes the date to exactly $2006.11.4$ wins. If you overshoot the specified date, it does not count as a win.
Adam always moves first. For the given starting date, determine whether he has a winning strategy.
Input Format
- The first line contains an integer $T$, the number of test cases.
- Each of the next $T$ lines contains three integers $X$, $Y$, $Z$, indicating year $X$, month $Y$, and day $Z$.
Output Format
For each test case, output `YES` or `NO` indicating whether Adam has a winning strategy.
Explanation/Hint
------------
2024/1/31 Added a set of hack testdata.
Translated by ChatGPT 5