結果

問題 No.2629 A replace B replace C
ユーザー PNJPNJ
提出日時 2024-02-16 21:31:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 465 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 80,760 KB
最終ジャッジ日時 2024-02-16 21:31:33
合計ジャッジ時間 7,318 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
66,572 KB
testcase_01 AC 92 ms
78,148 KB
testcase_02 AC 88 ms
77,784 KB
testcase_03 AC 115 ms
80,760 KB
testcase_04 AC 63 ms
72,768 KB
testcase_05 AC 77 ms
76,396 KB
testcase_06 AC 59 ms
72,524 KB
testcase_07 AC 87 ms
77,896 KB
testcase_08 AC 83 ms
77,452 KB
testcase_09 AC 90 ms
79,524 KB
testcase_10 AC 97 ms
79,036 KB
testcase_11 AC 109 ms
79,964 KB
testcase_12 AC 108 ms
80,708 KB
testcase_13 AC 83 ms
76,892 KB
testcase_14 AC 90 ms
79,032 KB
testcase_15 AC 93 ms
79,376 KB
testcase_16 AC 88 ms
77,904 KB
testcase_17 AC 95 ms
78,340 KB
testcase_18 AC 75 ms
76,524 KB
testcase_19 AC 72 ms
75,968 KB
testcase_20 AC 74 ms
76,224 KB
testcase_21 AC 84 ms
78,384 KB
testcase_22 AC 72 ms
77,816 KB
testcase_23 AC 90 ms
78,300 KB
testcase_24 AC 84 ms
77,728 KB
testcase_25 AC 79 ms
77,740 KB
testcase_26 AC 68 ms
76,072 KB
testcase_27 AC 77 ms
76,856 KB
testcase_28 AC 79 ms
77,984 KB
testcase_29 AC 58 ms
72,596 KB
testcase_30 AC 71 ms
76,068 KB
testcase_31 AC 95 ms
78,924 KB
testcase_32 AC 74 ms
76,816 KB
testcase_33 AC 80 ms
77,036 KB
testcase_34 AC 73 ms
76,068 KB
testcase_35 AC 82 ms
77,080 KB
testcase_36 AC 84 ms
77,884 KB
testcase_37 AC 92 ms
78,744 KB
testcase_38 AC 84 ms
77,584 KB
testcase_39 AC 58 ms
72,484 KB
testcase_40 AC 80 ms
77,000 KB
testcase_41 AC 76 ms
77,072 KB
testcase_42 AC 102 ms
79,316 KB
testcase_43 AC 95 ms
78,652 KB
testcase_44 AC 89 ms
77,728 KB
testcase_45 AC 91 ms
79,284 KB
testcase_46 AC 100 ms
79,732 KB
testcase_47 AC 87 ms
77,728 KB
testcase_48 AC 78 ms
76,860 KB
testcase_49 AC 56 ms
70,588 KB
testcase_50 AC 103 ms
79,884 KB
testcase_51 AC 87 ms
78,304 KB
testcase_52 AC 50 ms
71,156 KB
testcase_53 AC 42 ms
61,836 KB
testcase_54 AC 47 ms
65,932 KB
testcase_55 AC 46 ms
63,884 KB
testcase_56 AC 44 ms
63,884 KB
testcase_57 AC 92 ms
78,652 KB
testcase_58 AC 47 ms
66,224 KB
testcase_59 AC 85 ms
78,020 KB
testcase_60 AC 50 ms
69,112 KB
testcase_61 AC 37 ms
53,460 KB
testcase_62 AC 37 ms
53,460 KB
testcase_63 AC 35 ms
53,460 KB
testcase_64 AC 38 ms
53,460 KB
testcase_65 AC 38 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = input()
T = input()
ans = 'Yes'
B = []
C = []
for i in range(N):
  if S[i] == T[i]:
    continue
  if T[i] == 'A':
    ans = 'No'
  elif T[i] == 'B':
    if S[i] == 'A':
      B.append((0,i))
    else:
      ans = 'No'
  else:
    if S[i] == 'A':
      B.append((1,i))
    else:
      C.append(i)

B.sort()
while len(B) and len(C):
  f,i = B.pop()
  j = C.pop()
  if f:
    C.append(i)
if len(B):
  ans = 'No'
if len(C):
  ans = 'No'
print(ans)
0