#P4175. [CTSC2008] 网络管理
[CTSC2008] 网络管理
Description
Company M is a very large multinational with branches or departments in many countries. To let the departments distributed around the world work together, the company built a communication network that connects the entire company.
The network consists of routers and high-speed fiber-optic cables. Each department has a dedicated router; all machines in the department’s local area network connect to this router, and then communicate with other departments through this communication subnet. The network structure guarantees that between any two routers there exists a direct or indirect path for communication.
The fiber-optic cables transmit data so fast that the latency on the cables can be ignored. However, due to router aging, exchanging data on the routers introduces significant delay. The communication delay between two routers is determined by the maximum exchange delay among all routers on the communication path between the two routers.
As an intern in Company M’s network division, you are asked to write a simple program to monitor the company’s network status. The program must be able to update the network status at any time (changes in routers’ data exchange delay), and, upon queries, report the delay of the -th largest-delay router on the path between two routers.
Task: Your program reads from the input file the connectivity of the routers and fiber-optic cables, the initial data exchange delay of each router, and queries (or state changes). Process the queries in order; each is one of:
- Due to an upgrade or a new fault, a router’s data exchange delay changes.
- Query the delay of the -th largest-delay router on the path between routers and .
Input Format
The first line contains two integers and , the total number of routers and the total number of queries.
The second line contains integers; the -th number is the initial data exchange delay of router .
The next lines each contain two integers and , indicating there is a fiber-optic cable connecting router and router .
Then follow lines, each containing three integers .
If , router changes state: its data exchange delay changes from to .
If , query the -th largest delay among all routers on the path from to (including and ). Note that can be equal to ; in this case, the path contains only one router.
Output Format
For each query of the second type (i.e., ), output one line containing a single integer, the corresponding delay. If the routers on the path are fewer than , output invalid request!.
5 5
5 1 2 3 4
3 1
2 1
4 3
5 3
2 4 5
0 1 2
2 2 3
2 1 4
3 3 5
3
2
2
invalid request!
Hint
Constraints
For of the testdata, , , and at any time the delay of any router is less than .
Translated by ChatGPT 5
京公网安备 11011102002149号