結果

問題 No.1894 Delete AB
ユーザー lloyz
提出日時 2022-04-08 23:24:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,538 ms / 2,000 ms
コード長 266 bytes
コンパイル時間 339 ms
コンパイル使用メモリ 82,416 KB
実行使用メモリ 145,832 KB
最終ジャッジ日時 2024-11-28 14:35:30
合計ジャッジ時間 3,793 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())
for _ in range(t):
    n = int(input())
    S = input()
    ANS = ''
    for i in range(n - 1, -1, -1):
        ANS = S[i] + ANS
        if ANS[:2] == "AB":
            if len(ANS) > 2 and ANS[2] == 'B':
                ANS = ANS[2:]
    print(ANS)
0