21841_Network

2022-5-16 18:20| 发布者: Hocassian| 查看: 24| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505893278000-Problem List-采集的数据-后羿采集器.html

Pro.ID

21841

Title

Network

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21841

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    The ALPC company is now working on his own network system, which is connecting all N ALPC department. To economize on spending, the backbone network has only one router for each department, and N-1 optical fiber in total to connect all routers.

    The usual way to measure connecting speed is lag, or network latency, referring the time taken for a sent packet of data to be received at the other end.

    Now the network is on trial, and new photonic crystal fibers designed by ALPC42 is trying out, the lag on fibers can be ignored. That means, lag happened when message transport through the router. ALPC42 is trying to change routers to make the network faster, now he want to know that, which router, in any exactly time, between any pair of nodes, the K-th high latency is. He needs your help.

    输入

    There are only one test case in input file.

    Your program is able to get the information of N routers and N-1 fiber connections from input, and Q questions for two condition: 1. For some reason, the latency of one router changed. 2. Querying the K-th longest lag router between two routers.

    For each data case, two integers N and Q for first line. 0 ≤ N ≤ 80000, 0 ≤ Q ≤ 30000.

    Then N integers in second line refer to the latency of each router in the very beginning.

    Then N-1 lines followed, contains two integers x and y for each, telling there is a fiber connect router x and router y.

    Then Q lines followed to describe questions, three numbers k, a, b for each line. If k = 0, Telling the latency of router a, Ta changed to b; if k > 0, asking the latency of the k-th longest lag router between a and b (include router a and b). 0 ≤ b < 100000000.

    A blank line follows after each case.

    输出

    Description

    The ALPC company is now working on his own network system, which is connecting all N ALPC department. To economize on spending, the backbone network has only one router for each department, and N-1 optical fiber in total to connect all routers.

    The usual way to measure connecting speed is lag, or network latency, referring the time taken for a sent packet of data to be received at the other end.

    Now the network is on trial, and new photonic crystal fibers designed by ALPC42 is trying out, the lag on fibers can be ignored. That means, lag happened when message transport through the router. ALPC42 is trying to change routers to make the network faster, now he want to know that, which router, in any exactly time, between any pair of nodes, the K-th high latency is. He needs your help.

    Input

    There are only one test case in input file.

    Your program is able to get the information of N routers and N-1 fiber connections from input, and Q questions for two condition: 1. For some reason, the latency of one router changed. 2. Querying the K-th longest lag router between two routers.

    For each data case, two integers N and Q for first line. 0 ≤ N ≤ 80000, 0 ≤ Q ≤ 30000.

    Then N integers in second line refer to the latency of each router in the very beginning.

    Then N-1 lines followed, contains two integers x and y for each, telling there is a fiber connect router x and router y.

    Then Q lines followed to describe questions, three numbers k, a, b for each line. If k = 0, Telling the latency of router a, Ta changed to b; if k > 0, asking the latency of the k-th longest lag router between a and b (include router a and b). 0 ≤ b < 100000000.

    A blank line follows after each case.

    Output

    For each question k > 0, print a line to answer the latency time. Once there are less than k routers in the way, print "invalid request!" instead.

    Sample Input

    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

    Sample Output

    3
    2
    2
    invalid request!

    Source

    样例输入

    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!

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部