結果

問題 No.1894 Delete AB
ユーザー googol_S0googol_S0
提出日時 2022-04-08 22:16:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 199 ms / 2,000 ms
コード長 303 bytes
コンパイル時間 566 ms
コンパイル使用メモリ 87,172 KB
実行使用メモリ 84,248 KB
最終ジャッジ日時 2023-08-19 00:46:11
合計ジャッジ時間 3,926 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
71,272 KB
testcase_01 AC 91 ms
76,376 KB
testcase_02 AC 88 ms
76,712 KB
testcase_03 AC 180 ms
78,112 KB
testcase_04 AC 187 ms
78,864 KB
testcase_05 AC 188 ms
78,264 KB
testcase_06 AC 193 ms
78,328 KB
testcase_07 AC 188 ms
78,244 KB
testcase_08 AC 199 ms
78,628 KB
testcase_09 AC 142 ms
77,500 KB
testcase_10 AC 139 ms
77,576 KB
testcase_11 AC 97 ms
76,020 KB
testcase_12 AC 93 ms
76,144 KB
testcase_13 AC 97 ms
84,248 KB
testcase_14 AC 96 ms
76,676 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