QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 100

#12139. 模仿者捕捉器

Statistics

你的大学最近成立了研究生代码剽窃控制(GCPC)计划,以应对计算机科学作业批改者日益沉重的负担。目前,批改者需要手动检查作业代码是否存在剽窃行为。GCPC 旨在通过自动执行剽窃检查来简化批改者的工作。

A Plagiarism Keyboard

代码由以空格分隔的标记(token)组成。标记是由字母、数字和括号组成的字符串。如果一个标记仅由单个字母(大写或小写)组成,则它是代码中的一个变量。

GCPC 希望剽窃检查器将查询代码片段与参考代码进行比较。具体来说,它应该检查每个查询是否可以通过从参考代码中选择一段连续的标记,并对变量进行一致的重命名来获得。如果两个相同的变量没有被重命名为不同的变量,且没有两个不同的变量被重命名为相同的变量,则称变量被一致地重命名了。

GCPC 要求你开发这个剽窃检查器。

输入格式

输入包含: 参考代码的描述,包含: 一行包含一个整数 $n$ ($1 \le n \le 2\,000$),表示参考代码中的标记数量。 一行包含 $n$ 个标记,每个标记仅由字符 ‘a’-‘z’、‘A’-‘Z’、‘0’-‘9’、‘(’ 和 ‘)’ 组成。 一个整数 $q$ ($1 \le q \le 2\,000$),表示查询的数量。 * $2 \cdot q$ 行,每两行格式与参考代码相同。

保证每个查询以及参考代码最多包含 $2\,000$ 个字符(不包括空格)。标记由单个空格分隔。

输出格式

对于每个查询,如果查询可以从参考代码中获得,则输出 “yes”,否则输出 “no”。

样例

输入格式 1

9
for i in range(10) do print i j end
4
3
print j i
2
do print
6
k in range(10) do print k
6
k in range(10) do print j

输出格式 1

yes
yes
yes
no

输入格式 2

5
i is i times j
7
5
i is i times j
5
a is a times b
5
j is j times c
5
a is i times j
5
j is i times j
5
0 is 0 times j
5
i is i times i

输出格式 2

yes
yes
yes
no
no
no
no

输入格式 3

5
A 1 ( ) b
4
2
b 2
2
b 1
3
1 ) (
5
a 1 ( ) F

输出格式 3

no
yes
no
yes

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.