Logo
(追記) (追記ここまで)

3599번 - Formula 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 64 MB21150.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:

  • Variables — letters from ‘a’ to ‘k’;
  • Parentheses — if E is a formula, then (E) is another;
  • Negation — ¬E is a formula for any formula E;
  • Conjunction — E1E2 ∧ · · · ∧ En.
  • Disjunction — E1E2 ∨ · · · ∨ En.

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.

제한

예제 입력 1

(a | b) & (a | c)

예제 출력 1

Yes
a | b & c

예제 입력 2

d&~d

예제 출력 2

No

예제 입력 3

d & ~d | ~((a|~b) & (a|c))

예제 출력 3

Yes
~a&(b|~c)

예제 입력 4

a & b | ~ a & ~b

예제 출력 4

No

힌트

출처

ICPC > Regionals > Northern Eurasia > Northwestern Russia Regional Contest > NEERC Northern Subregional 2007 F번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /