結果
問題 | No.2629 A replace B replace C |
ユーザー |
![]() |
提出日時 | 2024-02-16 21:47:46 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 68 ms / 2,000 ms |
コード長 | 538 bytes |
コンパイル時間 | 385 ms |
コンパイル使用メモリ | 81,900 KB |
実行使用メモリ | 85,320 KB |
最終ジャッジ日時 | 2024-09-28 20:01:41 |
合計ジャッジ時間 | 5,386 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 61 |
ソースコード
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 or "CB" 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")