結果

問題 No.1894 Delete AB
ユーザー ShirotsumeShirotsume
提出日時 2022-04-08 02:13:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 464 bytes
コンパイル時間 142 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 83,072 KB
最終ジャッジ日時 2024-05-06 01:04:04
合計ジャッジ時間 2,008 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,096 KB
testcase_01 AC 60 ms
73,472 KB
testcase_02 AC 56 ms
72,576 KB
testcase_03 AC 85 ms
76,160 KB
testcase_04 AC 120 ms
76,928 KB
testcase_05 AC 88 ms
76,032 KB
testcase_06 AC 117 ms
76,416 KB
testcase_07 AC 91 ms
76,032 KB
testcase_08 AC 91 ms
76,032 KB
testcase_09 AC 73 ms
75,904 KB
testcase_10 AC 73 ms
75,648 KB
testcase_11 AC 60 ms
72,704 KB
testcase_12 AC 61 ms
73,344 KB
testcase_13 AC 67 ms
83,072 KB
testcase_14 AC 56 ms
69,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())


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


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