結果

問題 No.1894 Delete AB
ユーザー lllllll88938494
提出日時 2023-04-12 07:44:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 158 ms / 2,000 ms
コード長 328 bytes
コンパイル時間 507 ms
コンパイル使用メモリ 82,004 KB
実行使用メモリ 76,928 KB
最終ジャッジ日時 2024-10-08 04:45:23
合計ジャッジ時間 2,796 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
for _ in range(n):
    t = int(input())
    s = input()
    ans = []
    for i in range(t-1,-1,-1):
        ans.append(s[i])
        if len(ans) > 2 and ans[-3] == 'B':
            if ans[-1] == 'A' and ans[-2] == 'B':
                ans.pop()
                ans.pop()
    print(''.join(ans[::-1]))
            
0