結果

問題 No.1894 Delete AB
ユーザー mkawa2mkawa2
提出日時 2023-07-12 15:39:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 156 ms / 2,000 ms
コード長 983 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 87,184 KB
実行使用メモリ 91,616 KB
最終ジャッジ日時 2023-10-12 05:55:38
合計ジャッジ時間 3,743 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,292 KB
testcase_01 AC 103 ms
77,916 KB
testcase_02 AC 93 ms
76,536 KB
testcase_03 AC 156 ms
78,964 KB
testcase_04 AC 143 ms
78,944 KB
testcase_05 AC 146 ms
78,916 KB
testcase_06 AC 151 ms
78,844 KB
testcase_07 AC 156 ms
78,932 KB
testcase_08 AC 155 ms
79,092 KB
testcase_09 AC 126 ms
78,164 KB
testcase_10 AC 124 ms
77,968 KB
testcase_11 AC 107 ms
77,784 KB
testcase_12 AC 115 ms
77,676 KB
testcase_13 AC 93 ms
84,108 KB
testcase_14 AC 95 ms
91,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(200005)
# sys.set_int_max_str_digits(1000005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
md = 10**9+7
# md = 998244353

def solve():
    SI()
    ans=[]
    for c in SI():
        while c=="B" and len(ans)>1 and ans[-2]=="A" and ans[-1]=="B":
            ans.pop()
            ans.pop()
        ans.append(c)
    print(*ans,sep="")

for _ in range(II()):solve()
0