結果
| 問題 | 
                            No.1894 Delete AB
                             | 
                    
| コンテスト | |
| ユーザー | 
                             ytft
                         | 
                    
| 提出日時 | 2022-04-09 04:15:50 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 85 ms / 2,000 ms | 
| コード長 | 303 bytes | 
| コンパイル時間 | 266 ms | 
| コンパイル使用メモリ | 82,300 KB | 
| 実行使用メモリ | 83,632 KB | 
| 最終ジャッジ日時 | 2024-11-28 23:08:32 | 
| 合計ジャッジ時間 | 1,939 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 14 | 
ソースコード
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()
            
            
            
        
            
ytft