結果
問題 | No.1894 Delete AB |
ユーザー | persimmon-persimmon |
提出日時 | 2022-04-14 10:47:31 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 162 ms / 2,000 ms |
コード長 | 493 bytes |
コンパイル時間 | 122 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 13,540 KB |
最終ジャッジ日時 | 2024-12-24 05:54:24 |
合計ジャッジ時間 | 3,141 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 14 |
ソースコード
t=int(input()) ns=[] for _ in range(t): n=int(input()) s=input() ns.append([n,s]) for n,s in ns: # Bの前にあるABは全て消す if n<=2: print(s) continue ans=[] s=list(s) i=0 ans.append(s.pop()) ans.append(s.pop()) while s: if len(ans)>=2 and ans[-1]=="B" and ans[-2]=="B" and s[-1]=="A": s.pop() ans.pop() else: ans.append(s.pop()) ans.reverse() print("".join(ans))