#P5478. [BJOI2015] 骑士的旅行
[BJOI2015] 骑士的旅行
Description
According to Henry’s investigation, there are a total of titled knights on the continent, numbered from to . The -th knight lives in city and has combat power .
Henry plans to make several journeys. In each journey, he starts from some city and travels along the unique simple path to another city, and he will challenge the strongest knights (Henry has limited stamina, and to improve himself, of course he challenges the strongest knights). If there are fewer than knights on the route, Henry will challenge everyone he meets.
Before each journey, some knights’ combat power or residence may change. Henry will naturally gather information and adjust his plan.
To be fully prepared for each journey, Henry wants you to help compute which opponents he will challenge on that route before each journey.
Input Format
The first line contains an integer , meaning there are cities, numbered from to .
The next lines each contain two integers and , indicating that there is a road between city and city .
Line contains an integer , meaning there are knights.
The next lines each contain two integers and , describing in order the combat power and residence of each knight numbered from to .
Line contains two integers and , meaning the number of operations and the maximum number of knights challenged in each journey.
The next lines each contain three integers , , and . indicates the operation type.
There are three types of operations:
When , it means a journey: Henry will travel from city to city .
When , it means the residence of knight is moved to city .
When , it means the combat power of knight is changed to .
Output Format
Output several lines, in order, as the answers for each journey.
For each query with , output one line listing, in decreasing order, the combat power values of all knights Henry challenges in this journey. If there are no knights on the route, output one line containing the integer .
5
1 2
1 3
2 4
2 5
4
10 1
6 1
14 5
7 3
5 3
1 2 3
1 5 3
1 4 4
2 1 4
1 2 3
10 7 6
14 10 7
-1
7 6
Hint
Constraints: for of the testdata, , , , . The number of journeys does not exceed 40,000. Combat power values are positive integers not exceeding 1,000.
Translated by ChatGPT 5
京公网安备 11011102002149号