当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5274:Dylans loves tree

题目描述
Dylans is given a tree with $N$ nodes.

All nodes have a value $A[i]$.Nodes on tree is numbered by $1 \sim N$.

Then he is given $Q$ questions like that:

①$0 \ x \ y$:change node $x's$ value to $y$

②$1 \ x \ y$:For all the value in the path from $x$ to $y$,do they all appear even times?

For each ② question,it guarantees that there is at most one value that appears odd times on the path.

$1 \leq N,Q \leq 100000$, the value $A[i]∈N$ and $A[i] \leq 100000$
输入解释
In the first line there is a test number $T$.
($T \leq 3$ and there is at most one testcase that $N > 1000$)

For each testcase:

In the first line there are two numbers $N$ and $Q$.

Then in the next $N - 1$ lines there are pairs of $(X,Y)$ that stand for a road from $x$ to $y$.

Then in the next line there are $N$ numbers $A_1..A_N$ stand for value.

In the next $Q$ lines there are three numbers$(opt,x,y)$.
输出解释
For each question ② in each testcase,if the value all appear even times output "-1",otherwise output the value that appears odd times.
输入样例
1
3 2
1 2
2 3
1 1 1
1 1 2
1 1 3
输出样例
-1
1

提示
If you want to hack someone,N and Q in your testdata must smaller than 10000,and you shouldn't print any space in each end of the line.
来自杭电HDUOJ的附加信息
Recommend hujie

该题目是Virtual Judge题目,来自 杭电HDUOJ

题目来源 BestCoder Round #45

源链接: HDU-5274

最后修改于 2020-10-25T23:21:15+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 131072/131072K(Java/Others)