luogu#P4096. [HEOI2013] Eden 的博弈树
[HEOI2013] Eden 的博弈树
Background
Description
For a two-player, perfect-information, deterministic game, a game tree is a common analysis tool. A game tree is a rooted tree whose nodes are game states. If node B’s parent is A, then state A can transition to state B with a single decision. Each state has a unique player to move, i.e., exactly one side should make the move at that state. We assume the two players alternate moves at all times, meaning adjacent nodes in the tree always have different players to move.
In this problem, we only care about which player wins, and we assume the game cannot end in a draw.
We call the two players Black and White, and the root’s player to move is Black. Clearly, each node has exactly two possible outcomes: Black wins or White wins. If an internal node (i.e., a node that has children) is a Black-to-move node, then this node is winning for Black if and only if at least one of its children is winning for Black; conversely for a White-to-move node. Solving the game tree means determining the outcome at the root.
If we already knew the outcomes of all leaves (nodes without children), the game tree would be easy to solve. However, here the outcomes of all leaves are unknown and need further computation. For a set of leaves , if knowing that every node in is a win for Black is sufficient to assert that the root is a win for Black, then is called a Black-winning set. Among Black-winning sets , if for any other Black-winning set it holds that (where denotes the number of elements in ), then is a minimal Black-winning set. Similarly, we can define White-winning sets and minimal White-winning sets.
Eden is studying game trees. He noticed that if a leaf belongs to some minimal Black-winning set and also to some minimal White-winning set, then determining this leaf’s outcome is clearly most helpful for determining the root’s outcome. Such leaves are called critical leaf nodes. For a given game tree, Eden wants to know which leaves are critical leaf nodes.
Output Format
Print three space-separated positive integers on a single line: the index of the critical leaf node with the smallest index, the number of critical leaf nodes, and the bitwise XOR of the indices of all critical leaf nodes.
7
1
1
2
2
3
3
4 4 0
Hint
[Sample explanation]

As shown, black nodes indicate Black-to-move nodes, and white nodes indicate White-to-move nodes.
All minimal Black-winning sets are and .
All minimal White-winning sets are , , , and .
Therefore, the set of critical leaf nodes is .
- For of the testdata, .
- For of the testdata, .
- For of the testdata, , and the tree is randomly generated.
- For of the testdata, , and for node (), the index of its parent is less than .
Translated by ChatGPT 5