#P8238. [AGM 2022 资格赛] 避难所
[AGM 2022 资格赛] 避难所
Problem Description
Country U has buildings. The first building is the shelter, and they are connected by roads. Each building has a certain number of refugees. Initially, the number of refugees in building is .
During the war, events occur. There are two types of events:
-
1 x y: The number of refugees in building becomes . -
2 x: The road that is closest to the shelter on the path from building to the shelter changes its state: if it was open, it becomes blocked; otherwise, it becomes open. At the beginning, every road is open. It is guaranteed that .
After each event, you need to output how many refugees can reach the shelter by following open roads.
Input Format
The first line contains two positive integers .
The next lines each contain two integers , indicating that there is an edge connecting and .
The next line contains integers .
The following lines each contain two or three integers, representing one event.
Output Format
Output lines. Each line contains one number, representing the answer.
4 6
1 2
2 3
3 4
1 1 1 1
1 2 2
2 4
2 2
1 4 10
2 4
2 2
5
4
1
1
1
14
9 15
1 2
1 3
3 4
3 5
4 6
3 7
7 8
7 9
5 65 70 8 1 500 18 21 180
2 7
1 3 200
2 3
1 6 300
2 6
1 9 100
2 7
2 6
1 4 20
2 2
2 3
1 2 9
1 7 0
2 3
2 2
649
779
70
70
70
70
70
70
70
5
665
665
647
5
14
Hint
Constraints
For of the testdata, it is guaranteed that and .
Notes
Translated from AGM 2022 Qualification Round J Shelters。
Translated by ChatGPT 5