結果

問題 No.2629 A replace B replace C
ユーザー Cecil
提出日時 2024-02-16 23:00:35
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 508 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 14,464 KB
最終ジャッジ日時 2024-09-28 21:35:02
合計ジャッジ時間 5,733 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 61
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict as dd

N = int(input())
S = list(input())
T = list(input())

dic = dd(lambda:0)

for i in range(N):
    if S[i] == "B" and T[i] == "A":
        print("No")
        exit()
    elif S[i] == "C" and (T[i] == "B" or T[i] == "A"):
        print("No")
        exit()
    elif S[i] == T[i]:
        continue
    s = S[i]+T[i]
    dic[s] += 1
if 0<dic["AB"] and dic["AB"]==dic["BC"]:
    print("Yes")
elif dic["AB"]==dic["AC"]==dic["BC"]==0:
    print("Yes")
else:
    print("No")
0