結果

問題 No.1894 Delete AB
ユーザー 👑 rin204rin204
提出日時 2023-05-22 06:59:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 197 ms / 2,000 ms
コード長 293 bytes
コンパイル時間 324 ms
コンパイル使用メモリ 82,520 KB
実行使用メモリ 78,092 KB
最終ジャッジ日時 2024-12-22 02:54:47
合計ジャッジ時間 3,290 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

for _ in range(int(input())):
    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="")


0