結果
| 問題 |
No.1894 Delete AB
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-04-08 23:13:25 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 96 ms / 2,000 ms |
| コード長 | 716 bytes |
| コンパイル時間 | 408 ms |
| コンパイル使用メモリ | 82,540 KB |
| 実行使用メモリ | 78,932 KB |
| 最終ジャッジ日時 | 2024-11-28 14:22:41 |
| 合計ジャッジ時間 | 2,384 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 14 |
ソースコード
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))