結果

問題 No.2629 A replace B replace C
ユーザー 👑 tipstar0125tipstar0125
提出日時 2024-02-19 16:52:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 492 bytes
コンパイル時間 333 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 94,604 KB
最終ジャッジ日時 2024-02-19 16:52:46
合計ジャッジ時間 7,307 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
94,604 KB
testcase_01 AC 52 ms
72,932 KB
testcase_02 AC 53 ms
72,716 KB
testcase_03 AC 58 ms
79,096 KB
testcase_04 AC 46 ms
66,900 KB
testcase_05 AC 49 ms
70,444 KB
testcase_06 AC 43 ms
67,836 KB
testcase_07 AC 53 ms
72,664 KB
testcase_08 AC 82 ms
84,376 KB
testcase_09 AC 84 ms
87,596 KB
testcase_10 AC 55 ms
75,532 KB
testcase_11 AC 95 ms
87,668 KB
testcase_12 AC 64 ms
77,204 KB
testcase_13 AC 54 ms
72,312 KB
testcase_14 AC 84 ms
87,448 KB
testcase_15 AC 55 ms
75,836 KB
testcase_16 AC 52 ms
72,568 KB
testcase_17 AC 52 ms
73,256 KB
testcase_18 AC 53 ms
75,672 KB
testcase_19 AC 49 ms
70,128 KB
testcase_20 AC 52 ms
72,472 KB
testcase_21 AC 82 ms
87,136 KB
testcase_22 AC 73 ms
81,928 KB
testcase_23 AC 85 ms
87,284 KB
testcase_24 AC 93 ms
85,108 KB
testcase_25 AC 78 ms
84,488 KB
testcase_26 AC 70 ms
82,588 KB
testcase_27 AC 82 ms
81,056 KB
testcase_28 AC 79 ms
86,904 KB
testcase_29 AC 66 ms
81,848 KB
testcase_30 AC 62 ms
75,376 KB
testcase_31 AC 45 ms
67,508 KB
testcase_32 AC 45 ms
67,400 KB
testcase_33 AC 47 ms
71,324 KB
testcase_34 AC 41 ms
64,720 KB
testcase_35 AC 45 ms
67,116 KB
testcase_36 AC 46 ms
70,648 KB
testcase_37 AC 47 ms
69,912 KB
testcase_38 AC 45 ms
67,828 KB
testcase_39 AC 45 ms
64,828 KB
testcase_40 AC 45 ms
67,544 KB
testcase_41 AC 71 ms
81,888 KB
testcase_42 AC 79 ms
86,080 KB
testcase_43 AC 77 ms
84,492 KB
testcase_44 AC 100 ms
84,712 KB
testcase_45 AC 83 ms
87,272 KB
testcase_46 AC 82 ms
89,772 KB
testcase_47 AC 75 ms
85,272 KB
testcase_48 AC 76 ms
83,280 KB
testcase_49 AC 56 ms
74,836 KB
testcase_50 AC 81 ms
86,684 KB
testcase_51 AC 75 ms
83,684 KB
testcase_52 AC 50 ms
73,036 KB
testcase_53 AC 44 ms
65,008 KB
testcase_54 AC 50 ms
67,660 KB
testcase_55 AC 47 ms
67,704 KB
testcase_56 AC 45 ms
64,808 KB
testcase_57 AC 79 ms
84,876 KB
testcase_58 AC 54 ms
67,736 KB
testcase_59 AC 92 ms
87,756 KB
testcase_60 AC 51 ms
70,296 KB
testcase_61 AC 41 ms
53,332 KB
testcase_62 AC 43 ms
53,332 KB
testcase_63 AC 38 ms
53,332 KB
testcase_64 AC 39 ms
53,332 KB
testcase_65 AC 38 ms
53,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
N=int(input())
S=list(input())
T=list(input())
QA=deque()
QB=[]
for i in range(N):
    if S[i]>T[i]:
        print("No")
        exit(0)
    if S[i]<T[i]:
        if S[i]=="A":
            if T[i]=="B":QA.appendleft(i)
            else:QA.append(i)
        elif S[i]=="B":QB.append(i)

while len(QA)*len(QB):
    a_idx=QA.pop()
    b_idx=QB.pop()
    S[a_idx]="B"
    S[b_idx]="C"
    if S[a_idx]!=T[a_idx]:QB.append(a_idx)

if S==T:print("Yes")
else:print("No")
0