結果

問題 No.1894 Delete AB
ユーザー ikomaikoma
提出日時 2022-04-08 21:45:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 391 bytes
コンパイル時間 331 ms
コンパイル使用メモリ 87,300 KB
実行使用メモリ 96,200 KB
最終ジャッジ日時 2023-08-19 00:23:22
合計ジャッジ時間 2,499 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
71,228 KB
testcase_01 AC 73 ms
77,076 KB
testcase_02 AC 74 ms
77,424 KB
testcase_03 AC 96 ms
77,620 KB
testcase_04 AC 111 ms
77,820 KB
testcase_05 AC 97 ms
78,096 KB
testcase_06 AC 112 ms
77,992 KB
testcase_07 AC 99 ms
77,976 KB
testcase_08 AC 89 ms
77,524 KB
testcase_09 AC 88 ms
77,548 KB
testcase_10 AC 85 ms
77,544 KB
testcase_11 AC 75 ms
76,532 KB
testcase_12 AC 85 ms
77,216 KB
testcase_13 AC 74 ms
84,168 KB
testcase_14 AC 87 ms
96,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

T=int(input())
for t in range(T):
    N=int(input())
    S=input().strip()
    stack = []
    for s in S:
        if s=="B":
            while len(stack)>=2:
                if stack[-2]=="A" and stack[-1]=="B":
                    stack.pop()
                    stack.pop()
                else:break
        stack.append(s)
    print("".join(stack))
0