結果

問題 No.1894 Delete AB
ユーザー ShirotsumeShirotsume
提出日時 2022-02-27 10:18:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 165 ms / 2,000 ms
コード長 371 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 11,744 KB
最終ジャッジ日時 2024-05-02 00:58:23
合計ジャッジ時間 2,553 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,752 KB
testcase_01 AC 97 ms
11,136 KB
testcase_02 AC 96 ms
11,264 KB
testcase_03 AC 152 ms
10,752 KB
testcase_04 AC 158 ms
10,624 KB
testcase_05 AC 154 ms
10,752 KB
testcase_06 AC 158 ms
10,752 KB
testcase_07 AC 161 ms
10,752 KB
testcase_08 AC 165 ms
10,752 KB
testcase_09 AC 71 ms
10,752 KB
testcase_10 AC 82 ms
10,752 KB
testcase_11 AC 79 ms
10,752 KB
testcase_12 AC 81 ms
10,752 KB
testcase_13 AC 99 ms
11,744 KB
testcase_14 AC 77 ms
11,136 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