結果

問題 No.2629 A replace B replace C
ユーザー ikomaikoma
提出日時 2024-02-16 21:47:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 538 bytes
コンパイル時間 366 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 84,788 KB
最終ジャッジ日時 2024-02-16 21:48:10
合計ジャッジ時間 6,890 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
74,012 KB
testcase_01 AC 64 ms
75,548 KB
testcase_02 AC 57 ms
74,452 KB
testcase_03 AC 72 ms
81,680 KB
testcase_04 AC 49 ms
65,972 KB
testcase_05 AC 54 ms
71,052 KB
testcase_06 AC 64 ms
67,868 KB
testcase_07 AC 56 ms
73,704 KB
testcase_08 AC 58 ms
74,576 KB
testcase_09 AC 69 ms
81,544 KB
testcase_10 AC 69 ms
80,908 KB
testcase_11 AC 72 ms
82,448 KB
testcase_12 AC 73 ms
82,704 KB
testcase_13 AC 56 ms
73,844 KB
testcase_14 AC 70 ms
81,552 KB
testcase_15 AC 71 ms
81,552 KB
testcase_16 AC 58 ms
74,456 KB
testcase_17 AC 58 ms
74,424 KB
testcase_18 AC 57 ms
74,140 KB
testcase_19 AC 53 ms
68,132 KB
testcase_20 AC 55 ms
70,804 KB
testcase_21 AC 70 ms
80,072 KB
testcase_22 AC 74 ms
75,040 KB
testcase_23 AC 91 ms
80,056 KB
testcase_24 AC 59 ms
75,228 KB
testcase_25 AC 58 ms
75,400 KB
testcase_26 AC 55 ms
73,112 KB
testcase_27 AC 56 ms
73,704 KB
testcase_28 AC 69 ms
80,208 KB
testcase_29 AC 51 ms
67,868 KB
testcase_30 AC 53 ms
69,000 KB
testcase_31 AC 75 ms
84,788 KB
testcase_32 AC 72 ms
82,560 KB
testcase_33 AC 75 ms
83,584 KB
testcase_34 AC 69 ms
81,536 KB
testcase_35 AC 71 ms
81,680 KB
testcase_36 AC 78 ms
83,624 KB
testcase_37 AC 79 ms
84,352 KB
testcase_38 AC 72 ms
82,124 KB
testcase_39 AC 59 ms
74,332 KB
testcase_40 AC 70 ms
80,832 KB
testcase_41 AC 56 ms
73,392 KB
testcase_42 AC 60 ms
77,056 KB
testcase_43 AC 60 ms
76,044 KB
testcase_44 AC 57 ms
73,688 KB
testcase_45 AC 71 ms
81,544 KB
testcase_46 AC 70 ms
80,508 KB
testcase_47 AC 57 ms
73,812 KB
testcase_48 AC 56 ms
73,844 KB
testcase_49 AC 52 ms
70,400 KB
testcase_50 AC 70 ms
81,680 KB
testcase_51 AC 60 ms
75,672 KB
testcase_52 AC 59 ms
73,112 KB
testcase_53 AC 48 ms
65,824 KB
testcase_54 AC 52 ms
68,004 KB
testcase_55 AC 51 ms
67,868 KB
testcase_56 AC 50 ms
65,820 KB
testcase_57 AC 60 ms
76,812 KB
testcase_58 AC 53 ms
68,296 KB
testcase_59 AC 70 ms
80,052 KB
testcase_60 AC 55 ms
71,048 KB
testcase_61 AC 42 ms
53,460 KB
testcase_62 AC 48 ms
53,460 KB
testcase_63 AC 42 ms
53,460 KB
testcase_64 AC 40 ms
53,460 KB
testcase_65 AC 40 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import defaultdict,deque,Counter

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

cnt = Counter([s+t for s,t in zip(S,T) if s!=t])
def solve(cnt):
    # (B,A) (C,A) があったらNo
    if "BA" in cnt or "CA" in cnt or "CB" in cnt:
        return False
    # (A,C), (B,C) -> (B,C),(C,C)
    if cnt["AC"]>0 and cnt["BC"]==0:
        return False
    n = cnt["AC"]
    cnt[""]
    # (A,B),(B,C) -> (B,B),(C,C)
    return cnt["AB"]==cnt["BC"]

print("Yes" if solve(cnt) else "No")
0