当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3540:Formula

Special Judge 特殊评判
题目描述

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)
#2d&~d
#3d & ~d | ~((a|~b) & (a|c))
#4a & b | ~ a & ~b
输出样例
#1Yes
a | b & c
#2No
#3Yes
~a&(b|~c)
#4No
来自北京大学POJ的附加信息
Case time limit(单组数据时间限制) 2000MS

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3540

最后修改于 2020-10-29T07:04:02+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
3000 65536