結果

問題 No.1894 Delete AB
ユーザー taiga0629kyoprotaiga0629kyopro
提出日時 2022-04-08 22:23:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 143 ms / 2,000 ms
コード長 302 bytes
コンパイル時間 363 ms
コンパイル使用メモリ 82,568 KB
実行使用メモリ 82,560 KB
最終ジャッジ日時 2024-11-28 13:05:46
合計ジャッジ時間 2,202 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #



T=int(input())
for _ in range(T):
    n=int(input())
    s=list(input())
    s.reverse()
    ans=[]
    for x in s:
        ans.append(x)
        if len(ans)>=3 and ans[-1]=="A" and ans[-2]=="B" and ans[-3]=="B":
            ans.pop()
            ans.pop()
    ans.reverse()
    print("".join(ans))
0