結果

問題 No.1894 Delete AB
ユーザー simansiman
提出日時 2022-04-09 00:32:15
言語 Ruby
(3.3.0)
結果
AC  
実行時間 213 ms / 2,000 ms
コード長 272 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 11,464 KB
実行使用メモリ 29,424 KB
最終ジャッジ日時 2023-08-19 03:00:15
合計ジャッジ時間 3,989 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
15,204 KB
testcase_01 AC 186 ms
15,804 KB
testcase_02 AC 182 ms
15,796 KB
testcase_03 AC 131 ms
15,224 KB
testcase_04 AC 140 ms
15,364 KB
testcase_05 AC 147 ms
15,360 KB
testcase_06 AC 144 ms
15,356 KB
testcase_07 AC 149 ms
15,220 KB
testcase_08 AC 162 ms
15,156 KB
testcase_09 AC 127 ms
15,376 KB
testcase_10 AC 146 ms
15,296 KB
testcase_11 AC 148 ms
15,256 KB
testcase_12 AC 161 ms
15,716 KB
testcase_13 AC 198 ms
21,860 KB
testcase_14 AC 213 ms
29,424 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:4: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

T = gets.to_i

T.times do
  n = gets.to_i
  s = gets.chomp

  stack = []

  s.each_char do |c|
    stack << c

    while stack.size >= 3 && stack[-3] == 'A' && stack[-2] == 'B' && stack[-1] == 'B'
      stack.pop(3)
      stack << 'B'
    end
  end

  puts stack.join
end
0