Editorial for LCC/Moose '19 Contest 1 S3 - Chomp


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Author: Riolku

First, one might notice that we could do some sort of dyanmic programming on the chocolate, with the state being whether or not each cell has chocolate in it, and throw out invalid states.

The idea is that given a position, we denote it as either "losing" or "winning". Then, when computing the verdict for a position, we see if we can make a move to make a position losing. If we can make a position losing, this indicates that we can force our opponent into a losing position, and therefore, we would be in a winning position.

However, if we cannot force our opponent into a losing position, we must give our opponent a winning position, which means we are in a losing position.

This approach of losing and winning positions is very common in Game Theory.

Our base case is when there are no chocolates on the grid. This would indicate a winning position, as it implies that our opponent ate the last chocolate. This would have time complexity around  \mathcal O(RC \times 2^{RC}) , which will net you the first subtask.


To get full points, we instead represent our state as the number of chocolates in each column. As an example, the following configuration can be represented as [4, 2, 1]:

#...
#...
##..
###.

We can encode this state in a 6-digit integer for full points.
Note that this representation is valid because we cannot have any "floating" chocolates. Similarly, the number must be non-increasing, since otherwise we have chocolates without their left dependent.

Time Complexity:  \mathcal O(RC \times R^C)


Comments

There are no comments at the moment.