結果
| 問題 |
No.2629 A replace B replace C
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-02-16 22:03:35 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 60 ms / 2,000 ms |
| コード長 | 696 bytes |
| コンパイル時間 | 301 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 76,384 KB |
| 最終ジャッジ日時 | 2024-09-28 20:20:59 |
| 合計ジャッジ時間 | 5,384 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 61 |
ソースコード
from collections import defaultdict
import sys
input = sys.stdin.readline
N = int(input())
S = input().strip()
T = input().strip()
D = defaultdict(int)
for s, t in zip(S, T):
D[s+t] += 1
if 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"] = 0
while D["AB"]>0 and D["BC"]>0:
if D["AB"] > D["BC"]:
D["AB"] = D["AB"]-D["BC"]
D["BC"] = 0
elif D["AB"] < D["BC"]:
D["AB"] = 0
D["BC"] = D["BC"] - D["AB"]
else:
D["AB"] = 0
D["BC"] = 0
if D["AB"]==D["AC"]==D["BC"]==0:
print("Yes")
else:
print("No")