結果

問題 No.2629 A replace B replace C
ユーザー rlangevinrlangevin
提出日時 2024-02-16 21:36:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 923 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 90,360 KB
最終ジャッジ日時 2024-02-16 21:36:28
合計ジャッジ時間 5,576 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
90,360 KB
testcase_01 AC 56 ms
70,452 KB
testcase_02 AC 46 ms
62,076 KB
testcase_03 AC 53 ms
69,020 KB
testcase_04 AC 43 ms
56,292 KB
testcase_05 AC 45 ms
59,884 KB
testcase_06 AC 45 ms
59,812 KB
testcase_07 AC 55 ms
68,124 KB
testcase_08 AC 59 ms
70,628 KB
testcase_09 AC 62 ms
73,476 KB
testcase_10 AC 59 ms
73,188 KB
testcase_11 AC 49 ms
65,136 KB
testcase_12 AC 59 ms
73,712 KB
testcase_13 AC 54 ms
67,776 KB
testcase_14 AC 63 ms
73,328 KB
testcase_15 AC 47 ms
62,848 KB
testcase_16 AC 45 ms
59,908 KB
testcase_17 AC 47 ms
62,752 KB
testcase_18 AC 58 ms
73,204 KB
testcase_19 AC 52 ms
67,792 KB
testcase_20 AC 54 ms
68,060 KB
testcase_21 AC 65 ms
73,280 KB
testcase_22 AC 58 ms
70,264 KB
testcase_23 AC 60 ms
73,296 KB
testcase_24 AC 58 ms
73,296 KB
testcase_25 AC 57 ms
70,720 KB
testcase_26 AC 55 ms
70,380 KB
testcase_27 AC 55 ms
68,048 KB
testcase_28 AC 59 ms
73,164 KB
testcase_29 AC 52 ms
67,920 KB
testcase_30 AC 53 ms
67,340 KB
testcase_31 AC 50 ms
65,564 KB
testcase_32 AC 50 ms
65,456 KB
testcase_33 AC 55 ms
69,384 KB
testcase_34 AC 48 ms
62,776 KB
testcase_35 AC 49 ms
65,172 KB
testcase_36 AC 52 ms
68,708 KB
testcase_37 AC 52 ms
67,968 KB
testcase_38 AC 51 ms
67,932 KB
testcase_39 AC 48 ms
64,932 KB
testcase_40 AC 51 ms
65,600 KB
testcase_41 AC 49 ms
62,040 KB
testcase_42 AC 47 ms
62,612 KB
testcase_43 AC 47 ms
62,492 KB
testcase_44 AC 47 ms
62,788 KB
testcase_45 AC 50 ms
65,456 KB
testcase_46 AC 52 ms
68,592 KB
testcase_47 AC 48 ms
62,824 KB
testcase_48 AC 47 ms
62,240 KB
testcase_49 AC 44 ms
59,848 KB
testcase_50 AC 48 ms
64,968 KB
testcase_51 AC 57 ms
70,436 KB
testcase_52 AC 54 ms
70,828 KB
testcase_53 AC 47 ms
62,812 KB
testcase_54 AC 50 ms
65,272 KB
testcase_55 AC 50 ms
65,508 KB
testcase_56 AC 47 ms
62,612 KB
testcase_57 AC 58 ms
70,612 KB
testcase_58 AC 50 ms
65,348 KB
testcase_59 AC 61 ms
73,516 KB
testcase_60 AC 52 ms
68,092 KB
testcase_61 AC 41 ms
53,460 KB
testcase_62 AC 38 ms
53,460 KB
testcase_63 AC 38 ms
53,460 KB
testcase_64 AC 39 ms
53,460 KB
testcase_65 AC 37 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = list(input())
T = list(input())
s = [S.count("A"), S.count("B"), S.count("C")]
t = [T.count("A"), T.count("B"), T.count("C")]
if s[1] == 0:
    if S == T:
        print("Yes")
    else:
        print("No")
else:
    if s[1] == t[1] and s[0] >= t[0]:
        ab, ac, bc = 0, 0, 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] == "A" and T[i] == "C":
                ac += 1
            elif S[i] == "B" and T[i] == "C":
                bc += 1
            else:
                print("No")
                exit()
        if bc:
            if ab == bc:
                print("Yes")
            else:
                print("NO")
        else:
            if ab == ac == 0:
                print("Yes")
            else:
                print("No")
    else:
        print("No")
0