結果

問題 No.1894 Delete AB
ユーザー titiatitia
提出日時 2022-04-08 21:29:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 321 bytes
コンパイル時間 316 ms
コンパイル使用メモリ 10,556 KB
実行使用メモリ 9,500 KB
最終ジャッジ日時 2023-08-19 00:10:31
合計ジャッジ時間 1,943 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
7,784 KB
testcase_01 AC 54 ms
8,500 KB
testcase_02 AC 54 ms
8,592 KB
testcase_03 AC 49 ms
7,836 KB
testcase_04 AC 57 ms
7,848 KB
testcase_05 AC 56 ms
7,848 KB
testcase_06 AC 57 ms
7,848 KB
testcase_07 AC 56 ms
7,784 KB
testcase_08 AC 64 ms
7,784 KB
testcase_09 AC 38 ms
7,956 KB
testcase_10 AC 45 ms
7,956 KB
testcase_11 AC 42 ms
8,276 KB
testcase_12 AC 44 ms
8,172 KB
testcase_13 AC 53 ms
9,500 KB
testcase_14 AC 51 ms
8,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

T=int(input())
for tests in range(T):
    N=int(input())
    S=input().strip()

    T=[]

    for s in S[::-1]:
        if s=="A" and len(T)>=2 and T[-1]=="B" and T[-2]=="B":
            T.pop()
            continue
        else:
            T.append(s)
    print("".join(T[::-1]))
0