/
Time Limit: 2 sec / Memory Limit: 1024 MiB
Score: 100 points
Problem Statement
You are given a string S, T of length N consisting of only uppercase English letters. You can perform the following operation 0 or more times:
- If there exists a substring of S such that
TIOT, choose one and replace it withISCT. (More precisely, if there exists 1 \le i \le N-3 such that S_{i}={}T, S_{i+1}={}I, S_{i+2}={}O, S_{i+3}={}T, choose one and replace it with S_{i}={}I, S_{i+1}={}S, S_{i+2}={}C, S_{i+3}={}T.)
Can you make S equal to T by performing the operation?
You have Q test cases to answer.
Constraints
- 1 \leq Q \leq 5 \times 10^4
- 4 \le N \le 2 \times 10^5
- S and T are strings of length N consisting of uppercase English letters.
- The sum of N across the test cases is at most 2 \times 10^5.
Input
The input is given in the following format:
Q
{case}_1
{case}_2
\vdots
{case}_Q
Each test cases is given in the following format:
N S T
Output
Print Q lines. On the i-th line, print the answer to the i-th test case as either Yes or No.
Sample Input 1
3 10 ETIOTROPIC EISCTROPIC 6 BTIEOT BISECT 10 TIOTIOTIOT TIOISCISCT
Sample Output 1
Yes No Yes
For the first test case, you can match ETIOTROPIC to EISCTROPIC by performing the operation once as follows:
- The substring from the 2 nd to 5 th characters in
ETIOTROPICisTIOT, so replace it withISCT.
For the second test case, you cannot match two strings through the operation.
配点 : 100 点
問題文
英大文字のみからなる長さ N の文字列 S, T が与えられます。あなたは S に次の操作を 0 回以上行うことができます。
- S の連続部分文字列が
TIOTである部分が存在すれば一つ選ぶ。その部分をISCTに置換する。(より正確には、1 \leq i \leq N-3 を満たす整数 i であって S_{i}={}T, S_{i+1}={}I, S_{i+2}={}O, S_{i+3}={}Tを満たすものが存在するなら一つ選び、S_{i}={}I, S_{i+1}={}S, S_{i+2}={}C, S_{i+3}={}Tに置換する。)
操作によって S を T に一致させることはできますか?
Q 個のテストケースが与えられるので、それぞれについて答えてください。
制約
- 1 \leq Q \leq 5 \times 10^4
- 4 \leq N \leq 2 \times 10^5
- S,T は英大文字からなる長さ N の文字列
- ひとつの入力について、含まれるテストケースの N の総和は 2 \times 10^5 を超えない
入力
入力は以下の形式で与えられる。
Q
{case}_1
{case}_2
\vdots
{case}_Q
各テストケースは以下の形式で与えられる。
N S T
出力
全体で Q 行出力せよ。 i 行目には i 個目のテストケースに対する答えを Yes または No で出力せよ。
入力例 1
3 10 ETIOTROPIC EISCTROPIC 6 BTIEOT BISECT 10 TIOTIOTIOT TIOISCISCT
出力例 1
Yes No Yes
1 個目のテストケースでは次のように操作を 1 回行うことで ETIOTROPIC を EISCTROPIC に一致させることができます。
ETIOTROPICの 2 文字目から 5 文字目がTIOTであるので、この部分をISCTに置き換える。
一方 2 個目のテストケースでは操作によって 2 つの文字列を一致させることはできません。