3 1 1 2 1 1 1
4 The four possible final states of $A$ are $(1,1,1)$, $(3,0,1)$, $(3,1,0)$, and $(5,0,0)$.
3 1 2 1 1 1 1
5 The five possible final states of $A$ are $(1,1,1)$, $(1,2,0)$, $(2,0,1)$, $(2,1,0)$, and $(3,0,0)$.
3 1 2 2 1 1 1
6 The six possible final states of $A$ are $(1,1,1)$, $(1,3,0)$, $(3,0,1)$, $(3,2,0)$, $(5,1,0)$, and $(7,0,0)$.
5 1 1 3 3 2 0 1 0 1 2
48
5 1 1 3 3 123456789 1 2 3 4 5
87782255
{
"problem": {
"name": "Child to Parent",
"description": {
"content": "There is a rooted tree with $N$ vertices numbered $1$ to $N$. Vertex $1$ is the root, and the parent of vertex $i$ ($2\\leq i\\leq N$) is $P_i$. You are given a non-negative integer $r$ and a sequence o",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 4000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "agc063_e"
},
"statements": [
{
"statement_type": "Markdown",
"content": "There is a rooted tree with $N$ vertices numbered $1$ to $N$. Vertex $1$ is the root, and the parent of vertex $i$ ($2\\leq i\\leq N$) is $P_i$.\nYou are given a non-negative integer $r$ and a sequence o...",
"is_translate": false,
"language": "English"
}
]
}