結果

問題 No.1894 Delete AB
ユーザー rlangevinrlangevin
提出日時 2023-01-18 01:31:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 194 ms / 2,000 ms
コード長 398 bytes
コンパイル時間 375 ms
コンパイル使用メモリ 87,216 KB
実行使用メモリ 86,512 KB
最終ジャッジ日時 2023-09-01 22:53:49
合計ジャッジ時間 4,025 ms
ジャッジサーバーID
(参考情報)
judge14 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,680 KB
testcase_01 AC 103 ms
86,260 KB
testcase_02 AC 96 ms
79,372 KB
testcase_03 AC 159 ms
78,656 KB
testcase_04 AC 175 ms
78,196 KB
testcase_05 AC 140 ms
77,860 KB
testcase_06 AC 194 ms
78,108 KB
testcase_07 AC 154 ms
77,472 KB
testcase_08 AC 150 ms
77,564 KB
testcase_09 AC 114 ms
77,652 KB
testcase_10 AC 113 ms
77,676 KB
testcase_11 AC 99 ms
76,856 KB
testcase_12 AC 98 ms
78,980 KB
testcase_13 AC 98 ms
86,512 KB
testcase_14 AC 91 ms
79,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
for _ in range(T):
    N = int(input())
    S = list(input())
    stack = ["$", "$"]
    S.reverse()
    for s in S:
        if s == "B":
            stack.append(s)
        else:
            if stack[-1] == stack[-2] == "B":
                stack.pop()
            else:
                stack.append(s)
    stack.reverse()
    stack.pop()
    stack.pop()
    print("".join(stack))
0