結果

問題 No.2629 A replace B replace C
ユーザー ikoma
提出日時 2024-02-16 21:46:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 522 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 82,460 KB
実行使用メモリ 85,064 KB
最終ジャッジ日時 2024-09-28 20:00:32
合計ジャッジ時間 5,681 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 60 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import defaultdict,deque,Counter

N=int(input())
S=input().strip()
T=input().strip()

cnt = Counter([s+t for s,t in zip(S,T) if s!=t])
def solve(cnt):
    # (B,A) (C,A) があったらNo
    if "BA" in cnt or "CA" in cnt:
        return False
    # (A,C), (B,C) -> (B,C),(C,C)
    if cnt["AC"]>0 and cnt["BC"]==0:
        return False
    n = cnt["AC"]
    cnt[""]
    # (A,B),(B,C) -> (B,B),(C,C)
    return cnt["AB"]==cnt["BC"]

print("Yes" if solve(cnt) else "No")
0