4 1 1 2
2 In the given tree, the only vertices where a stone can be placed initially are $3$ and $4$. One possible progression from here is as follows. * Alice places a stone with the white side up on vertex $4$. After this operation, all descendants of vertex $2$ have stones, so it is now possible to place a stone on vertex $2$. * Bob places a stone with the black side up on vertex $2$ and flips the stone on vertex $4$ to have the black side up. * Alice places a stone with the white side up on vertex $3$. * Bob places a stone with the black side up on vertex $1$ and flips all the stones on vertices $2$, $3$, and $4$. In this case, at the end of the game, the stones on vertices $1$, $2$, $3$, and $4$ have black, white, black, and white sides up, respectively. In fact, this progression is an example of optimal sequences of moves for both players; the answer is $2$.
7 1 1 2 4 4 4
5
{
"problem": {
"name": "Subtree Reversi",
"description": {
"content": "You are given a rooted tree with $N$ vertices numbered from $1$ to $N$, rooted at vertex $1$. The parent of vertex $i$ is vertex $p_i$ ($2\\leq i\\leq N$). Alice and Bob play a game using this tree as f",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "arc164_f"
},
"statements": [
{
"statement_type": "Markdown",
"content": "You are given a rooted tree with $N$ vertices numbered from $1$ to $N$, rooted at vertex $1$. The parent of vertex $i$ is vertex $p_i$ ($2\\leq i\\leq N$).\nAlice and Bob play a game using this tree as f...",
"is_translate": false,
"language": "English"
}
]
}