No.2629 A replace B replace C
問題文最終更新日: 2024-02-16 17:47:52
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
traP 作問ハッカソンコンテスト 002(day1)
(順位表)
の他の問題:
Problem Statement
You are given strings $S$, $T$ of length $N$ consisting of A , B , C. Determine whether it is possible to make $S$ equal to $T$ by performing the following operation on $S$ $0$ or more times.
- Choose one
Aand oneBin $S$, replace the chosenAwithB, and replace the chosenBwithC.
Constraints
-
$1 \le N \le 2 \times 10^5$
-
$S, T$ are strings of length $N$ consisting of
A,B,C
Input
$N$ $S$ $T$
Output
Print Yes if $S$ can be made equal to $T$, and No otherwise.
Sample
Sample 1
Input
2 AB BC
Output
Yes
Replacing $S_1$= A with B and $S_2$= B with C makes it equal to $T$.
Sample 2
Input
2 BC AB
Output
No
Sample 3
Input
1 A C
Output
No
Sample 4
Input
3 ABC ABC
Output
Yes
Sample 5
Input
4 AAAB BCCC
Output
Yes
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
noya2