結果

問題 No.1894 Delete AB
ユーザー 👑 KazunKazun
提出日時 2022-04-08 21:39:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 402 bytes
コンパイル時間 518 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 95,616 KB
最終ジャッジ日時 2024-05-06 07:11:31
合計ジャッジ時間 2,801 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
51,968 KB
testcase_01 AC 87 ms
75,776 KB
testcase_02 AC 84 ms
75,648 KB
testcase_03 AC 124 ms
77,568 KB
testcase_04 AC 142 ms
78,336 KB
testcase_05 AC 119 ms
77,224 KB
testcase_06 AC 181 ms
78,332 KB
testcase_07 AC 117 ms
77,312 KB
testcase_08 AC 140 ms
78,864 KB
testcase_09 AC 94 ms
76,544 KB
testcase_10 AC 107 ms
77,184 KB
testcase_11 AC 74 ms
75,264 KB
testcase_12 AC 82 ms
75,776 KB
testcase_13 AC 64 ms
77,056 KB
testcase_14 AC 84 ms
95,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T=int(input())
Ans=[""]*T

for t in range(T):
    N=int(input())
    S=input()

    Q=[]
    for x in S:
        Q.append(x)
        while True:
            if len(Q)>=3 and Q[-3]=="A" and Q[-2]=="B" and Q[-1]=="B":
                Q.pop()
                Q.pop()
                Q.pop()
                Q.append("B")
            else:
                break
    Ans[t]="".join(Q)

print(*Ans,sep="\n")
0