#P6123. [NEERC 2016] Hard Refactoring

[NEERC 2016] Hard Refactoring

Problem Description

For a variable xx, some constraints are given in the form xax \ge a or xax \le a. These constraints are connected using ||, and you need to simplify them and finally output the simplified constraints.

Input Format

The input has at most 10310^3 lines. Each line is either two constraints connected by && or a single constraint.

If a line has two constraints, the first constraint is always in the form xax \ge a, and the second constraint is always in the form xax \le a.

Except for the last line of the input, each line ends with a ||.

All characters (except >=, <=, &&, ||) are separated by spaces, and there are no extra leading or trailing spaces.

Output Format

Output several lines representing the simplest form of the constraints (that is, make the number of output lines as small as possible). The other formatting should remain the same as in the input format.

The output lines do not need to be in any particular order.

In particular, if for any x[32768,32767]x \in [-32768, 32767], xx can satisfy the constraints, output only one line: true. Otherwise, if for any x[32768,32767]x \in [-32768, 32767], xx cannot satisfy the constraints, output only one line: false.

x >= 5 && x <= 10 ||
x >= 7 && x <= 20 ||
x <= 2 ||
x >= 21 && x <= 25 ||
x >= 8 && x <= 10 ||
x >= 100
x <= 2 ||
x >= 5 && x <= 25 ||
x >= 100

Hint

For all numbers that appear in this problem (including xx), they are all 32768\ge -32768 (215-2^{15}) and 32767\le 32767 (21512^{15}-1).

Translated by ChatGPT 5