結果

問題 No.1894 Delete AB
ユーザー ytftytft
提出日時 2022-04-09 04:15:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 303 bytes
コンパイル時間 555 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 83,880 KB
最終ジャッジ日時 2023-08-19 08:17:00
合計ジャッジ時間 3,239 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,272 KB
testcase_01 AC 110 ms
77,000 KB
testcase_02 AC 112 ms
76,856 KB
testcase_03 AC 118 ms
77,456 KB
testcase_04 AC 124 ms
78,020 KB
testcase_05 AC 122 ms
78,144 KB
testcase_06 AC 123 ms
77,496 KB
testcase_07 AC 124 ms
78,028 KB
testcase_08 AC 129 ms
77,928 KB
testcase_09 AC 107 ms
76,940 KB
testcase_10 AC 116 ms
77,280 KB
testcase_11 AC 109 ms
76,604 KB
testcase_12 AC 109 ms
76,600 KB
testcase_13 AC 123 ms
83,880 KB
testcase_14 AC 100 ms
76,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda:sys.stdin.readline().rstrip()
def solve():
	N=int(input())
	S=input()
	ans=['A']
	for i in range(N-1,-1,-1):
		ans.append(S[i])
		if len(ans)>2 and ans[-3:]==['B','B','A']:
			ans.pop()
			ans.pop()
	print(''.join(ans[len(ans)-1:0:-1]))
T=int(input())
for i in range(T):
	solve()
0