Logo
(追記) (追記ここまで)

32479번 - Copycat Catcher 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 (추가 시간 없음) 1024 MB87282554.348%

문제

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

예제 출력 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

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > German Collegiate Programming Contest > GCPC 2024 C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /