結果

問題 No.1894 Delete AB
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-04-08 21:31:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 207 ms / 2,000 ms
コード長 474 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 87,216 KB
実行使用メモリ 96,336 KB
最終ジャッジ日時 2023-08-19 00:11:37
合計ジャッジ時間 2,921 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
71,200 KB
testcase_01 AC 81 ms
77,516 KB
testcase_02 AC 78 ms
77,148 KB
testcase_03 AC 169 ms
79,284 KB
testcase_04 AC 196 ms
80,428 KB
testcase_05 AC 166 ms
79,788 KB
testcase_06 AC 207 ms
80,788 KB
testcase_07 AC 155 ms
79,216 KB
testcase_08 AC 143 ms
77,864 KB
testcase_09 AC 111 ms
77,780 KB
testcase_10 AC 104 ms
78,016 KB
testcase_11 AC 84 ms
77,288 KB
testcase_12 AC 92 ms
77,532 KB
testcase_13 AC 76 ms
84,248 KB
testcase_14 AC 87 ms
96,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())
for _ in range(t):
    n = int(input())
    S = input()
    l = []
    for s in S:
        if s == "A":
            l.append(s)
            continue

        if len(l) < 2:
            l.append(s)
            continue
        # print(l)
        while len(l) >= 2:
            if l[-1] == "B" and l[-2] == "A":
                l.pop()
                l.pop()
            else:
                break
        l.append(s)
    # print("ans")
    print(*l,sep="")
0