#abc375f. F - Road Blocked

F - Road Blocked

Score : 550550 points

问题陈述

在AtCoder国家,有编号为11NNNN个城市,以及编号为11MMMM条道路。 道路ii双向连接城市AiA_iBiB_i,长度为CiC_i

你需要按顺序处理QQ个查询。查询分为以下两种类型:

  • 1 i:道路ii关闭。
  • 2 x y:打印从城市xx到城市yy的最短距离,只使用未关闭的道路。如果从城市xx无法到达城市yy,则打印-1

保证每个测试用例中第一种类型的查询最多包含300300个。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

In the nation of AtCoder, there are NN cities numbered 11 to NN, and MM roads numbered 11 to MM.
Road ii connects cities AiA_i and BiB_i bidirectionally and has a length of CiC_i.

You are given QQ queries to process in order. The queries are of the following two types.

  • 1 i: Road ii becomes closed.
  • 2 x y: Print the shortest distance from city xx to city yy, using only roads that are not closed. If city yy cannot be reached from city xx, print -1 instead.

It is guaranteed that each test case contains at most 300300 queries of the first type.

Constraints

  • 2N3002 \leq N \leq 300
  • 0MN(N1)20 \leq M \leq \frac{N(N-1)}{2}
  • 1Ai<BiN1 \leq A_i < B_i \leq N
  • All pairs (Ai,Bi)(A_i, B_i) are distinct.
  • 1Ci1091 \leq C_i \leq 10^9
  • 1Q2×1051 \leq Q \leq 2 \times 10^5
  • In the queries of the first type, 1iM1 \leq i \leq M.
  • 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 300300.
  • In the queries of the second type, 1x<yN1 \leq x < y \leq N.
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN MM QQ

A1A_1 B1B_1 C1C_1

\vdots

AMA_M BMB_M CMC_M

query1\mathrm{query}_1

\vdots

queryQ\mathrm{query}_Q

Each query is in one of the following two formats:

1 ii

2 xx yy

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 11 to city 33, which is 1010.
  • In the second query, road 22 becomes closed.
  • In the third query, print the shortest distance from city 11 to city 33, which is 1111.
  • In the fourth query, road 11 becomes closed.
  • In the fifth query, city 33 cannot be reached from city 11, 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