結果
| 問題 | No.1894 Delete AB |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-04-08 21:56:22 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 609 bytes |
| 記録 | |
| コンパイル時間 | 295 ms |
| コンパイル使用メモリ | 85,248 KB |
| 実行使用メモリ | 86,656 KB |
| 最終ジャッジ日時 | 2026-05-22 13:17:27 |
| 合計ジャッジ時間 | 2,157 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 2 WA * 12 |
ソースコード
T = int(input())
for _ in range(T):
N = int(input())
S = list(input())
B_count = 0
ans = [S[-1]]
if S[-1] == "B":
B_count+=1
A_count = 0
for i in range(-2,-(N+1),-1):
if S[i] == "B":
B_count+=1
ans.append("B")
else:
if B_count>A_count+1 and ans[-1]=="B":
ans.pop()
B_count-=1
if B_count == 0:
A_count = 0
else:
ans.append("A")
if B_count >=1:
A_count += 1
print("".join(reversed(ans)))