luogu#P5168. xtq玩魔塔
xtq玩魔塔
Background
Sample explanation has been added.
When 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 vertices and 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 , representing the number of vertices, the number of edges, and the number of operations.
The second line contains integers, representing the gem type on each vertex.
The next lines each contain three integers , meaning there is a road between and , and there is a monster on the road that requires HP to defeat.
Then follow lines, each containing three integers .
When , change the gem at vertex to type .
When , query the minimum HP required to go from vertex to vertex .
When , query how many gems can be picked up if starting from vertex with HP .
Output Format
For each operation of type and type , 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 . Starting from with HP, you can reach , and the gem types you can obtain are .
The second operation changes the gem type of to , as shown below:

The third operation is type . Starting from , the reachable vertices are , and the gem types you can obtain are .
The fourth operation is type . To walk from to , you need at least HP.
Constraints:
| Test Point | Has modification operations | |||
|---|---|---|---|---|
| Yes | ||||
| ^ | ||||
| No | ||||
| ^ | Yes | |||
| No | ||||
| ^ | ^ | Yes | ||
| ^ | ||||
For of the data, , , .
All remaining numbers are .
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