#abc375f. F - Road Blocked
F - Road Blocked
Score : points
问题陈述
在AtCoder国家,有编号为到的个城市,以及编号为到的条道路。 道路双向连接城市和,长度为。
你需要按顺序处理个查询。查询分为以下两种类型:
1 i
:道路关闭。2 x y
:打印从城市到城市的最短距离,只使用未关闭的道路。如果从城市无法到达城市,则打印-1
。
保证每个测试用例中第一种类型的查询最多包含个。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
In the nation of AtCoder, there are cities numbered to , and roads numbered to .
Road connects cities and bidirectionally and has a length of .
You are given queries to process in order. The queries are of the following two types.
1 i
: Road becomes closed.2 x y
: Print the shortest distance from city to city , using only roads that are not closed. If city cannot be reached from city , print-1
instead.
It is guaranteed that each test case contains at most queries of the first type.
Constraints
- All pairs are distinct.
- In the queries of the first type, .
- The road given in a query of the first type is not already closed at that time.
- The number of queries of the first type is at most .
- In the queries of the second type, .
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Each query is in one of the following two formats:
1
2
Output
Process the queries in order.
Sample Input 1
3 3 5
1 2 5
1 3 10
2 3 6
2 1 3
1 2
2 1 3
1 1
2 1 3
Sample Output 1
10
11
-1
- In the first query, print the shortest distance from city to city , which is .
- In the second query, road becomes closed.
- In the third query, print the shortest distance from city to city , which is .
- In the fourth query, road becomes closed.
- In the fifth query, city cannot be reached from city , so print
-1
.
Sample Input 2
4 6 6
2 3 1
2 4 1
3 4 1
1 2 1
1 3 1
1 4 1
1 4
1 5
1 6
2 1 2
2 1 3
2 1 4
Sample Output 2
-1
-1
-1