結果
| 問題 | No.1894 Delete AB |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-04-08 23:26:41 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 134 ms / 2,000 ms |
| コード長 | 378 bytes |
| 記録 | |
| コンパイル時間 | 227 ms |
| コンパイル使用メモリ | 85,248 KB |
| 実行使用メモリ | 85,760 KB |
| 最終ジャッジ日時 | 2026-05-22 14:26:24 |
| 合計ジャッジ時間 | 2,600 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 14 |
ソースコード
from collections import deque
t = int(input())
for _ in range(t):
n = int(input())
S = input()
ANS = deque()
for i in range(n - 1, -1, -1):
ANS.appendleft(S[i])
if len(ANS) > 1 and ANS[0] == 'A' and ANS[1] == 'B':
if len(ANS) > 2 and ANS[2] == 'B':
ANS.popleft()
ANS.popleft()
print(''.join(ANS))