luogu#P6098. [USACO19FEB] Cow Land G
[USACO19FEB] Cow Land G
Background
Cow Land is a special cow amusement park where cows can walk around, eat tasty grass, and visit different attractions (especially the roller coasters, which are very popular).
Problem Description
Cow Land has a total of different attractions (). There are roads connecting pairs of attractions, which means there is exactly one simple path between any two attractions.
Each attraction has an enjoyment value , and this value may change. This is because some attractions are more appealing in the morning, while others are more appealing in the afternoon.
Cows traveling from attraction to attraction can enjoy all the sights along the path from to . The enjoyment value of this route is the bitwise XOR of the enjoyment values of all attractions on the path from to (including attraction and attraction ).
Please help the cows determine the enjoyment value of the routes they plan to take during their trip to Cow Land.
Input Format
The first line contains two integers ().
The next line contains integers, where the -th integer represents the enjoyment value of attraction .
The next lines each contain two integers , indicating that there is a road connecting attraction and attraction .
The last lines each contain 3 integers, describing an operation as follows.
1 i v, meaning to change to .2 i j, meaning to ask what the enjoyment value of the route from attraction to attraction is.
Output Format
For each operation of type 2, output the answer to the corresponding query.
5 5
1 2 4 8 16
1 2
1 3
3 4
3 5
2 1 5
1 1 16
2 3 5
2 1 5
2 1 3
21
20
4
20
Hint
Subtasks: For of the testdata, there are no update operations.
Translated by ChatGPT 5