시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 64 MB | 0 | 0 | 0 | 0.000% |
Nick is a mathematician and his speciality is Boolean logic, especially repetition-free functions. The Boolean function is repetition-free if it can be represented as a repetition-free formula. Formula is repetition-free if each variable occurs in the formula only once.
Let us fix the syntax of considered logical formulae:
a
’ to ‘k
’;The operations are listed from the highest priority to the lowest.
The problem is to represent given Boolean function by a repetition-free formula.
The only line of input contains the Boolean function represented as a string consisting of characters ‘a
’..‘k
’, ‘(
’, ‘)
’, ‘
’, ‘&
’ and ‘|
’. The last three tokens stand for ¬, ∧ and ∨ respectively. Tokens can be separated by an arbitrary number of spaces. The line contains 1 000 characters at most. The formula in the file is syntactically correct.
The first line of the output file must contain “Yes” if function is repetition-free and “No” otherwise.
In the former case the following line must contain the repetition-free formula for given Boolean function in the same format as in the input file. The line must contain no more than 1 000 characters.
(a | b) & (a | c)
Yes a | b & c
d&~d
No
d & ~d | ~((a|~b) & (a|c))
Yes ~a&(b|~c)
a & b | ~ a & ~b
No