Two Choices Each
N boolean variables must satisfy M clauses, each an OR of two literals (3 -5 means x3 OR NOT x5). Is the formula satisfiable?
Input: the first line has N and M; each of the next M lines has two non-zero integers a b (negative = negated variable).
Output: YES or NO.
Constraints:
- 1 ≤ N ≤ 105
- 1 ≤ M ≤ 2×105
Sample Tests
Input 1
2 3 1 2 -1 2 -2 1
Output 1
YES
Input 2
1 2 1 1 -1 -1
Output 2
NO
Discussion (opens after you solve — no spoilers before)
No comments yet.