結果

問題 No.1894 Delete AB
ユーザー lloyzlloyz
提出日時 2022-04-08 23:26:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 165 ms / 2,000 ms
コード長 378 bytes
コンパイル時間 366 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 82,688 KB
最終ジャッジ日時 2024-05-06 09:10:21
合計ジャッジ時間 2,855 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
53,376 KB
testcase_01 AC 83 ms
76,672 KB
testcase_02 AC 70 ms
76,100 KB
testcase_03 AC 142 ms
77,440 KB
testcase_04 AC 136 ms
77,116 KB
testcase_05 AC 125 ms
76,800 KB
testcase_06 AC 165 ms
77,612 KB
testcase_07 AC 126 ms
76,672 KB
testcase_08 AC 137 ms
77,180 KB
testcase_09 AC 114 ms
77,312 KB
testcase_10 AC 98 ms
77,388 KB
testcase_11 AC 91 ms
76,160 KB
testcase_12 AC 78 ms
76,160 KB
testcase_13 AC 91 ms
82,688 KB
testcase_14 AC 64 ms
75,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

t = int(input())
for _ in range(t):
    n = int(input())
    S = input()
    ANS = deque()
    for i in range(n - 1, -1, -1):
        ANS.appendleft(S[i])
        if len(ANS) > 1 and ANS[0] == 'A' and ANS[1] == 'B':
            if len(ANS) > 2 and ANS[2] == 'B':
                ANS.popleft()
                ANS.popleft()
    print(''.join(ANS))
0