| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 10955 | Prefix to truth table 2 |
|
Description
Give a prefix Boolean expression, which only has at most 4 variables ‘A’, ‘B’, ‘C’, and ‘D’, and 2 operators, AND ‘&’ and OR ‘|’, print its truth table which output equal to 1.
For example, if input is "&|AB|CA", then result will be
A B C D output
0 1 1 0 1
0 1 1 1 1
1 0 0 0 1
1 0 0 1 1
1 0 1 0 1
1 0 1 1 1
1 1 0 0 1
1 1 0 1 1
1 1 1 0 1
1 1 1 1 1
Input
The input contains a sequences of prefix expression. It only has at most 4 variables ‘A’, ‘B’, ‘C’, and ‘D’, and 2 operators, AND ‘&’ and OR ‘|’. The length of prefix expression is shorter than 30.
Output
It has 4 variables 'A', 'B', 'C', 'D', and output, each variable is separated by a space.