CF932D.Tree

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

First line containing the number of queries QQ (1<=Q<=400000)(1<=Q<=400000) .

Let lastlast be the answer for previous query of type 22 (initially lastlast equals 00 ).

Each of the next QQ lines contains a query of following form:

  • 1 p q ( 1<=p,q<=10181<=p,q<=10^{18} ): This is query of first type where and . It is guaranteed that 1<=R<=cnt1<=R<=cnt and 0<=W<=1090<=W<=10^{9} .
  • 2 p q ( 1<=p,q<=10181<=p,q<=10^{18} ): This is query of second type where and . It is guaranteed that 1<=R<=cnt1<=R<=cnt and 0<=X<=10150<=X<=10^{15} .

denotes bitwise XOR of aa and bb .

It is guaranteed that at least one query of type 2 exists.

输入格式

Output the answer to each query of second type in separate line.

输出格式

In the first example,

last=0last=0

- Query 1: 1 1 1, Node 22 with weight 11 is added to node 11 .

- Query 2: 2 2 0, No sequence of nodes starting at 22 has weight less than or equal to 00 . last=0last=0

- Query 3: 2 2 1, Answer is 11 as sequence will be 2{2} . last=1last=1

- Query 4: 1 2 1, Node 33 with weight 11 is added to node 22 .

- Query 5: 2 3 1, Answer is 11 as sequence will be 3{3} . Node 22 cannot be added as sum of weights cannot be greater than 11 . last=1last=1

- Query 6: 2 3 3, Answer is 22 as sequence will be 3,2{3,2} . last=2last=2

输入输出样例

  • 输入#1

    6
    1 1 1
    2 2 0
    2 2 1
    1 3 0
    2 2 0
    2 2 2
    

    输出#1

    0
    1
    1
    2
    
  • 输入#2

    6
    1 1 0
    2 2 0
    2 0 3
    1 0 2
    2 1 3
    2 1 6
    

    输出#2

    2
    2
    3
    2
    
  • 输入#3

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

    输出#3

    1
    1
    2
    
  • 输入#4

    7
    1 1 3
    1 2 3
    2 3 4
    1 2 0
    1 5 3
    2 5 5
    2 7 22
    

    输出#4

    1
    2
    3
    

说明/提示

In the first example,

last=0last=0

- Query 1: 1 1 1, Node 22 with weight 11 is added to node 11 .

- Query 2: 2 2 0, No sequence of nodes starting at 22 has weight less than or equal to 00 . last=0last=0

- Query 3: 2 2 1, Answer is 11 as sequence will be 2{2} . last=1last=1

- Query 4: 1 2 1, Node 33 with weight 11 is added to node 22 .

- Query 5: 2 3 1, Answer is 11 as sequence will be 3{3} . Node 22 cannot be added as sum of weights cannot be greater than 11 . last=1last=1

- Query 6: 2 3 3, Answer is 22 as sequence will be 3,2{3,2} . last=2last=2

首页