結果

問題 No.2629 A replace B replace C
ユーザー FromBooskaFromBooska
提出日時 2024-02-17 07:22:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 777 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 75,912 KB
最終ジャッジ日時 2024-02-17 07:22:23
合計ジャッジ時間 6,173 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
68,516 KB
testcase_01 AC 57 ms
73,668 KB
testcase_02 AC 51 ms
71,992 KB
testcase_03 AC 62 ms
75,912 KB
testcase_04 AC 44 ms
65,856 KB
testcase_05 AC 50 ms
70,060 KB
testcase_06 AC 53 ms
65,964 KB
testcase_07 AC 49 ms
70,060 KB
testcase_08 AC 49 ms
72,108 KB
testcase_09 AC 61 ms
75,448 KB
testcase_10 AC 61 ms
75,588 KB
testcase_11 AC 62 ms
75,588 KB
testcase_12 AC 62 ms
75,588 KB
testcase_13 AC 51 ms
72,132 KB
testcase_14 AC 62 ms
75,588 KB
testcase_15 AC 65 ms
75,588 KB
testcase_16 AC 56 ms
71,992 KB
testcase_17 AC 57 ms
72,108 KB
testcase_18 AC 50 ms
72,108 KB
testcase_19 AC 45 ms
67,904 KB
testcase_20 AC 46 ms
68,012 KB
testcase_21 AC 70 ms
75,448 KB
testcase_22 AC 53 ms
73,028 KB
testcase_23 AC 57 ms
75,564 KB
testcase_24 AC 63 ms
72,128 KB
testcase_25 AC 53 ms
73,272 KB
testcase_26 AC 47 ms
70,060 KB
testcase_27 AC 50 ms
71,992 KB
testcase_28 AC 57 ms
75,588 KB
testcase_29 AC 43 ms
65,964 KB
testcase_30 AC 46 ms
67,896 KB
testcase_31 AC 65 ms
75,448 KB
testcase_32 AC 62 ms
75,448 KB
testcase_33 AC 67 ms
75,828 KB
testcase_34 AC 61 ms
75,448 KB
testcase_35 AC 66 ms
75,588 KB
testcase_36 AC 69 ms
75,748 KB
testcase_37 AC 68 ms
75,448 KB
testcase_38 AC 64 ms
75,588 KB
testcase_39 AC 52 ms
72,000 KB
testcase_40 AC 59 ms
75,456 KB
testcase_41 AC 59 ms
70,060 KB
testcase_42 AC 59 ms
75,448 KB
testcase_43 AC 59 ms
75,588 KB
testcase_44 AC 60 ms
72,108 KB
testcase_45 AC 62 ms
75,448 KB
testcase_46 AC 68 ms
75,744 KB
testcase_47 AC 51 ms
72,108 KB
testcase_48 AC 51 ms
72,000 KB
testcase_49 AC 47 ms
68,012 KB
testcase_50 AC 61 ms
75,588 KB
testcase_51 AC 59 ms
75,588 KB
testcase_52 AC 48 ms
70,060 KB
testcase_53 AC 42 ms
63,916 KB
testcase_54 AC 47 ms
65,856 KB
testcase_55 AC 44 ms
65,964 KB
testcase_56 AC 44 ms
65,964 KB
testcase_57 AC 59 ms
75,588 KB
testcase_58 AC 55 ms
67,904 KB
testcase_59 AC 59 ms
75,564 KB
testcase_60 AC 48 ms
70,060 KB
testcase_61 AC 35 ms
55,608 KB
testcase_62 AC 36 ms
55,608 KB
testcase_63 AC 35 ms
55,608 KB
testcase_64 AC 35 ms
55,608 KB
testcase_65 AC 35 ms
55,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# STで異なる組だけを見る
# [BC, AC]を[CC, BC]に変える、[AB, BC]を[BB, CC]に変える

N = int(input())
S = input()
T = input()

from collections import defaultdict
dic = defaultdict(int)

for i in range(N):
    if S[i] == T[i]:
        continue
    dic[(S[i], T[i])] += 1
    
#print(dic)

if dic[('B', 'C')] > 0 and dic[('A', 'C')] > 0 and dic[('A', 'B')] > 0:
    ABACBC = min(dic[('A', 'B')], dic[('A', 'C')], dic[('B', 'C')])
    dic[('A', 'C')] = 0
    dic[('A', 'B')] -= ABACBC
    dic[('B', 'C')] -= ABACBC

ABBC = min(dic[('A', 'B')], dic[('B', 'C')])
dic[('A', 'B')] -= ABBC
dic[('B', 'C')] -= ABBC
    
ans = 'Yes'
for i in ['A', 'B', 'C']:
    for j in ['A', 'B', 'C']:
        if dic[(i, j)] > 0:
            ans = 'No'
print(ans)

#print(dic)



0