AtCoder Grand Contest 055
翻译中…
Problem Statement
翻译中…
You are given a string $S$ of length $N$, consisting of A, B, and C. You are allowed to perform the following operation any number of times:
翻译中…
- Choose any
$i$with$1 \le i \le N-2$, such that$S_iS_{i+1}S_{i+2}$is equal toABC,BCA, orCAB. Then, replace the three characters withABC,BCA, orCAB.
翻译中…
For example, you can perform the following transformations with string AABC:
翻译中…
AABC$\to$ABCA$\to$BCAA
翻译中…
Determine if you can obtain string $T$ from string $S$ with some finite (maybe zero) number of operations above.
翻译中…
Constraints
翻译中…
$3\le N \le 5\cdot 10^5$$S$is a string of length$N$consisting ofA,B, andC.$T$is a string of length$N$consisting ofA,B, andC.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N
S
T
翻译中…
Output
翻译中…
If you can transform $S$ into $T$ with the operations above, output YES, otherwise output NO. The checker is case-insensitive: you can use either uppercase or lowercase letters.
翻译中…
样例
Input #1
4
AABC
BCAA
Output #1
YES
This example was explained in the statement.
Input #2
4
ABCA
BCAB
Output #2
NO
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。