6 6 1 2 1 3 1 5 4 1 5 3 4 3 5 6 4 2 6 5 7 1 4 6 2 4 6 3 4 6 4 4 6 5 4 6 6 4 6 5 6 5
0 0 0 0 0 1 1  The above figure shows the edge numbers in black and the edge weights in blue. Let us explain the first through sixth queries. First, consider $d(4,6)$ in the given graph. The maximum weight of an edge along the path $4 \rightarrow 1 \rightarrow 2 \rightarrow 6$ is $5$, which is the minimum over all paths connecting vertex $4$ and vertex $6$, so $d(4,6)=5$. Next, consider the increment of $d(4,6)$ when the weight of edge $x\ (1 \leq x \leq 6)$ increases by $1$. When $x=6$, we have $d(4,6)=6$, and the increment is $1$. On the other hand, when $x \neq 6$, we have $d(4,6)=5$, and the increment is $0$. For instance, when $x=3$, the maximum weight of an edge along the path $4 \rightarrow 1 \rightarrow 2 \rightarrow 6$ is $6$, but the maximum weight of an edge along the path $4 \rightarrow 3 \rightarrow 1 \rightarrow 2 \rightarrow 6$ is $5$, so $d(4,6)$ is still $5$.
2 2 1 2 1 1 2 1 1 1 1 2
0 The given graph may contain multi-edges.
{
"problem": {
"name": "Ex - Difference of Distance",
"description": {
"content": "We have a connected undirected graph with $N$ vertices numbered $1$ to $N$ and $M$ edges numbered $1$ to $M$. Edge $i$ connects vertex $U_i$ and vertex $V_i$, and has an integer weight of $W_i$. For $",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 5000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "abc301_h"
},
"statements": [
{
"statement_type": "Markdown",
"content": "We have a connected undirected graph with $N$ vertices numbered $1$ to $N$ and $M$ edges numbered $1$ to $M$. Edge $i$ connects vertex $U_i$ and vertex $V_i$, and has an integer weight of $W_i$. For $...",
"is_translate": false,
"language": "English"
}
]
}