11574 - Prefix to truth table
|
Time |
Memory |
| Case 1 |
1 sec |
32 MB |
| Case 2 |
1 sec |
32 MB |
| Case 3 |
1 sec |
32 MB |
| Case 4 |
1 sec |
32 MB |
| Case 5 |
1 sec |
32 MB |
| Case 6 |
1 sec |
32 MB |
| Case 7 |
1 sec |
32 MB |
| Case 8 |
1 sec |
32 MB |
| Case 9 |
1 sec |
32 MB |
| Case 10 |
1 sec |
32 MB |
Description
Give a prefix Boolean expression, which only has at most 26 variables ‘A’, ‘B’, ‘C’... 'Z', and 3 operators, AND ‘&’ , OR ‘|’, and ExclusiveOR '^', print its truth table which output equal to 1.
For example, if input is "4 7 &|AB|CA", then result will be
A B C D
0 1 1 0
0 1 1 1
1 0 0 0
1 0 0 1
1 0 1 0
1 0 1 1
1 1 0 0
1 1 0 1
1 1 1 0
1 1 1 1
Input
The input contains two unsigned short number (num and length) and a sequences of prefix expression.
- First unsigned short number (num) means the number of variables from 'A' to 'A'+num-1. (e.g. 5 => 'A', 'B', 'C', 'D', 'E' ) 1 <= num <= 26
- Second unsigned short number (length) means the length of prefix expression.
- A sequences of prefix expression only has at most 26 variables ‘A’, ‘B’, ‘C’... 'Z', and 3 operators, AND ‘&’ , OR ‘|’, and ExclusiveOR '^'.
Output
Print its truth table which output equal to 1. (It has ' ' behind each number)
Tags