結果

問題 No.1894 Delete AB
ユーザー tassei903tassei903
提出日時 2022-04-08 21:48:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 646 bytes
コンパイル時間 231 ms
コンパイル使用メモリ 87,124 KB
実行使用メモリ 90,256 KB
最終ジャッジ日時 2023-08-19 00:25:33
合計ジャッジ時間 2,732 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,144 KB
testcase_01 AC 98 ms
77,268 KB
testcase_02 AC 100 ms
77,408 KB
testcase_03 AC 104 ms
78,144 KB
testcase_04 AC 120 ms
78,032 KB
testcase_05 AC 106 ms
77,624 KB
testcase_06 AC 133 ms
78,692 KB
testcase_07 AC 102 ms
77,464 KB
testcase_08 AC 113 ms
77,420 KB
testcase_09 AC 101 ms
77,312 KB
testcase_10 AC 125 ms
77,572 KB
testcase_11 AC 94 ms
76,752 KB
testcase_12 AC 104 ms
77,372 KB
testcase_13 AC 104 ms
84,912 KB
testcase_14 AC 114 ms
90,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################
t = ni()
for _ in range(t):
    n = ni()
    s = input()
    p = []
    for i in range(n):
        p.append(s[i])
        while len(p)>=3 and p[-3:] == ["A","B","B"]:
            p.pop()
            p.pop()
            p.pop()
            p.append("B")
        #print(p)
    print("".join(p))
0