| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 2048 MB | 14 | 11 | 8 | 88.889% |
You are given a string $S$ of length $N$. There are $Q$ queries (numbered from $1$ to $Q$) that you need to answer. For query $i$, determine if a string $T_i$ of length $N$, can be obtained by performing the following algorithm from the initial string $S$.
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 $N$ ($1 ≤ N ≤ 10\, 000$).
The second line consists of a string $S$ of length $N$.
The third line consists of an integer $Q$ ($1 ≤ Q ≤ 100$)
Each of the next $Q$ lines consists of a string $T_i$ of length $N$.
All strings consist of only upper-case letters.
For each query, output a single line containing a string. If string $T_i$ can be obtained from the algorithm above, output YES. Otherwise, output NO.
7 REVERSE 5 SEVERER EVERSER REVERSE EVEREST RESERVE
YES YES YES NO NO
For query $2$, you can split the string into R and EVERSE.
For query $3$, note that you can split the string into one substring REVERSE.
3 INC 6 INC ICN NIC NCI CIN CNI
YES NO NO YES YES YES
1 A 2 A B
YES NO
ICPC > Regionals > Asia Pacific > Indonesia > Indonesia National Contest > INC 2023 E번