結果

問題 No.1894 Delete AB
ユーザー ShirotsumeShirotsume
提出日時 2022-02-24 14:28:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 248 ms / 2,000 ms
コード長 371 bytes
コンパイル時間 611 ms
コンパイル使用メモリ 86,972 KB
実行使用メモリ 83,556 KB
最終ジャッジ日時 2023-09-20 06:19:46
合計ジャッジ時間 4,083 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
71,732 KB
testcase_01 AC 148 ms
77,696 KB
testcase_02 AC 127 ms
77,244 KB
testcase_03 AC 208 ms
79,216 KB
testcase_04 AC 248 ms
80,348 KB
testcase_05 AC 210 ms
78,920 KB
testcase_06 AC 244 ms
79,724 KB
testcase_07 AC 217 ms
79,588 KB
testcase_08 AC 213 ms
79,392 KB
testcase_09 AC 171 ms
78,576 KB
testcase_10 AC 172 ms
78,384 KB
testcase_11 AC 136 ms
77,668 KB
testcase_12 AC 134 ms
77,752 KB
testcase_13 AC 137 ms
83,556 KB
testcase_14 AC 116 ms
77,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

def solve(n, s):
    q = deque()
    for i in range(n - 1, -1, -1):
        q.appendleft(s[i])
        if len(q) >= 3:
            if q[0] + q[1] == 'AB' and q[2] == 'B':
                q.popleft()
                q.popleft()
    return ''.join(q)


for _ in range(int(input())):
    n = int(input())
    s = input()
    print(solve(n, s))
0