結果
| 問題 | No.2629 A replace B replace C | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-02-16 21:36:58 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 93 ms / 2,000 ms | 
| コード長 | 486 bytes | 
| コンパイル時間 | 233 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 11,648 KB | 
| 最終ジャッジ日時 | 2024-09-28 19:51:17 | 
| 合計ジャッジ時間 | 5,556 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 5 | 
| other | AC * 61 | 
ソースコード
n = int(input())
s = input()
t = input()
ok = True
ab = 0
bc = 0
ac = 0
for i in range(n):
    if s[i] == t[i]: continue
    elif s[i] == "A" and t[i] == "B":
        ab += 1
    elif s[i] == "B" and t[i] == "C":
        bc += 1
    elif s[i] == "A" and t[i] == "C":
        ac += 1
    else:
        ok = False
if ok:
    if ab == 0 and bc == 0 and ac == 0:
        print("Yes")
    elif ab*bc == 0 or ab != bc:
        print("No")
    else:
        print("Yes")
else:
    print("No")
            
            
            
        