結果

問題 No.1894 Delete AB
ユーザー lllllll88938494lllllll88938494
提出日時 2023-04-12 07:44:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 328 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 76,680 KB
最終ジャッジ日時 2024-04-16 22:42:39
合計ジャッジ時間 2,506 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
51,968 KB
testcase_01 AC 56 ms
68,224 KB
testcase_02 AC 50 ms
66,816 KB
testcase_03 AC 122 ms
76,300 KB
testcase_04 AC 150 ms
76,680 KB
testcase_05 AC 112 ms
76,328 KB
testcase_06 AC 160 ms
76,544 KB
testcase_07 AC 118 ms
76,420 KB
testcase_08 AC 129 ms
76,544 KB
testcase_09 AC 82 ms
75,904 KB
testcase_10 AC 82 ms
76,516 KB
testcase_11 AC 60 ms
69,248 KB
testcase_12 AC 60 ms
69,376 KB
testcase_13 AC 58 ms
76,160 KB
testcase_14 AC 48 ms
67,072 KB
権限があれば一括ダウンロードができます

ソースコード

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