QOJ.ac

QOJ

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

#2487. 检查字符串

الإحصائيات

假设我们有一台在问题 B 中描述的虚拟机。

给定字符串 $s$ 以及该机器的一系列 $n$ 条指令(每条指令均来自列表 “copy”、“swap”、“roll”、“fuse”)。

最初,虚拟机的栈中包含两个字符串,形式为 “a b”。

列表中的所有指令将按顺序在虚拟机上执行。

请确定所有指令是否均已正确执行,或者其中某条指令的执行是否导致了 CRASH 事件。如果所有程序指令均已正确执行,则还需确定在执行完所有指令后,机器栈顶的字符串是否等于字符串 $s$。

输入格式

第一行包含字符串 $s$。它仅由小写拉丁字母 “a” 和 “b” 组成,长度为 $1$ 到 $10^5$ 个字符。

第二行包含一个整数 $n$ ($0 \le n \le 10^5$)。

接下来的 $n$ 行包含程序指令,每行一条,按在虚拟机上的执行顺序排列。每条指令均来自列表 “copy”、“swap”、“roll”、“fuse”。

输出格式

输出以下消息之一:

CRASH — 如果程序执行过程中发生了 CRASH 事件。

YES — 如果在执行完所有指令后,机器栈顶的字符串等于 $s$。

NO — 如果在执行完所有指令后,栈顶的字符串不等于 $s$。

样例

样例输入 1

ababa
9
swap
copy
roll
fuse
copy
fuse
copy
roll
fuse

样例输出 1

YES

样例输入 2

a
0

样例输出 2

NO

样例输入 3

aaba
1
roll

样例输出 3

CRASH

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.