結果
問題 | No.2629 A replace B replace C |
ユーザー |
|
提出日時 | 2024-02-16 22:02:42 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 696 bytes |
コンパイル時間 | 217 ms |
コンパイル使用メモリ | 82,512 KB |
実行使用メモリ | 76,516 KB |
最終ジャッジ日時 | 2024-09-28 20:19:27 |
合計ジャッジ時間 | 5,310 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 59 WA * 2 |
ソースコード
from collections import defaultdictimport sysinput = sys.stdin.readlineN = int(input())S = input().strip()T = input().strip()D = defaultdict(int)for s, t in zip(S, T):D[s+t] += 1if D["BA"]>0 or D["CA"]>0 or D["CB"]>0:print("No")exit()while D["AC"]>0 and D["BC"]>0:if D["AC"] > D["BC"]:D["AC"] = D["AC"]-D["BC"]else:D["AC"] = 0while D["AB"]>0 and D["BC"]>0:if D["AB"] > D["BC"]:D["AB"] = D["AB"]-D["BC"]D["BC"] = 0elif D["AB"] < D["BC"]:D["AB"] = 0D["BC"] = D["BC"] = D["AB"]else:D["AB"] = 0D["BC"] = 0if D["AB"]==D["AC"]==D["BC"]==0:print("Yes")else:print("No")