TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

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 formula:

. 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 — E1 & E2 & ... & En.

. Disjunction — E1 | E2 | ... | 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.

Input Format

The only line of input contains the Boolean function represented as a string consisting of characters
‘a’..‘k’, ‘(’, ‘)’, ‘~’, ‘&’ and ‘|’. Tokens can be
separated by an arbitrary number of spaces. The line contains 1000 characters at most. The formula in
the file is syntactically correct.

Output Format

The first line of the output file must contain “yes” if function is repetition-free and “no” otherwise.

Sample Input 1

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

Sample Output 1

yes
no
yes
no

Hints

Problem Source

Migrated from old NTUJ.

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 2000 65536 200