|
||||||||||
TreeTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 102400/102400 K (Java/Others)Total Submission(s): 6238 Accepted Submission(s): 1706 Problem Description Zero and One are good friends who always have fun with each other. This time, they decide to do something on a tree which is a kind of graph that there is only one path from node to node. First, Zero will give One an tree and every node in this tree has a value. Then, Zero will ask One a series of queries. Each query contains three parameters: x, y, z which mean that he want to know the maximum value produced by z xor each value on the path from node x to node y (include node x, node y). Unfortunately, One has no idea in this question. So he need you to solve it. Input There are several test cases and the cases end with EOF. For each case: The first line contains two integers n(1<=n<=10^5) and m(1<=m<=10^5), which are the amount of tree¡¯s nodes and queries, respectively. The second line contains n integers a[1..n] and a[i](0<=a[i]<2^{16}) is the value on the ith node. The next n¨C1 lines contains two integers u v, which means there is an connection between u and v. The next m lines contains three integers x y z, which are the parameters of Zero¡¯s query. Output For each query, output the answer. Sample Input
Sample Output
Source | ||||||||||
|