結果

問題 No.1894 Delete AB
ユーザー manta1130manta1130
提出日時 2022-04-15 17:33:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 521 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 10,648 KB
実行使用メモリ 10,696 KB
最終ジャッジ日時 2023-08-26 06:24:13
合計ジャッジ時間 2,337 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,692 KB
testcase_01 AC 44 ms
9,712 KB
testcase_02 AC 47 ms
9,712 KB
testcase_03 AC 101 ms
7,900 KB
testcase_04 AC 104 ms
7,764 KB
testcase_05 AC 106 ms
7,776 KB
testcase_06 AC 110 ms
7,916 KB
testcase_07 AC 107 ms
7,816 KB
testcase_08 AC 111 ms
7,724 KB
testcase_09 AC 36 ms
7,692 KB
testcase_10 AC 41 ms
7,844 KB
testcase_11 AC 36 ms
8,104 KB
testcase_12 AC 36 ms
8,216 KB
testcase_13 AC 42 ms
10,696 KB
testcase_14 AC 42 ms
9,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    n = int(input())
    s = list(input())

    stack = ['P', 'P']
    for idx in reversed(range(n)):
        if s[idx] == 'B':
            stack.append(s[idx])
        else:
            if stack[-1] != 'B':
                stack.append(s[idx])
            elif stack[-2] == 'B':
                del stack[-1]
            else:
                stack.append(s[idx])
        # print(stack)
    stack = stack[::-1]
    del(stack[-2:])
    print(''.join(stack))


t = int(input())
for i in range(t):
    solve()
0