QOJ.ac

QOJ

حد الوقت: 4 s حد الذاكرة: 256 MB مجموع النقاط: 100

#1081. 满意度保证

الإحصائيات

考虑一种非常简单的编程语言,它只有三种类型的语句:

if <boolean expression> then <statement list> fi if <boolean expression> then <statement list> else <statement list> fi checkpoint

所有关键字必须由小写字母组成。一个 <statement list> 显然只是一条或多条语句的列表,整个程序就是一个单一的 <statement list>

一个 <boolean expression> 由以下部分组成: 变量:单个大写字母 运算符:一元运算符 ~ (NOT),二元运算符 & (AND),二元运算符 | (OR)。 优先级:~ > & > | 括号 无空格 <BE> -> ~<BE><BE>&<BE><BE>|<BE>(<BE>)[A-Z]

给定一个该简单语言中语法正确的程序,为了满足每一个 checkpoint,布尔变量必须取什么值?

输入格式

输入将是一个该简单语言中语法正确的单一程序。关键字保证全部为小写字母,布尔变量保证均为单个大写字母。空白字符(空格、制表符或换行符)保证用于分隔关键字并环绕表达式。表达式中不包含空白字符。每个 <statement list> 将至少包含一条语句。输入程序使用的变量不超过 20 个,且包含的语句不超过 5,000 条。没有任何布尔表达式的长度超过 128 个字符。

输出格式

对于每一个 checkpoint,按照它们出现的顺序,输出一行,由 > 后跟变量列表或单词 unreachable 组成。如果 checkpoint 是可达的,则输出一个按字母顺序排列的变量列表,如果变量必须为真,则使用大写字母;如果变量必须为假才能到达该 checkpoint,则使用小写字母。如果变量可以是任意值,则省略该变量。如果 checkpoint 不可达,则输出单词 unreachable(全部小写)。不要打印任何空格,也不要在输出行之间打印任何空行。

样例

样例输入 1

if A then
 checkpoint
 if ~A then
 checkpoint
 fi
else
 checkpoint
fi
if (A&B)|(~A&~B) then
 checkpoint 
fi
if A|~A then checkpoint fi
if B then
 if ~A then checkpoint fi
fi

样例输出 1

>A
>unreachable
>a
>
>
>aB

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.