問題一覧 > 通常問題

No.2629 A replace B replace C

レベル : / AI推定難易度 : 1000 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 128
作問者 : tassei903 / テスター : noya2 👑 potato167
お気に入りにしたユーザー ProblemId : 10663 / 自分の提出
問題文最終更新日: 2024-02-16 17:47:52
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 A and one B in $S$, replace the chosen A with B, and replace the chosen B with C.

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もしくは右上の雲マークをクリックしてアカウントを作成してください。