G - Not Only Tree Game 解説 by en_translator
Since the given graph does not contain an odd cycle, each connected component forms a bipartite graph. Now consider the following five characteristic values of the graph:
- \(x\): the number of edges that can be added without changing the connectivity while preserving the bipartiteness
- \(\mathrm{ee}\): the number of connected components where the number of vertices in both parts are both even
- \(\mathrm{oe}\): the number of connected components where the number of vertices in both parts are both odd
- \(\mathrm{eo}\): the number of connected components with two or more vertices, where the number of vertices in one part is even and the other is odd
- \(\mathrm{iso}\): the number of connected components with one vertex
Then the winner can be determined as follows.
- If \(N\) is odd
- The first player wins if \(\mathrm{oo}+x\) is odd, and the second does if it is even.
- If \(N\) is even and \(\mathrm{eo}=0\)
- The first player wins if \(\mathrm{iso}/2+x\) is odd, and the second does if it is even.
- If \(N\) is even and \(1 \leq \mathrm{eo}\leq 2\)
- The first player always wins.
- If \(N\) is even and \(\mathrm{eo} \geq 3\)
- The first player wins if \(\mathrm{oo}+x\) is odd, and the second does if it is even.
The idea for the proof
In this game, every move increments the number of edges, so the parity of the number of edges in the final graph is important.
If \(N\) is odd, one part of the final bipartite graph has an odd number of vertices, and the other is even, so the resulting graph always have an even number of edges. Thus, the winner is determined only by the current number of edges regardless of moves.
If \(N\) is even, the final parity of the number of edges depend on whether the parities of the numbers of vertices in the partite sets of the final graph are both odd or both even. The parities are affected by how the connected components contributing to \(\mathrm{eo}\) and \(\mathrm{iso}\) are merged, so handling this process properly is essential.
Proof
If \(N\) is odd
In this case, the number of edges in the graph at the end of the game is always even regardless of operations, so the winner is solely dependent on the number of edges in the current graph. Currently, the graph has \((\text{even}\times \text{even}\times\mathrm{ee} + \text{odd}\times \text{odd}\times\mathrm{oo}+\text{even}\times \text{odd}\times\mathrm{eo}-x)\) connected components, whose parity is equal to that of \(\mathrm{oo}+x\). If this is odd, the first player will win; if it is even, the second player will win.
If \(N\) is even and \(\mathrm{eo}=0\)
Notice that \(\mathrm{iso}\) is even in this case.
If \(\mathrm{iso}/2+x\) is odd, at least one of \(\mathrm{iso}/2\) is positive, so one can add an edge that connects isolated vertices, or an edge that does not change the connectivity. This way, one can make the state where \(\mathrm{eo}=0\) and \(\mathrm{iso}/2+x\) is even.
If \(\mathrm{iso}/2+x\) is even, the possible operations are
- add an edge that does not affect the connectivity,
- add an edge between isolated vertices,
- add an edge between two connected components that are not isolated vertices,
- add an edge that connects an isolated vertex and another connected component.
After the first, second, or third operation, \(\mathrm{eo}=0\) and \(\mathrm{iso}/2+x\) is odd. After the fourth operation, (as there are still isolated vertices left) if the opponent chooses in the next move to appropriately add an edge that connects another isolated vertex with the same connected component, the first player will face the state where \(\mathrm{eo}=0\) and \(\mathrm{iso}/2+x\) is even again.
Since \(\mathrm{eo}=\mathrm{iso}=x=0\) should hold when the terminal condition of the game is satisfied, it can be proved by induction on the number of edges that in this case, the first player will win if and only if \(\mathrm{iso}/2+x\) is odd.
If \(N\) is even and \(\mathrm{eo}=1\)
By the parity of the number of vertices, there is at least one isolated vertex. By appropriately adding an edge between a connected component that contributes to \(\mathrm{eo}\) and an isolated vertex, one can make a move so that \(\mathrm{eo}=0\) and \(\mathrm{iso}/2+x\) becomes even.
If \(N\) is even and \(\mathrm{eo}=2\)
By adding an edge between connected components that contribute to \(\mathrm{eo}\), one can make a move so that \(\mathrm{eo}=0\) and \(\mathrm{iso}/2+x\) becomes even.
If \(N\) is even and \(\mathrm{eo}\geq 3\)
After one move, \(\mathrm{eo}\) changes at most by two, so if it becomes that \(\mathrm{eo} < 3\), the player will lose as shown above. Thus, the final result will coincide to the case where exactly three connected components that contribute to \(\mathrm{eo}\) are maintained throughout the game. This way, it has been boiled down to the case where \(N\) is odd.
投稿日時:
最終更新: