| Author: | Well-known | Time limit: | 1 sec | |
| Input file: | Standard input | Memory limit: | 64 Mb | |
| Output file: | Standard output | |||
| Maximum points: | 8 |
An ancient mechanism contains gears that can be installed clockwise or counterclockwise. Each inscription states that gear i has direction di, gear j has direction dj, or both. The mechanism opens only when every inscription is true.
Formally, let xi = 1 mean clockwise and xi = 0 mean counterclockwise. Each inscription is a disjunction of two literals (li ∧ lj). Find an assignment satisfying every clause, or report that none exists.
The first line contains n, the number of clauses. Each of the next n lines contains at most two integers. A positive integer i denotes xi, and a negative integer − i denotes ¬ xi.
For example, (X ∧ Y) ∨ (¬ X ∧ Z) is represented as:
2
1 2
-1 3
Print any satisfying sequence of zeros and ones separated by spaces. Position i describes gear i. Its length must equal the largest gear index in the input. If the formula is unsatisfiable, print − 1.
| No. | Standard input | Standard output |
|---|---|---|
| 1 |
|
|
| 2 |
|
|