結果

問題 No.2629 A replace B replace C
ユーザー 👑 tipstar0125tipstar0125
提出日時 2024-02-19 16:36:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 557 bytes
コンパイル時間 339 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 94,456 KB
最終ジャッジ日時 2024-02-19 16:37:04
合計ジャッジ時間 6,933 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
94,456 KB
testcase_01 AC 45 ms
72,784 KB
testcase_02 AC 49 ms
70,516 KB
testcase_03 AC 54 ms
77,736 KB
testcase_04 AC 39 ms
64,692 KB
testcase_05 AC 62 ms
68,240 KB
testcase_06 AC 41 ms
65,896 KB
testcase_07 AC 50 ms
71,232 KB
testcase_08 WA -
testcase_09 AC 76 ms
86,944 KB
testcase_10 AC 47 ms
73,328 KB
testcase_11 AC 55 ms
78,560 KB
testcase_12 AC 48 ms
76,304 KB
testcase_13 AC 44 ms
70,112 KB
testcase_14 AC 68 ms
86,168 KB
testcase_15 AC 47 ms
74,272 KB
testcase_16 AC 43 ms
70,356 KB
testcase_17 AC 51 ms
71,040 KB
testcase_18 AC 45 ms
73,472 KB
testcase_19 AC 42 ms
67,928 KB
testcase_20 AC 44 ms
70,400 KB
testcase_21 AC 75 ms
85,708 KB
testcase_22 AC 71 ms
82,552 KB
testcase_23 WA -
testcase_24 AC 69 ms
85,576 KB
testcase_25 AC 69 ms
83,696 KB
testcase_26 WA -
testcase_27 AC 67 ms
81,344 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 52 ms
73,928 KB
testcase_31 AC 40 ms
65,564 KB
testcase_32 AC 38 ms
65,456 KB
testcase_33 AC 41 ms
69,384 KB
testcase_34 AC 41 ms
62,776 KB
testcase_35 AC 39 ms
65,172 KB
testcase_36 AC 41 ms
68,708 KB
testcase_37 AC 41 ms
67,968 KB
testcase_38 AC 43 ms
67,932 KB
testcase_39 AC 39 ms
64,932 KB
testcase_40 AC 38 ms
65,600 KB
testcase_41 AC 59 ms
73,640 KB
testcase_42 AC 55 ms
77,884 KB
testcase_43 AC 55 ms
77,460 KB
testcase_44 AC 53 ms
76,888 KB
testcase_45 AC 68 ms
88,040 KB
testcase_46 AC 70 ms
91,076 KB
testcase_47 AC 53 ms
76,956 KB
testcase_48 AC 54 ms
75,616 KB
testcase_49 AC 48 ms
72,744 KB
testcase_50 AC 59 ms
79,652 KB
testcase_51 WA -
testcase_52 AC 44 ms
72,112 KB
testcase_53 AC 38 ms
65,208 KB
testcase_54 AC 43 ms
67,656 KB
testcase_55 AC 40 ms
67,892 KB
testcase_56 AC 39 ms
65,004 KB
testcase_57 WA -
testcase_58 AC 43 ms
68,008 KB
testcase_59 AC 80 ms
86,592 KB
testcase_60 AC 43 ms
69,376 KB
testcase_61 AC 32 ms
53,460 KB
testcase_62 AC 32 ms
53,460 KB
testcase_63 AC 31 ms
53,460 KB
testcase_64 AC 33 ms
53,460 KB
testcase_65 AC 33 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
S=list(input())
T=list(input())
QA=[]
QB=[]
num=0
for i in range(N):
    if S[i]>T[i]:
        print("No")
        exit(0)
    if S[i]<T[i]:
        if S[i]=="A":QA.append(i)
        elif S[i]=="B":QB.append(i)
        num+=1

cnt=0
while True:
    if num==cnt and S==T:
        print("Yes")
        exit(0)
    if len(QA)==0 or len(QB)==0:
        print("No")
        exit(0)
    a_idx=QA.pop()
    b_idx=QB.pop()
    S[a_idx]="B"
    S[b_idx]="C"
    if S[a_idx]==T[a_idx]:cnt+=1
    else:QB.append(a_idx)
    if S[b_idx]==T[b_idx]:cnt+=1

0