10 1 2 3 4 5 6 7 8 9
10 There is no choice for the players, and the game will always go as follows, so Takahashi will get every coin. * Takahashi gets the coin on Vertex $1$. * Aoki moves the piece to Vertex $2$. * Takahashi gets the coin on Vertex $2$. * Aoki moves the piece to Vertex $3$. * $\vdots$ * Takahashi gets the coin on Vertex $10$. * Aoki moves the piece to Vertex $9$. * Takahashi moves the piece to Vertex $8$. * Aoki moves the piece to Vertex $7$. * $\vdots$ * Takahashi moves the piece to Vertex $2$. * Aoki moves the piece to Vertex $1$. * The game ends.
5 1 2 3 1
2 First, Takahashi gets the coin on Vertex $1$. Then, Aoki can move the piece to Vertex $2$ or Vertex $5$. If he moves it to Vertex $2$, Aoki will eventually get just the coin on Vertex $5$. On the other hand, if he moves it to Vertex $5$, Aoki will eventually get the coins on Vertex $2$, $3$, and $4$. Since Aoki will play optimally to maximize the number of coins he will get, he will choose to move the piece to Vertex $5$. Thus, Takahashi will get two coins.
10 1 1 3 1 3 6 7 6 6
5
{
"problem": {
"name": "DFS Game",
"description": {
"content": "Takahashi and Aoki will play a game using a rooted tree with $n$ vertices, numbered $1$ through $n$. The root of the tree is Vertex $1$. For each $v=2,\\dots,n$, the parent of Vertex $v$ is $p_v$. Init",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "arc112_c"
},
"statements": [
{
"statement_type": "Markdown",
"content": "Takahashi and Aoki will play a game using a rooted tree with $n$ vertices, numbered $1$ through $n$. The root of the tree is Vertex $1$. For each $v=2,\\dots,n$, the parent of Vertex $v$ is $p_v$. Init...",
"is_translate": false,
"language": "English"
}
]
}