5 1 2 3 1 3 6 1 4 9 4 5 10 4 2 2 3 2 1 5 1 3 1 2 1 5
9 19 11 The initial tree is shown in the figure below.  Each query should be processed as follows. * The first query asks you to print the distance between vertex $2$ and vertex $3$. Edge $1$ and edge $2$, in this order, form a path between them with a total weight of $9$, which is the minimum, so you should print $9$. * The second query asks you to print the distance between vertex $1$ and vertex $5$. Edge $3$ and edge $4$, in this order, form a path between them with a total weight of $19$, which is the minimum, so you should print $19$. * The third query changes the weight of edge $3$ to $1$. * The fourth query asks you to print the distance between vertex $1$ and vertex $5$. Edge $3$ and edge $4$, in this order, form a path between them with a total weight of $11$, which is the minimum, so you should print $11$.
7 1 2 1000000000 2 3 1000000000 3 4 1000000000 4 5 1000000000 5 6 1000000000 6 7 1000000000 3 2 1 6 1 1 294967296 2 1 6
5000000000 4294967296 Note that the answers may not fit into $32$\-bit integers.
1 1 2 1 1
0
8 1 2 105 1 3 103 2 4 105 2 5 100 5 6 101 3 7 106 3 8 100 18 2 2 8 2 3 6 1 4 108 2 3 4 2 3 5 2 5 5 2 3 1 2 4 3 1 1 107 2 3 1 2 7 6 2 3 8 2 1 5 2 7 6 2 4 7 2 1 7 2 5 3 2 8 6
308 409 313 316 0 103 313 103 525 100 215 525 421 209 318 519
{
"problem": {
"name": "Distance Queries on a Tree",
"description": {
"content": "You are given a tree $T$ with $N$ vertices. Edge $i$ $(1\\leq i\\leq N-1)$ connects vertices $u _ i$ and $v _ i$, and has a weight of $w _ i$. Process $Q$ queries in order. There are two kinds of querie",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 4000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "abc294_g"
},
"statements": [
{
"statement_type": "Markdown",
"content": "You are given a tree $T$ with $N$ vertices. Edge $i$ $(1\\leq i\\leq N-1)$ connects vertices $u _ i$ and $v _ i$, and has a weight of $w _ i$.\nProcess $Q$ queries in order. There are two kinds of querie...",
"is_translate": false,
"language": "English"
}
]
}