eolymp
bolt
Try our new interface for solving problems
Problems

Satisfaction Guaranteed

Satisfaction Guaranteed

Consider a very simple programming language, with only three types of statements: \textbf{if then fi} \textbf{if then else fi} \textbf{checkpoint} All keywords are required to consist of all lower case letters. A is obviously just a list of one or more statements, and an entire program is a single . A consists of: Variables: a single capital letter Operators: unary \textbf{~} (\textbf{NOT}), binary \textbf{&} (\textbf{AND}), binary \textbf{|} (\textbf{OR}). Precedence:\textbf{ ~ > & > |} Parentheses NO Spaces \textbf{→ ~ or & or | or () or \[A-Z\]} Given a syntactically correct program in this simple language, what values must the boolean variables hold in order to satisfy each of the checkpoints? \InputFile Input will be a single syntactically correct program in this simple language. Keywords are guaranteed to be in all lower case, and boolean variables are guaranteed to each be a single upper case letter. White space (space, tab or newline) is guaranteed to separate keywords, and surround expressions. Expressions will not contain whitespace. Every will contain at least one statement. The input program will not use more than \textbf{20} of the available variables, and will not contain more than \textbf{5000} statements. No Boolean expression will be longer than \textbf{128} characters. \OutputFile For each \textbf{checkpoint}, in the order they appear, output a single line, consisting of '\textbf{>}' followed by either a list of variables, or the word '\textbf{unreachable}'. If the \textbf{checkpoint} is reachable, output a list of variables, in alphabetical order, with an upper case letter if it must be true, or a lower case letter if it must be false to reach the \textbf{checkpoint}. Omit the variable if it can be either. If the \textbf{checkpoint} is not reachable, then output the word '\textbf{unreachable}', entirely in lower case. Do not print any spaces, and do not print any blank lines between lines of output.
Time limit 1 second
Memory limit 64 MiB
Source The University of Chicago Invitational Programming Contest 2013, March 29-31, 2013