結果

問題 No.1894 Delete AB
ユーザー 👑 rin204rin204
提出日時 2023-05-22 06:59:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 293 bytes
コンパイル時間 206 ms
コンパイル使用メモリ 82,404 KB
実行使用メモリ 77,576 KB
最終ジャッジ日時 2024-06-01 16:34:31
合計ジャッジ時間 2,806 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,640 KB
testcase_01 AC 66 ms
76,680 KB
testcase_02 AC 55 ms
73,984 KB
testcase_03 AC 156 ms
77,576 KB
testcase_04 AC 179 ms
77,516 KB
testcase_05 AC 139 ms
76,552 KB
testcase_06 AC 169 ms
77,040 KB
testcase_07 AC 129 ms
76,556 KB
testcase_08 AC 140 ms
77,236 KB
testcase_09 AC 95 ms
77,108 KB
testcase_10 AC 93 ms
76,704 KB
testcase_11 AC 70 ms
76,056 KB
testcase_12 AC 68 ms
76,436 KB
testcase_13 AC 59 ms
76,044 KB
testcase_14 AC 52 ms
73,000 KB
権限があれば一括ダウンロードができます

ソースコード

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