#P5354. [Ynoi Easy Round 2017] 由乃的 OJ
[Ynoi Easy Round 2017] 由乃的 OJ
Description
Yuno is building her OJ. Now she is dealing with the user ranking problem.
There are users registered on the OJ, numbered . Initially, they are ranked by their indices. Yuno, depending on her mood, would like to perform the following four types of operations to modify users’ rankings and indices. However, Yuno is in a very bad mood because Deus keeps asking her problems...
Because Deus keeps asking Yuno OI problems, Yuno went to study OI. Since Yuno is quite smart, she learned OI very well.
She entered the provincial team with the first place at RBOI2016 and then won a gold medal and a direct recommendation at NOI2016.
Deus: How do you solve this problem?
Yuno: Isn’t this just an easy problem from NOI2014...
Deus: What if we put it on a tree, with multiple path queries, with modifications?
Yuno: Eh...???
Deus: This problem is called “睡觉困难综合征”~
Although Yuno is good at OI, she basically isn’t good at DS; she can only hand-wave segment trees. For example, her NOI2016 scores were ... and her NOIP2017 scores were .
So she still has to ask you to help her...
You are given a tree with nodes. Each node has a bitwise operation and a value . The bitwise operations are &, |, ^, represented by respectively.
Each query consists of three integers . You choose an initial number . Then passes through all nodes on the path from to in order. Every time it passes a node , becomes . She wants to know the maximum possible final value when reaching . The initial value must be in .
Each modification consists of three integers , meaning that the operation at node is changed to and its value is changed to .
Input Format
The first line contains three integers . The meaning of is that each number on a node and each in the queries are less than .
Then lines follow. Each line contains two integers , representing the operation ID and the value of that node.
Then lines follow. Each line contains two integers , indicating that there is an edge between and .
Then lines follow. Each line contains four integers . Here indicates the type of operation ( for query, for modification), and have the meanings described above.
Output Format
For each operation of type , output the maximum value that can be obtained at the end.
5 5 3
1 7
2 6
3 7
3 6
3 1
1 2
2 3
3 4
1 5
1 1 4 7
1 1 3 5
2 1 1 3
2 3 3 3
1 1 3 2
7
1
5
2 2 2
2 2
2 2
1 2
2 2 2 2
1 2 2 2
3
Hint
Idea: f321dd, Solution: f321dd & nzhtl1477, Code: nzhtl1477, Data: nzhtl1477.
For of the testdata, .
For another of the testdata, .
For another of the testdata, only one kind of bitwise operation appears.
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号