#P6627. Mall Discount Promotion

    ID: 19836 Type: Default 1000ms 256MiB

Mall Discount Promotion

Mall Discount Promotion

To celebrate significant progress in pandemic prevention, a mall holds a discount promotion. Each customer may choose an integer as their lucky number. Initially, the discount is 0. The mall has \(n\) reward conditions, each with a reward amount \(w_i\). A customer’s discount is updated by performing a bitwise XOR with \(w_i\) for each reward condition satisfied by their number \(x\).

The reward conditions are of three types:

  1. Interval Condition: Given two parameters \(L\) and \(R\) (with \(L < R\)), the condition is met if \(L \le x \le R\).
  2. Equality Condition: Given a parameter \(A\), the condition is met if \(x = A\).
  3. Non-equality Condition: Given a parameter \(B\), the condition is met if \(x \neq B\).

Given the information for all \(n\) conditions, determine the maximum discount a customer can achieve as well as one corresponding lucky number that attains that discount. If there are multiple lucky numbers which yield the maximum discount, output the smallest one.

inputFormat

The first line contains an integer (n) representing the number of reward conditions. Each of the next (n) lines represents a reward condition in one of the following formats:

For an interval condition: 1 L R w For an equality condition: 2 A w For a non-equality condition: 3 B w

Here, for the interval condition, (L < R) is guaranteed.

outputFormat

Output two space-separated integers: the maximum discount achievable and a lucky number that attains that discount. If multiple lucky numbers yield the maximum discount, output the smallest one.

sample

3
1 1 10 5
2 5 2
3 7 3
6 1

</p>