포럼
문제 ICPC00383

C. Copycat Catcher

설명

Your university recently established the Graduate Code Plagiarism Control (GCPC) initiative to get hold of the ever-increasing load on the graders for the computer science assignments. Currently, the graders need to check the code of assignments manually for plagiarism. The GCPC aims to simplify this part of the graders' jobs by performing the plagiarism checks automatically.

Code consists of tokens separated by spaces. Tokens are strings of alphabetical letters, numerals, and brackets. If a token consists of only a single alphabetical letter (upper or lowercase), it is a variable in the code.

The GCPC wants the plagiarism checker to compare query pieces of code to a reference code. Specifically, it should check whether each query could have been obtained by selecting a contiguous string of tokens from the reference and consistently renaming variables.

Variables are consistently renamed if no two occurrences of the same variable are renamed to different variables, and if no two different variables are renamed to the same variable.

The GCPC has asked you to develop the plagiarism checker.

제약
입력 형식

The input consists of:
- A description of the reference, consisting of:
- One line containing an integer \(n\) (\(1\leq n \leq 2\,000\)), the number of tokens in the reference.
- One line containing \(n\) tokens, each consisting only of the characters 'a'-'z', 'A'-'Z', '0'-'9', '(' and ')'.
- An integer \(q\) (\(1 \leq q \leq 2\,000\)), the number of queries.
- \(2\cdot q\) lines, each two lines in the same format as the reference.

It is guaranteed that each query as well as the reference consist of at most \(2\,000\) characters (excluding spaces). Tokens are separated by single spaces.

출력 형식

For each query, output "yes" if the query could have been obtained from the reference, and "no" otherwise.

예제 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
출력
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
출력
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
출력
no
yes
no
yes
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC GCPC 2024

평가 및 의견

C. Copycat Catcher

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

C. Copycat Catcher

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8