CF696E....Wait for it...

NOI/NOI+/CTSC

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Barney is searching for his dream girl. He lives in NYC. NYC has n junctions numbered from 1 to n and n - 1 roads connecting them. We will consider the NYC as a rooted tree with root being junction 1. m girls live in NYC, i-th of them lives along junction c__i and her weight initially equals i pounds.

Barney consider a girl x to be better than a girl y if and only if: girl x has weight strictly less than girl y or girl x and girl y have equal weights and index of girl x living junction index is strictly less than girl y living junction index, i.e. c__x < c__y. Thus for any two girls one of them is always better than another one.

For the next q days, one event happens each day. There are two types of events:

  1. Barney goes from junction v to junction u. As a result he picks at most k best girls he still have not invited from junctions on his way and invites them to his house to test if one of them is his dream girl. If there are less than k not invited girls on his path, he invites all of them.
  2. Girls living along junctions in subtree of junction v (including v itself) put on some weight. As result, their weights increase by k pounds.

Your task is for each event of first type tell Barney the indices of girls he will invite to his home in this event.

巴尼正在寻找他梦寐以求的女孩。他住在纽约市(NYC)。NYC 有 nn 个路口,编号从 11 到 nn,以及 n−1n-1 条连接它们的道路。我们将 NYC 视为一棵以路口 11 为根的有根树。NYC 中住着 mm 位女孩,其中第 ii 位女孩住在路口 cic_i,她初始体重为 ii 磅。

巴尼认为女孩 xx 比女孩 yy 更好,当且仅当:女孩 xx 的体重严格小于女孩 yy 的体重;或者女孩 xx 与女孩 yy 体重相等,且女孩 xx 所在路口的编号严格小于女孩 yy 所在路口的编号,即 cx<cyc_x < c_y。因此,对于任意两位女孩,总有一位严格优于另一位。

接下来的 qq 天中,每天发生一个事件。事件共分两类:

  1. 巴尼从路口 vv 走到路口 uu。结果是,他从路径上的所有路口中,挑选至多 kk 位他尚未邀请过的、最优的女孩,并邀请她们到他家,以测试其中是否有人是他梦寐以求的女孩。若路径上未被邀请的女孩少于 kk 位,则他邀请全部这些女孩。
  2. 住在路口 vv 的子树(包含 vv 自身)内所有路口的女孩增重。结果是,她们的体重均增加 kk 磅。

你的任务是:对每个第一类事件,输出巴尼此次将邀请到家中的女孩们的索引(即女孩编号)。

输入格式

The first line of input contains three integers n, m and q (1 ≤ n, m, q ≤ 105) — the number of junctions in NYC, the number of girls living in NYC and the number of events respectively.

The next n - 1 lines describes the roads. Each line contains two integers v and u (1 ≤ v, u ≤ n, v ≠ u) meaning that there is a road connecting junctions v and u .

The next line contains m integers _c_1, _c_2, ..., c__m (1 ≤ c__i ≤ n) — the girl's living junctions.

The next q lines describe the events in chronological order. Each line starts with an integer t (1 ≤ t ≤ 2) — type of the event .

If t = 1 then the line describes event of first type three integers v, u and k (1 ≤ v, u, k ≤ n) follow — the endpoints of Barney's path and the number of girls that he will invite at most.

Otherwise the line describes event of second type and two integers v and k (1 ≤ v ≤ n, 1 ≤ k ≤ 109) follow — the root of the subtree and value by which all the girls' weights in the subtree should increase.

输入的第一行包含三个整数 nn、mm 和 qq(1 ≤ n, m, q ≤ 1051 ≤ n, m, q ≤ 10^5)——分别表示纽约市的路口数量、居住在纽约市的女孩数量以及事件总数。

接下来的 n − 1n - 1 行描述道路。每行包含两个整数 vv 和 uu(1 ≤ v, u ≤ n1 ≤ v, u ≤ n, v ≠ uv ≠ u),表示存在一条连接路口 vv 和 uu 的道路。

下一行包含 mm 个整数 c1, c2, ..., cmc_1, c_2, ..., c_m(1 ≤ ci ≤ n1 ≤ c_i ≤ n)——表示每位女孩所居住的路口编号。

接下来的 qq 行按时间顺序描述事件。每行以一个整数 tt(1 ≤ t ≤ 21 ≤ t ≤ 2)开头——表示事件类型。

若 t = 1t = 1,则该行为第一类事件,其后跟着三个整数 vv、uu 和 kk(1 ≤ v, u, k ≤ n1 ≤ v, u, k ≤ n)——分别表示 Barney 行进路径的两个端点,以及他最多邀请的女孩人数。

否则,该行为第二类事件,其后跟着两个整数 vv 和 kk(1 ≤ v ≤ n1 ≤ v ≤ n, 1 ≤ k ≤ 1091 ≤ k ≤ 10^9)——分别表示子树的根节点,以及该子树内所有女孩权重应增加的值。

输出格式

For each event of the first type, print number t and then t integers _g_1, _g_2, ..., g__t in one line, meaning that in this event Barney will invite t girls whose indices are _g_1, ..., g__t in the order from the best to the worst according to Barney's considerations.

对于每种第一类事件,输出数字 tt,然后在同一行输出 tt 个整数 g1, g2, ..., gtg_1,\,g_2,\,...,\,g_t,表示在该事件中,Barney 将按其个人标准从最优到最差的顺序邀请索引为 g1, ..., gtg_1,\,...,\,g_t 的 tt 位女生。

输入输出样例

  • 输入#1

    5 7 11
    3 5
    2 3
    4 3
    1 4
    4 1 4 5 4 1 4
    2 4 3
    1 2 1 2
    1 4 2 1
    2 2 10
    2 1 10
    1 2 4 1
    1 2 3 4
    2 5 2
    2 4 9
    1 3 5 2
    1 1 2 3

    输出#1

    2 2 1 
    1 3 
    1 5 
    0 
    1 4 
    2 6 7

说明/提示

For the first sample case:

Description of events:

  1. Weights of girls in subtree of junction 4 increase by 3. These girls have IDs: 1, 3, 5, 4, 7.
  2. Barney goes from junction 2 to 1. Girls on his way have IDs 1, 2, 3, 5, 6, 7 with weights 4, 2, 6, 8, 6, 10 respectively. So, he invites girls 2 and 1.
  3. Barney goes from junction 4 to junction 2. Girls on his way has IDs 3, 5, 7 with weights 6, 8, 10 respectively. So he invites girl 3.
  4. Weight of girls in subtree of junction 2 increase by 10. There are no not invited girls, so nothing happens.
  5. Weight of girls in subtree of junction 1 increase by 10. These girls (all girls left) have IDs: 4, 5, 6, 7.
  6. Barney goes from junction 2 to junction 4. Girls on his way has IDs 5, 7 with weights 18, 20 respectively. So he invites girl 5.
  7. Barney goes from junction 2 to junction 3. There is no girl on his way.
  8. Weight of girls in subtree of junction 5 increase by 2. The only girl there is girl with ID 4.
  9. Weight of girls in subtree of junction 4 increase by 9. These girls have IDs: 4, 6, 7.
  10. Barney goes from junction 3 to junction 5. Only girl on his way is girl with ID 4.
  11. Barney goes from junction 1 to junction 2. Girls on his way has IDs 6, 7 with weights 16, 29 respectively.

对于第一个样例:

事件描述如下:

  1. 结点 4 的子树中所有女孩的体重增加 3。这些女孩的编号为:1、3、5、4、7。
  2. 巴尼从结点 2 走到结点 1。沿途女孩的编号为 1、2、3、5、6、7,对应体重分别为 4、2、6、8、6、10。因此,他邀请了编号为 2 和 1 的女孩。
  3. 巴尼从结点 4 走到结点 2。沿途女孩的编号为 3、5、7,对应体重分别为 6、8、10。因此,他邀请了编号为 3 的女孩。
  4. 结点 2 的子树中所有女孩的体重增加 10。此时已无未被邀请的女孩,故无任何变化。
  5. 结点 1 的子树中所有女孩的体重增加 10。剩余所有女孩(即尚未被邀请的女孩)编号为:4、5、6、7。
  6. 巴尼从结点 2 走到结点 4。沿途女孩的编号为 5、7,对应体重分别为 18、20。因此,他邀请了编号为 5 的女孩。
  7. 巴尼从结点 2 走到结点 3。途中没有女孩。
  8. 结点 5 的子树中所有女孩的体重增加 2。该子树中仅有一名女孩,编号为 4。
  9. 结点 4 的子树中所有女孩的体重增加 9。这些女孩的编号为:4、6、7。
  10. 巴尼从结点 3 走到结点 5。途中唯一一名女孩编号为 4。
  11. 巴尼从结点 1 走到结点 2。沿途女孩的编号为 6、7,对应体重分别为 16、29。

输入解题思路,AI测评打分。不知道怎么写?

首页