5 1 2 2 3 2 4 4 5 4 1 1 1 1 4 10 2 1 100 2 2 1000
11 110 1110 110 100 In the first query, we add $1$ to each vertex reachable from Vertex $1$ without visiting Vertex $2$, that is, Vertex $1$. In the second query, we add $10$ to each vertex reachable from Vertex $4$ without visiting Vertex $5$, that is, Vertex $1, 2, 3, 4$. In the third query, we add $100$ to each vertex reachable from Vertex $2$ without visiting Vertex $1$, that is, Vertex $2, 3, 4, 5$. In the fourth query, we add $1000$ to each vertex reachable from Vertex $3$ without visiting Vertex $2$, that is, Vertex $3$.
7 2 1 2 3 4 2 4 5 6 1 3 7 7 2 2 1 1 3 2 2 2 4 1 6 8 1 3 16 2 4 32 2 1 64
72 8 13 26 58 72 5
11 2 1 1 3 3 4 5 2 1 6 1 7 5 8 3 9 3 10 11 4 10 2 6 688 1 10 856 1 8 680 1 8 182 2 2 452 2 4 183 2 6 518 1 3 612 2 6 339 2 3 206
1657 1657 2109 1703 1474 1657 3202 1474 1247 2109 2559
{
"problem": {
"name": "Through Path",
"description": {
"content": "We have a tree with $N$ vertices and $N-1$ edges, where the vertices are numbered $1, 2, \\dots, N$ and the edges are numbered $1, 2, \\dots, N-1$. Edge $i$ connects Vertices $a_i$ and $b_i$. Each ver",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "abc187_e"
},
"statements": [
{
"statement_type": "Markdown",
"content": "We have a tree with $N$ vertices and $N-1$ edges, where the vertices are numbered $1, 2, \\dots, N$ and the edges are numbered $1, 2, \\dots, N-1$. Edge $i$ connects Vertices $a_i$ and $b_i$. \nEach ver...",
"is_translate": false,
"language": "English"
}
]
}