結果
| 問題 | No.1894 Delete AB |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-04-08 22:22:19 |
| 言語 | PyPy3 (7.3.23 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 91 ms / 2,000 ms |
| + 596µs | |
| コード長 | 499 bytes |
| 記録 | |
| コンパイル時間 | 63 ms |
| コンパイル使用メモリ | 81,468 KB |
| 実行使用メモリ | 84,572 KB |
| 最終ジャッジ日時 | 2026-10-01 10:13:09 |
| 合計ジャッジ時間 | 2,674 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 14 |
ソースコード
T = int(input())
for _ in range(T):
N = int(input())
S = list(input())
ans = [S[-1]]
B_count = 0
if S[-1]=="B":
B_count+=1
for i in range(-2,-(N+1),-1):
if S[i] == "B":
B_count+=1
ans.append("B")
else:
if B_count>=2 and ans[-1]=="B":
ans.pop()
B_count-=1
else:
B_count = 0
ans.append("A")
print("".join(reversed(ans)))