A11631 | Tree
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
First line containing the number of queries $Q$ $(1<=Q<=400000)$ .
Let $last$ be the answer for previous query of type $2$ (initially $last$ equals $0$ ).
Each of the next $Q$ lines contains a query of following form:
- 1 p q ( $1<=p,q<=10^{18}$ ): This is query of first type where  and . It is guaranteed that $1<=R<=cnt$ and $0<=W<=10^{9}$ .
- 2 p q ( $1<=p,q<=10^{18}$ ): This is query of second type where  and . It is guaranteed that $1<=R<=cnt$ and $0<=X<=10^{15}$ .
 denotes bitwise XOR of $a$ and $b$ .
It is guaranteed that at least one query of type 2 exists.
Let $last$ be the answer for previous query of type $2$ (initially $last$ equals $0$ ).
Each of the next $Q$ lines contains a query of following form:
- 1 p q ( $1<=p,q<=10^{18}$ ): This is query of first type where  and . It is guaranteed that $1<=R<=cnt$ and $0<=W<=10^{9}$ .
- 2 p q ( $1<=p,q<=10^{18}$ ): This is query of second type where  and . It is guaranteed that $1<=R<=cnt$ and $0<=X<=10^{15}$ .
 denotes bitwise XOR of $a$ and $b$ .
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=0$
\- Query 1: 1 1 1, Node $2$ with weight $1$ is added to node $1$ .
\- Query 2: 2 2 0, No sequence of nodes starting at $2$ has weight less than or equal to $0$ . $last=0$
\- Query 3: 2 2 1, Answer is $1$ as sequence will be ${2}$ . $last=1$
\- Query 4: 1 2 1, Node $3$ with weight $1$ is added to node $2$ .
\- Query 5: 2 3 1, Answer is $1$ as sequence will be ${3}$ . Node $2$ cannot be added as sum of weights cannot be greater than $1$ . $last=1$
\- Query 6: 2 3 3, Answer is $2$ as sequence will be ${3,2}$ . $last=2$
$last=0$
\- Query 1: 1 1 1, Node $2$ with weight $1$ is added to node $1$ .
\- Query 2: 2 2 0, No sequence of nodes starting at $2$ has weight less than or equal to $0$ . $last=0$
\- Query 3: 2 2 1, Answer is $1$ as sequence will be ${2}$ . $last=1$
\- Query 4: 1 2 1, Node $3$ with weight $1$ is added to node $2$ .
\- Query 5: 2 3 1, Answer is $1$ as sequence will be ${3}$ . Node $2$ cannot be added as sum of weights cannot be greater than $1$ . $last=1$
\- Query 6: 2 3 3, Answer is $2$ as sequence will be ${3,2}$ . $last=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=0$
\- Query 1: 1 1 1, Node $2$ with weight $1$ is added to node $1$ .
\- Query 2: 2 2 0, No sequence of nodes starting at $2$ has weight less than or equal to $0$ . $last=0$
\- Query 3: 2 2 1, Answer is $1$ as sequence will be ${2}$ . $last=1$
\- Query 4: 1 2 1, Node $3$ with weight $1$ is added to node $2$ .
\- Query 5: 2 3 1, Answer is $1$ as sequence will be ${3}$ . Node $2$ cannot be added as sum of weights cannot be greater than $1$ . $last=1$
\- Query 6: 2 3 3, Answer is $2$ as sequence will be ${3,2}$ . $last=2$
$last=0$
\- Query 1: 1 1 1, Node $2$ with weight $1$ is added to node $1$ .
\- Query 2: 2 2 0, No sequence of nodes starting at $2$ has weight less than or equal to $0$ . $last=0$
\- Query 3: 2 2 1, Answer is $1$ as sequence will be ${2}$ . $last=1$
\- Query 4: 1 2 1, Node $3$ with weight $1$ is added to node $2$ .
\- Query 5: 2 3 1, Answer is $1$ as sequence will be ${3}$ . Node $2$ cannot be added as sum of weights cannot be greater than $1$ . $last=1$
\- Query 6: 2 3 3, Answer is $2$ as sequence will be ${3,2}$ . $last=2$
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted