結果

問題 No.1894 Delete AB
ユーザー KudeKude
提出日時 2022-04-08 21:28:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 278 bytes
コンパイル時間 253 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 77,440 KB
最終ジャッジ日時 2024-05-06 07:02:59
合計ジャッジ時間 2,338 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
51,712 KB
testcase_01 AC 69 ms
76,288 KB
testcase_02 AC 58 ms
72,960 KB
testcase_03 AC 162 ms
77,440 KB
testcase_04 AC 167 ms
76,940 KB
testcase_05 AC 135 ms
76,816 KB
testcase_06 AC 170 ms
77,188 KB
testcase_07 AC 126 ms
76,416 KB
testcase_08 AC 158 ms
77,056 KB
testcase_09 AC 103 ms
77,056 KB
testcase_10 AC 105 ms
76,672 KB
testcase_11 AC 74 ms
75,648 KB
testcase_12 AC 71 ms
76,160 KB
testcase_13 AC 59 ms
74,624 KB
testcase_14 AC 52 ms
71,936 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