Editorial for CTU Open Contest 2018 - Split Game
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.
Submitting an official solution before solving the problem yourself is a bannable offence.
- Each impartial game is equivalent to NIM.
- Sum of games has nimber equivalent to XOR of nimbers of individual games.
- Note that adding two same piles does not change the outcome.
- We precompute nimbers up to piles of size (DP).
- XOR nimbers of games on the input.
- If XOR is zero second player wins, otherwise first player wins.
Complexity
If you try hard, you can achieve
Comments