結果

問題 No.1894 Delete AB
ユーザー KudeKude
提出日時 2022-04-08 21:28:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 186 ms / 2,000 ms
コード長 278 bytes
コンパイル時間 338 ms
コンパイル使用メモリ 87,036 KB
実行使用メモリ 83,380 KB
最終ジャッジ日時 2023-08-19 00:09:23
合計ジャッジ時間 2,910 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
71,424 KB
testcase_01 AC 80 ms
77,504 KB
testcase_02 AC 73 ms
76,888 KB
testcase_03 AC 163 ms
78,888 KB
testcase_04 AC 171 ms
78,464 KB
testcase_05 AC 167 ms
77,988 KB
testcase_06 AC 186 ms
78,220 KB
testcase_07 AC 138 ms
78,548 KB
testcase_08 AC 144 ms
78,616 KB
testcase_09 AC 106 ms
78,292 KB
testcase_10 AC 103 ms
78,344 KB
testcase_11 AC 86 ms
77,128 KB
testcase_12 AC 86 ms
77,452 KB
testcase_13 AC 77 ms
83,380 KB
testcase_14 AC 72 ms
76,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

for _ in range(int(input())):
    n = int(input())
    s = input()
    st = []
    for c in reversed(s):
        if len(st) >= 2 and c == 'A' and st[-1] == 'B' and st[-2] == 'B':
            st.pop()
        else:
            st.append(c)
    st.reverse()
    print(*st, sep='')
0