luogu#P4782. 【模板】2-SAT
【模板】2-SAT
Problem Description
There are Boolean variables , and constraints that must be satisfied. Each constraint has the form: “ is true / false or is true / false”. For example, “ is true or is false”, “ is false or is false”.
The goal of the 2-SAT problem is to assign a value to each variable so that all constraints are satisfied.
Input Format
The first line contains two integers and , with the meanings as described above.
The next lines each contain four integers , , , , meaning “ is or is a, b\in {0,1}$).
Output Format
If there is no solution, output IMPOSSIBLE.
Otherwise output POSSIBLE, and on the next line output integers (), representing a constructed solution.
3 1
1 1 3 0
POSSIBLE
0 0 0
Hint
. The first test points check for small mistakes, and the remaining test points check efficiency.
Since the testdata is generated randomly, it may contain tricky cases such as 10 0 10 0, but the official solution written in the most standard way did not make mistakes. The hints about what each test point is checking are in the official solution.
Translated by ChatGPT 5