結果
| 問題 | No.2629 A replace B replace C | 
| コンテスト | |
| ユーザー |  Cecil | 
| 提出日時 | 2024-02-16 22:54:41 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 493 bytes | 
| コンパイル時間 | 319 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 14,464 KB | 
| 最終ジャッジ日時 | 2024-09-28 21:32:03 | 
| 合計ジャッジ時間 | 5,827 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 WA * 1 | 
| other | AC * 54 WA * 7 | 
ソースコード
from collections import defaultdict as dd
N = int(input())
S = list(input())
T = list(input())
dic = dd(lambda:0)
for i in range(N):
    if S[i] == "B" and T[i] == "A":
        print("No")
        exit()
    elif S[i] == "C" and (T[i] == "B" or T[i] == "A"):
        print("No")
        exit()
    elif S[i] == T[i]:
        continue
    s = S[i]+T[i]
    dic[s] += 1
if dic["AB"]==dic["BC"]:
    print("Yes")
elif dic["AB"]==dic["AC"]==dic["BC"]==0:
    print("Yes")
else:
    print("No")
            
            
            
        