結果

問題 No.1894 Delete AB
ユーザー googol_S0googol_S0
提出日時 2022-04-08 22:16:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 303 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 77,568 KB
最終ジャッジ日時 2024-05-06 07:46:47
合計ジャッジ時間 2,312 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
51,968 KB
testcase_01 AC 55 ms
68,096 KB
testcase_02 AC 54 ms
66,688 KB
testcase_03 AC 138 ms
77,404 KB
testcase_04 AC 138 ms
77,436 KB
testcase_05 AC 136 ms
77,568 KB
testcase_06 AC 135 ms
77,184 KB
testcase_07 AC 134 ms
77,148 KB
testcase_08 AC 146 ms
76,928 KB
testcase_09 AC 93 ms
76,160 KB
testcase_10 AC 90 ms
76,164 KB
testcase_11 AC 58 ms
68,736 KB
testcase_12 AC 55 ms
68,096 KB
testcase_13 AC 58 ms
75,776 KB
testcase_14 AC 49 ms
66,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
  N=int(input())
  S=input()[::-1]
  Q=[]
  for i in range(N):
    Q.append(S[i])
    if len(Q)>=2 and Q[-1]=='A' and Q[-2]=='B':
      if len(Q)==2:
        continue
      if Q[-3]=='B':
        del Q[-1]
        del Q[-1]
  print(''.join(Q[::-1]))

for t in range(int(input())):
  solve()
0