結果
問題 | No.1894 Delete AB |
ユーザー | SidewaysOwl |
提出日時 | 2022-04-08 21:36:42 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 226 ms / 2,000 ms |
コード長 | 589 bytes |
コンパイル時間 | 542 ms |
コンパイル使用メモリ | 86,240 KB |
実行使用メモリ | 80,336 KB |
最終ジャッジ日時 | 2023-08-19 00:16:44 |
合計ジャッジ時間 | 3,619 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 98 ms
70,940 KB |
testcase_01 | AC | 119 ms
80,336 KB |
testcase_02 | AC | 119 ms
79,960 KB |
testcase_03 | AC | 183 ms
77,724 KB |
testcase_04 | AC | 216 ms
79,876 KB |
testcase_05 | AC | 168 ms
77,596 KB |
testcase_06 | AC | 226 ms
78,196 KB |
testcase_07 | AC | 181 ms
77,636 KB |
testcase_08 | AC | 181 ms
77,772 KB |
testcase_09 | AC | 152 ms
77,756 KB |
testcase_10 | AC | 154 ms
78,060 KB |
testcase_11 | AC | 130 ms
76,888 KB |
testcase_12 | AC | 129 ms
78,276 KB |
testcase_13 | AC | 115 ms
80,208 KB |
testcase_14 | AC | 111 ms
80,096 KB |
ソースコード
from collections import deque for _ in range(int(input())): n = int(input()) s = list(input()) res = deque() for i in range(n-1,-1,-1): if s[i] == "A": if len(res) >= 2: a,b = res.pop(),res.pop() if a == b == "B": res.append("B") else: res.append(b) res.append(a) res.append(s[i]) else: res.append(s[i]) else: res.append(s[i]) res = list(res)[::-1] print("".join(res))