結果

問題 No.2629 A replace B replace C
ユーザー Meso Meso
提出日時 2025-06-09 09:19:41
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 117 ms / 2,000 ms
コード長 395 bytes
コンパイル時間 726 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,984 KB
最終ジャッジ日時 2025-06-09 09:19:51
合計ジャッジ時間 8,960 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 61
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = input()
t = input()

ab= ac = bc = 0
flag = True

for i in range(n):
    if s[i] > t[i]:
        flag = False
    elif s[i] == "A" and t[i] == "B":
        ab += 1
    elif s[i] == "A" and t[i] == "C":
        ac += 1
    elif s[i] == "B" and t[i] == "C":
        bc += 1

if ab != bc:
    flag = False
if ac > 0 and bc == 0:
    flag = False

print("Yes" if flag else "No")
0