結果
| 問題 |
No.1894 Delete AB
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-04-08 23:12:19 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 594 bytes |
| コンパイル時間 | 391 ms |
| コンパイル使用メモリ | 82,404 KB |
| 実行使用メモリ | 269,040 KB |
| 最終ジャッジ日時 | 2024-11-28 14:21:11 |
| 合計ジャッジ時間 | 10,199 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 1 WA * 12 TLE * 1 |
ソースコード
t = int(input())
for _ in range(t):
n = int(input())
S = input()
ANS = ''
res = 0
for i in range(n):
s = S[i]
if s == 'A':
ANS += s
elif s == 'B' and len(ANS) > 0 and ANS[-1] == 'A':
if i < n - 1 and S[i + 1] > ANS[-1]:
ANS = ANS[:-1]
else:
ANS += s
else:
ANS += s
res = 0
for i in range(0, len(ANS), 2):
if ANS[i:i + 2] == 'AB':
res += 2
else:
break
if len(ANS) != res:
ANS = ANS[res:]
print(ANS)