ACM ICPC World Finals 2012
The main observations that need to be made are the following:
While intuitively obvious, proving them is a bit tedious, so have fun with that.
With these observations, one can try a simple recursive tree search. This actually works (as long as you always try doing a takeover, when possible, before doing a merge), except that you will probably run out of stack size and crash.
Why should it work? Well, here are two more observations (easy to prove given the first two):
Taken together, this implies that it is only the first move of the game in which there is actually a choice. Thus, one can just try the (at most) two possibilities for that move and then easily simulate the rest of the game.