#P6627. [省选联考 2020 B 卷] 幸运数字
[省选联考 2020 B 卷] 幸运数字
Problem Description
To celebrate major progress in epidemic prevention and control, a shopping mall is holding a promotional event and offers customers some discount credits under the following rules.
- Each customer may choose any integer as their lucky number.
- Each customer’s initial discount credit is yuan.
- The mall has reward conditions, each with a corresponding reward value .
- Each customer checks these reward conditions in order. If the lucky number chosen by the customer satisfies the -th condition, then their discount credit will be XORed with the reward value corresponding to that condition.
There are three types of reward conditions. Suppose the customer’s lucky number is .
- Interval condition: it has two parameters and . The condition is satisfied if . It is guaranteed that .
- Equality condition: it has one parameter . The condition is satisfied if .
- Inequality condition: it has one parameter . The condition is satisfied if .
Xiaoyan knows all the reward conditions. He wants to know the maximum discount credit a customer can obtain and the corresponding lucky number. Please help him compute it.
Input Format
The first line contains a positive integer , representing the number of reward conditions.
The next lines each contain three or four integers describing one reward condition. The first integer of each line is , representing the type of the reward condition.
- If , the condition is an interval condition. The next three integers are .
- If , the condition is an equality condition. The next two integers are .
- If , the condition is an inequality condition. The next two integers are .
Output Format
Output one line with two integers. The first number is the maximum discount credit that can be obtained, and the second number is the corresponding lucky number.
If multiple lucky numbers can achieve the maximum discount credit, output the one with the smallest absolute value. If there are still multiple, output the largest one.
4
1 -100 -80 37
2 -3 3
3 4 64
1 -10 1024 156
223 -3
Hint
Sample Explanation
The lucky number satisfies reward conditions , so the reward credit is , where denotes the XOR operation.
Constraints and Conventions
of the testdata satisfy: .
of the testdata satisfy: .
of the testdata satisfy: $1 \le n \le 10^5, |L|, |R|, |A|, |B| \le 10^9, 1 \le w_i \le 10^9$.
Translated by ChatGPT 5