AtCoder Regular Contest 181
B
Annoying String Problem
AtCoder
⌀ 1633
原题
← AC →
翻译中…

Problem Statement

翻译中…

For strings $S$ and $T$ consisting of lowercase English letters, and a string $X$ consisting of 0 and 1, define the string $f(S,T,X)$ consisting of lowercase English letters as follows:

翻译中…
  • Starting with an empty string, for each $i=1,2,\dots,|X|$, append $S$ to the end if the $i$-th character of $X$ is 0, and append $T$ to the end if it is 1.
翻译中…

You are given a string $S$ consisting of lowercase English letters, and strings $X$ and $Y$ consisting of 0 and 1.

翻译中…

Determine if there exists a string $T$ (which can be empty) such that $f(S,T,X)=f(S,T,Y)$.

翻译中…

You have $t$ test cases to solve.

翻译中…

Constraints

翻译中…
  • $1 \leq t \leq 5 \times 10^5$
  • $1 \leq |S| \leq 5\times 10^5$
  • $1 \leq |X|,|Y| \leq 5\times 10^5$
  • $S$ is a string consisting of lowercase English letters.
  • $X$ and $Y$ are strings consisting of 0 and 1.
  • The sum of $|S|$ across all test cases in a single input is at most $5 \times 10^5$.
  • The sum of $|X|$ across all test cases in a single input is at most $5 \times 10^5$.
  • The sum of $|Y|$ across all test cases in a single input is at most $5 \times 10^5$.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

t
\mathrm{case}_1
\vdots
\mathrm{case}_t

翻译中…

Each case is given in the following format:

翻译中…

S
X
Y

翻译中…

Output

翻译中…

Print $t$ lines. The $i$-th line should contain Yes if there exists a $T$ that satisfies the condition for the $i$-th test case, and No otherwise.

翻译中…

样例

Input #1
3
araara
01
111
araaaa
100100
0010111
abacabac
0
1111
Output #1
Yes
No
No
Below, string concatenation is represented using $+$. For the 1st test case, if $T=$`ara`, then $f(S,T,X)=S+T=$`araaraara` and $f(S,T,Y)=T+T+T=$`araaraara`, so $f(S,T,X)=f(S,T,Y)$. For the 2nd and 3rd test cases, there is no $T$ that satisfies the condition.
Input #2
2
empty
10101
00
empty
11111
111
Output #2
Yes
Yes
$T$ can be empty.
题目信息
题号
arc181_b
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。