luogu#P5168. xtq玩魔塔

xtq玩魔塔

Background

Sample explanation has been added.

When xtqxtq was in fifth grade of primary school, he became obsessed with all kinds of strange Magic Tower games.
Background of the Magic Tower game: https://baike.baidu.com/item/魔塔/861619?fr=aladdin

This may not be of any help for understanding the problem.

Problem Description

xtq is now playing a Magic Tower. This Magic Tower is very special: it is not made of square grids, but an undirected graph with nn vertices and mm edges, and there is a monster on every edge. After many obstacles, xtq has now reached a reward floor.

On this floor, no monster will make xtq lose HP. However, for each monster, if xtq does not have at least a certain amount of HP, he cannot attack that monster. Each vertex also has a gem. There are many types of gems, but if xtq arrives at a vertex and he already has that type of gem, then he cannot pick it up. He now wants to know the minimum HP required to go from one vertex of the Magic Tower to another. He also wants to know, if he starts from some vertex with a certain amount of HP, how many gems he can pick up. One more thing troubles xtq a lot: due to some mysterious power, the gem types may change. It is guaranteed that if xtq has infinite HP, he can reach anywhere on this floor.

Input Format

The first line contains three integers n,m,qn, m, q, representing the number of vertices, the number of edges, and the number of operations.

The second line contains nn integers, representing the gem type on each vertex.

The next mm lines each contain three integers u,v,tu, v, t, meaning there is a road between uu and vv, and there is a monster on the road that requires tt HP to defeat.

Then follow qq lines, each containing three integers opt,x,yopt, x, y.

When opt=1opt = 1, change the gem at vertex xx to type yy.

When opt=2opt = 2, query the minimum HP required to go from vertex xx to vertex yy.

When opt=3opt = 3, query how many gems can be picked up if starting from vertex xx with HP yy.

Output Format

For each operation of type 22 and type 33, output one line containing the answer.

4 4 4
4 6 4 2
1 2 8
3 2 3
2 4 2
4 1 7
3 4 3
1 4 4
3 1 7
2 4 3
3
2
3

Hint

Sample explanation:

The first operation is type 33. Starting from 44 with 33 HP, you can reach {2,3,4}\{2,3,4\}, and the gem types you can obtain are {2,4,6}\{2,4,6\}.

The second operation changes the gem type of 11 to 44, as shown below:

The third operation is type 33. Starting from 11, the reachable vertices are {1,2,3,4}\{1,2,3,4\}, and the gem types you can obtain are {4,6}\{4,6\}.

The fourth operation is type 22. To walk from 44 to 33, you need at least 33 HP.

Constraints:

Test Point nn mm qq Has modification operations
11 1010 2020 1010 Yes
232 \sim 3 10001000 50005000 ^
454 \sim 5 80008000 3000030000 2000020000
66 2000020000 100000100000 No
77 ^ Yes
88 5000050000 200000200000 No
99 ^ ^ Yes
1010 100000100000 300000300000 ^

For 100%100\% of the data, n100000n \le 100000, m300000m \le 300000, q200000q \le 200000.

All remaining numbers are intmax\le \text{intmax}.

It is guaranteed that the query ranges are randomly generated (actually, the problem setter was too lazy to write a generator again).

Translated by ChatGPT 5