Editorial for TLE '16 Contest 3 P4 - Gaussian Elimination
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
For the first subtask, we can simply try all possible combinations of and . There are 9 combinations to check.
Time Complexity:
For the second subtask, we need to make several observations for this problem. First, when we perform a row or column reduction, we compress the entire grid into a new continuous grid after the move. This means that no matter which row we remove, the end state will be the same. The same applies for the columns. Thus, the only decision that matters is whether to perform a row or a column reduction.
Now we need to apply some game theory knowledge. Let if the first person to play on a grid with size will win, and if the first person will lose. The base case we have to deal with is if or , in this case, the first person to play always wins. Otherwise, we can see that the player to move will either make a grid with size or size . If the person going first at size wants to win, he should send the other person into a losing position. Thus, if or . Otherwise, . After generating the entire DP array, the answer is located at .
Time Complexity:
To solve the third subtask, we need to notice a pattern with the DP array since generating the entire DP array is too time-consuming. Again, if or , we know that the answer to will be . If we generate DP values for small grids, we realize that a checkerboard pattern is formed starting at . Thus, if and are both not equal to , the player who plays first will win if .
Note: This solution can be proven correct with induction. The proof of correctness is left as an exercise.
Time Complexity:
Comments