Editorial for COCI '06 Contest 5 #5 Ivana
Submitting an official solution before solving the problem yourself is a bannable offence.
The task description doesn't explicitly state Zvonko's strategy, just that he tries to win when he can, i.e. looks for a sequence of moves that guarantees victory. One such strategy is to try to win with the largest score difference possible.
Zvonko does not know how well Ivana plays so part of his strategy is to assume she plays optimally as well, since he wants to be absolutely certain that he won't lose.
After Ivana's first move, the circle falls apart and we're left with a chain of numbers. The players alternate in taking numbers from the two ends of the chain (they get to pick which end to take off).
Suppose Ivana has made her first move and a chain of
The current player either takes the number at index
The following identities hold:
, if the number at index is odd, or if it is even
The solution has Ivana try each of the
Comments