結果

問題 No.1894 Delete AB
ユーザー 👑 obakyan
提出日時 2022-05-02 15:50:25
言語 Lua
(LuaJit 2.1.1734355927)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 508 bytes
コンパイル時間 130 ms
コンパイル使用メモリ 6,688 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-01 19:37:39
合計ジャッジ時間 1,197 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

local q = io.read("*n", "*l")
for iq = 1, q do
  local n = io.read("*n", "*l")
  local s = io.read()
  local t = {}
  for i = 1, n do
    local b = s:byte(i) - 64
    table.insert(t, b)
    while true do
      if 2 < #t and t[#t - 1] == 2 and t[#t - 2] == 1 and t[#t] == 2 then
        table.remove(t)
        table.remove(t)
        table.remove(t)
        table.insert(t, 2)
      else
        break
      end
    end
  end
  for i = 1, #t do t[i] = string.char(t[i] + 64) end
  print(table.concat(t))
end
0