結果
| 問題 |
No.1894 Delete AB
|
| コンテスト | |
| ユーザー |
H20
|
| 提出日時 | 2022-04-08 21:54:06 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 146 ms / 2,000 ms |
| コード長 | 458 bytes |
| コンパイル時間 | 328 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 87,552 KB |
| 最終ジャッジ日時 | 2024-11-28 12:35:17 |
| 合計ジャッジ時間 | 2,272 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 14 |
ソースコード
import collections
T = int(input())
for _ in range(T):
N=int(input())
S = list(input())
d = collections.deque()
d.append('x')
d.append('x')
bcnt = 0
for s in S[::-1]:
d.append(s)
if d[-1]=='B' and d[-2]=='B':
bcnt+=1
while d[-1]=='A' and d[-2]=='B' and bcnt>=1:
d.pop()
d.pop()
bcnt-=1
ANS = list(d)[::-1]
print(''.join(map(str, ANS[:len(ANS)-2])))
H20