luogu#P4949. 最短距离
最短距离
Problem Description
You are given an undirected connected graph with vertices and edges.
You need to support two types of operations:
- Modify the length of the -th edge to .
- Query the shortest distance from vertex to vertex .
There are operations in total.
Input Format
The input has a total of lines:
Line contains two positive integers , representing the number of vertices (which is also the number of edges) and the number of operations.
Lines to each contain three positive integers , indicating that there is an edge of length between and .
Lines to each contain three positive integers , representing the type of operation and its parameters (see the meaning in the “Description”).
Output Format
For each operation of type , output the query result.
4 5
1 2 11
1 3 12
2 3 13
1 4 15
2 2 3
1 2 1
2 2 3
2 2 4
2 3 4
13
12
26
16
Hint

For of the testdata, it is guaranteed that .
Translated by ChatGPT 5