Reverse Severer
면접 대비시간 제한1초메모리 제한2048 MB
문자열 S가 주어질 때, S를 여러 조각으로 나눈 뒤 조각의 순서를 뒤집어 이어 붙여 각 질의 문자열 T를 만들 수 있는지 판정한다.
문제
You are given a string of length . There are queries (numbered from to ) that you need to answer. For query , determine if a string of length , can be obtained by performing the following algorithm from the initial string .
- First, split the string into one or more substrings.
- Reverse the order of the substrings.
- Concatenate the substrings into a single string.
For instance, you can obtain string SEVERER from string REVERSE by splitting it into R, E, VER, and SE. After reversing the order of the substrings, your substrings will be SE, VER, E, and R. If you concatenate the substrings, then you can obtain string SEVERER.
입력
The first line consists of an integer ().
The second line consists of a string of length .
The third line consists of an integer ()
Each of the next lines consists of a string of length .
All strings consist of only upper-case letters.
출력
For each query, output a single line containing a string. If string can be obtained from the algorithm above, output YES. Otherwise, output NO.