結果

問題 No.1894 Delete AB
ユーザー ytftytft
提出日時 2022-04-09 04:15:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 303 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 82,792 KB
実行使用メモリ 83,656 KB
最終ジャッジ日時 2024-05-06 15:30:34
合計ジャッジ時間 2,562 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,816 KB
testcase_01 AC 78 ms
75,768 KB
testcase_02 AC 79 ms
75,716 KB
testcase_03 AC 89 ms
76,488 KB
testcase_04 AC 98 ms
76,560 KB
testcase_05 AC 95 ms
75,976 KB
testcase_06 AC 96 ms
76,304 KB
testcase_07 AC 94 ms
76,068 KB
testcase_08 AC 97 ms
76,180 KB
testcase_09 AC 77 ms
75,868 KB
testcase_10 AC 83 ms
75,944 KB
testcase_11 AC 78 ms
75,424 KB
testcase_12 AC 81 ms
75,472 KB
testcase_13 AC 93 ms
83,656 KB
testcase_14 AC 74 ms
75,952 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