結果

問題 No.2629 A replace B replace C
ユーザー Shirotsume
提出日時 2024-02-16 23:57:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 692 bytes
コンパイル時間 698 ms
コンパイル使用メモリ 82,080 KB
実行使用メモリ 71,620 KB
最終ジャッジ日時 2024-09-28 23:08:56
合計ジャッジ時間 5,592 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 61
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, time, random
from collections import deque, Counter, defaultdict
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 61 - 1
mod = 998244353

n = ii()
s = input()
t = input()
ab = 0
bc = 0
ac = 0

for i in range(n):
    if s[i] == t[i]:
        continue
    if 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:
        print('No')
        exit()

#bc と ac をマッチング
if ac and not bc:
    print('No')
    exit()
if ab == bc:
    print('Yes')
else:
    print('No')
0