#P5465. Clarke and puzzle
Clarke and puzzle
Problem Description
Clarke is a patient with multiple personality disorder. One day, Clarke split into two personality $a$ and $b$, they are playing a game.
There is a $n*m$ matrix, each grid of this matrix has a number $c_{i, j}$.
$a$ wants to beat $b$ every time, so $a$ ask you for a help.
There are $q$ operations, each of them is belonging to one of the following two types:
1. They play the game on a $(x_1, y_1)-(x_2, y_2)$ sub matrix. They take turns operating. On any turn, the player can choose a grid which has a positive integer from the sub matrix and decrease it by a positive integer which less than or equal this grid's number. The player who can't operate is loser. $a$ always operate first, he wants to know if he can win this game.
2. Change $c_{i, j}$ to $b$.
Input
The first line contains a integer $T(1 \le T \le 5)$, the number of test cases.
For each test case:
The first line contains three integers $n, m, q(1 \le n, m \le 500, 1 \le q \le 2*10^5)$
Then $n*m$ matrix follow, the $i$ row $j$ column is a integer $c_{i, j}(0 \le c_{i, j} \le 10^9)$
Then $q$ lines follow, the first number is $opt$.
if $opt=1$, then $4$ integers $x_1, y_1, x_1, y_2(1 \le x_1 \le x_2 \le n, 1 \le y_1 \le y_2 \le m)$ follow, represent operation $1$.
if $opt=2$, then $3$ integers $i, j, b$ follow, represent operation $2$.
Output
For each testcase, for each operation $1$, print $Yes$ if $a$ can win this game, otherwise print $No$.
1
1 2 3
1 2
1 1 1 1 2
2 1 2 1
1 1 1 1 2
Yes
No
Hint:
The first enquiry: $a$ can decrease grid $(1, 2)$'s number by $1$. No matter what $b$ operate next, there is always one grid with number $1$ remaining . So, $a$ wins.
The second enquiry: No matter what $a$ operate, there is always one grid with number $1$ remaining. So, $b$ wins.