比赛场次 | 629 |
---|---|
比赛名称 | 中秋节快乐! |
比赛状态 | 已结束比赛成绩 |
开始时间 | 2024-09-17 08:00:00 |
结束时间 | 2024-09-17 12:00:00 |
开放分组 | 全部用户 |
注释介绍 |
题目名称 | 树上异或xor |
---|---|
输入输出 | xor_xian.in/out |
时间限制 | 1000 ms (1 s) |
内存限制 | 256 MiB |
测试点数 | 10 简单对比 |
用户 | 结果 | 时间 | 内存 | 得分 |
---|---|---|---|---|
wdsjl | AAAAAATTTT | 8.024 s | 3.90 MiB | 60 |
彭欣越 | WAWWWWTTTT | 8.034 s | 3.61 MiB | 10 |
There is a tree with $n$ nodes. For each node, there is an integer value $a_i$, ($1≤a_i≤1,000,000,000$ for $1≤i≤n$).
There is $q$ queries which are described as follow:
Assume the value on the path from node $a$ to node $b$ is $t_0,t_1,⋯t_m$,You are supposed to calculate $t_0\ xor\ t_k\ xor\ t_{2k}\ xor\ ...\ xor\ t_{pk} (pk≤m)$.
题目大意:
给出一棵树,每个节点有个 $val$,$q$ 个询问。
询问格式:$u$, $v$, $k$, 从 $u$ 到 $v$ 的路径, 每隔 $k$ 个点取一个,求所有点的 $val$ 值异或和。
There is only $1$ dataset.($n≤50,000,q≤50,000$).
First $2$ integers $n,q$
In the first $n−1$ lines, there are two integers $u,v$, indicates there is an edge connect node $u$ and node $v$.
In the next $n$ lines, There is an integer $a_i$ ($1≤a_i≤1,000,000,000$).
In the next $q$ lines, There is three integers $a,b$ and $k$. ($1≤a,b,k≤n$).
For each query, output an integer in one line, without any additional space.
5 6 1 5 4 1 2 1 3 2 19 26 0 8 17 5 5 1 1 3 2 3 2 1 5 4 2 3 4 4 1 4 5
17 19 26 25 0 19
点击下载样例2
对于 $30\%$ 的数据,$1 \leq n,q \leq 20$;
对于 $60\%$ 的数据,$1 \leq n,q \leq 1000$;
对于 $100\%$ 的数据,$1 \leq n,q \leq 50000,1≤a_i≤1,000,000,000$;
2017 ACM-ICPC 亚洲区(西安赛区)网络赛