結果
| 問題 | No.2629 A replace B replace C |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-02-16 22:03:35 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 47 ms / 2,000 ms |
| コード長 | 696 bytes |
| 記録 | |
| コンパイル時間 | 297 ms |
| コンパイル使用メモリ | 85,584 KB |
| 実行使用メモリ | 81,220 KB |
| 最終ジャッジ日時 | 2026-04-15 09:06:19 |
| 合計ジャッジ時間 | 4,717 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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")