結果
問題 | No.1894 Delete AB |
ユーザー | chineristAC |
提出日時 | 2022-04-08 23:13:25 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 143 ms / 2,000 ms |
コード長 | 716 bytes |
コンパイル時間 | 454 ms |
コンパイル使用メモリ | 87,440 KB |
実行使用メモリ | 86,580 KB |
最終ジャッジ日時 | 2023-08-19 01:49:14 |
合計ジャッジ時間 | 3,161 ms |
ジャッジサーバーID (参考情報) |
judge9 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 91 ms
74,680 KB |
testcase_01 | AC | 114 ms
81,236 KB |
testcase_02 | AC | 105 ms
81,096 KB |
testcase_03 | AC | 125 ms
81,708 KB |
testcase_04 | AC | 137 ms
81,948 KB |
testcase_05 | AC | 123 ms
81,540 KB |
testcase_06 | AC | 143 ms
81,632 KB |
testcase_07 | AC | 128 ms
81,292 KB |
testcase_08 | AC | 127 ms
81,344 KB |
testcase_09 | AC | 119 ms
81,216 KB |
testcase_10 | AC | 116 ms
81,500 KB |
testcase_11 | AC | 111 ms
80,852 KB |
testcase_12 | AC | 112 ms
80,728 KB |
testcase_13 | AC | 110 ms
86,580 KB |
testcase_14 | AC | 104 ms
81,520 KB |
ソースコード
import sys,random,bisect from collections import deque,defaultdict from heapq import heapify,heappop,heappush from itertools import permutations from math import log,gcd input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) for _ in range(int(input())): N = int(input()) S = input() res = [] for s in S[::-1]: if s=="B": res.append(s) else: if res and res[-1]=="B": if len(res) >= 2 and res[-2]=="B": res.pop() else: res.append("A") else: res.append("A") res = res[::-1] print("".join(res))