結果

問題 No.1894 Delete AB
ユーザー 👑 rin204
提出日時 2022-04-08 21:59:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 176 ms / 2,000 ms
コード長 316 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 77,792 KB
最終ジャッジ日時 2024-11-28 12:40:31
合計ジャッジ時間 2,782 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    n = int(input())
    S = input()
    T = []
    for s in S[::-1]:
        if s == "B":
            T.append(s)
        elif len(T) >= 2 and T[-1] == "B" and T[-2] == "B":
            T.pop()
        else:
            T.append(s)
    print(*T[::-1], sep="")

for _ in range(int(input())):
    solve()
0