|
|||
Bewitching LogicIf a witch weighs the same as a duck, she must be able to float like a duck. Since wood also floats, and you burn wood, you should burn the witch if she weighs the same as a duck. Well, logic can be confusing. The classic rule of modus ponens is that if you know “if P then Q” (written P==>Q) and you know P, then Q must also be true. However, if you have P==>Q and Q, you cannot derive anything about P. Given a series of logical implications and one known true statement, you must decide whether the other statements are true or false (or unknown). Input SpecificationEach case begins with two unsigned decimal integers, representing the number of logical variables and the number of statements. The integers will be separated by one space and followed by <EOLN>. The logical variables are just integers themselves numbered from 0 to one less than the number of variables. The individual statements will follow, each on its own line. They will follow the format as specified below. Sometimes a variable will appear alone within the statement and sometimes it will be preceded by !, signifying the negation of that variable. Following the statements will be one variable number stipulated to be true, followed by <EOLN>. “0 0<EOLN>” will follow the last data case. It is not to be processed; it just represents the end of input. Output Specification
Each output case should appear in the same order as the corresponding input case. The output
case should begin “ Sample Input
Output for Sample Input
|
|||
University of Debrecen; Faculty of Informatics; v. 09/30/2024 |