結果

問題 No.1894 Delete AB
ユーザー mkawa2mkawa2
提出日時 2023-02-20 12:31:44
言語 PyPy3
(7.3.15)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,010 bytes
コンパイル時間 729 ms
コンパイル使用メモリ 86,992 KB
実行使用メモリ 91,568 KB
最終ジャッジ日時 2023-09-28 11:29:38
合計ジャッジ時間 4,516 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,300 KB
testcase_01 AC 82 ms
76,380 KB
testcase_02 AC 81 ms
76,300 KB
testcase_03 AC 120 ms
77,724 KB
testcase_04 AC 120 ms
77,716 KB
testcase_05 RE -
testcase_06 AC 122 ms
78,524 KB
testcase_07 AC 120 ms
78,168 KB
testcase_08 AC 126 ms
78,084 KB
testcase_09 AC 103 ms
77,300 KB
testcase_10 AC 95 ms
77,196 KB
testcase_11 AC 83 ms
76,688 KB
testcase_12 AC 92 ms
76,752 KB
testcase_13 AC 84 ms
83,860 KB
testcase_14 AC 88 ms
91,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
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
# inf = (1 << 31)-1
# md = 10**9+7
md = 998244353

def solve():
    n = II()
    s = SI()
    ans = []
    for i in range(n):
        while s[i] == "B" and len(ans) > 1 and ans[-2] == "A" and ans[-1] == "B":
            ans.pop()
            ans.pop()
        ans.append(s[i])
    print("".join(ans))

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