Satisfiability

Write a program to find all the solutions to a set of m three–literal
clauses c₁, …, c_(m) in conjunctive normal form.

For instance, $\{a = \mbox{\em true}, b = \mbox{\em false},
c = \mbox{\em true}, d = \mbox{\em true}\}$ is a possible solution for
the three clauses
a or b or c,  not a or b or c,  b or not c or d.

As another example, $\{a = \mbox{\em true}, b = \mbox{\em false}\}$ is a
possible solution for the clause
b or not a or a.
Stricktly speaking, this clause does not have three literals (in fact it
is equal to true, which has no literals at all), but in this exercise it
is allowed to have repeated literals in the same clause.

Input

Input consists of a natural number 1 ≤ n ≤ 20, followed by a natural
number m > 0, followed by c₁, …, c_(m). The names of the variables are
the first n lowercase letters, and all of them appear in the input at
least once. A negative literal is indicated by a minus symbol in front
of the variable.

Output

Print all the possible solutions of the set of clauses. The literals of
each solution must appear in alphabetical order. If there is no
solution, print a hyphen.

Information about the checker

You can print the solutions to this exercise in any order.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T12:03:25.573Z

© Jutge.org, 2006–2026.
https://jutge.org
