結果

問題 No.2629 A replace B replace C
ユーザー ShirotsumeShirotsume
提出日時 2024-02-16 23:57:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 692 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 71,224 KB
最終ジャッジ日時 2024-02-16 23:57:13
合計ジャッジ時間 6,075 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
71,224 KB
testcase_01 AC 50 ms
66,380 KB
testcase_02 AC 51 ms
66,380 KB
testcase_03 AC 55 ms
66,948 KB
testcase_04 AC 50 ms
64,320 KB
testcase_05 AC 50 ms
66,380 KB
testcase_06 AC 46 ms
62,168 KB
testcase_07 AC 49 ms
66,380 KB
testcase_08 AC 50 ms
68,428 KB
testcase_09 AC 54 ms
70,480 KB
testcase_10 AC 52 ms
66,368 KB
testcase_11 AC 53 ms
68,432 KB
testcase_12 AC 51 ms
66,368 KB
testcase_13 AC 51 ms
66,380 KB
testcase_14 AC 53 ms
68,432 KB
testcase_15 AC 52 ms
68,432 KB
testcase_16 AC 51 ms
66,380 KB
testcase_17 AC 51 ms
66,380 KB
testcase_18 AC 60 ms
66,372 KB
testcase_19 AC 51 ms
64,316 KB
testcase_20 AC 51 ms
66,380 KB
testcase_21 AC 53 ms
68,432 KB
testcase_22 AC 52 ms
68,432 KB
testcase_23 AC 54 ms
68,428 KB
testcase_24 AC 53 ms
68,428 KB
testcase_25 AC 53 ms
68,432 KB
testcase_26 AC 52 ms
68,428 KB
testcase_27 AC 51 ms
68,432 KB
testcase_28 AC 52 ms
68,428 KB
testcase_29 AC 49 ms
66,372 KB
testcase_30 AC 54 ms
66,384 KB
testcase_31 AC 42 ms
58,328 KB
testcase_32 AC 43 ms
58,328 KB
testcase_33 AC 43 ms
58,892 KB
testcase_34 AC 43 ms
58,328 KB
testcase_35 AC 43 ms
58,328 KB
testcase_36 AC 42 ms
58,852 KB
testcase_37 AC 47 ms
58,328 KB
testcase_38 AC 41 ms
58,328 KB
testcase_39 AC 43 ms
58,328 KB
testcase_40 AC 43 ms
58,328 KB
testcase_41 AC 50 ms
68,428 KB
testcase_42 AC 53 ms
68,436 KB
testcase_43 AC 52 ms
68,432 KB
testcase_44 AC 52 ms
68,428 KB
testcase_45 AC 52 ms
70,480 KB
testcase_46 AC 52 ms
71,020 KB
testcase_47 AC 50 ms
68,428 KB
testcase_48 AC 51 ms
68,432 KB
testcase_49 AC 49 ms
66,376 KB
testcase_50 AC 51 ms
68,432 KB
testcase_51 AC 51 ms
68,428 KB
testcase_52 AC 48 ms
66,364 KB
testcase_53 AC 47 ms
64,316 KB
testcase_54 AC 53 ms
64,316 KB
testcase_55 AC 52 ms
66,364 KB
testcase_56 AC 54 ms
64,316 KB
testcase_57 AC 51 ms
68,432 KB
testcase_58 AC 47 ms
66,372 KB
testcase_59 AC 51 ms
68,428 KB
testcase_60 AC 48 ms
66,364 KB
testcase_61 AC 43 ms
56,268 KB
testcase_62 AC 44 ms
56,268 KB
testcase_63 AC 42 ms
56,268 KB
testcase_64 AC 40 ms
56,268 KB
testcase_65 AC 42 ms
56,268 KB
権限があれば一括ダウンロードができます

ソースコード

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