結果

問題 No.38 赤青白ブロック
ユーザー 👑 obakyanobakyan
提出日時 2022-01-10 11:12:38
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 1,680 ms / 5,000 ms
コード長 993 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 6,948 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-26 20:02:21
合計ジャッジ時間 43,980 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,464 ms
5,248 KB
testcase_01 AC 1,561 ms
5,376 KB
testcase_02 AC 1,580 ms
5,376 KB
testcase_03 AC 1,680 ms
5,376 KB
testcase_04 AC 1,455 ms
5,376 KB
testcase_05 AC 1,512 ms
5,376 KB
testcase_06 AC 1,606 ms
5,376 KB
testcase_07 AC 1,546 ms
5,376 KB
testcase_08 AC 1,391 ms
5,376 KB
testcase_09 AC 1,482 ms
5,376 KB
testcase_10 AC 1,455 ms
5,376 KB
testcase_11 AC 1,445 ms
5,376 KB
testcase_12 AC 1,516 ms
5,376 KB
testcase_13 AC 1,416 ms
5,376 KB
testcase_14 AC 1,496 ms
5,376 KB
testcase_15 AC 1,523 ms
5,376 KB
testcase_16 AC 1,548 ms
5,376 KB
testcase_17 AC 1,499 ms
5,376 KB
testcase_18 AC 1,512 ms
5,376 KB
testcase_19 AC 1,441 ms
5,376 KB
testcase_20 AC 1,516 ms
5,376 KB
testcase_21 AC 1,556 ms
5,376 KB
testcase_22 AC 1,575 ms
5,376 KB
testcase_23 AC 1,493 ms
5,376 KB
testcase_24 AC 1,618 ms
5,376 KB
testcase_25 AC 1,485 ms
5,376 KB
testcase_26 AC 1,457 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local mmi, mma = math.min, math.max
local bls, brs = bit.lshift, bit.rshift
local kr, kb = io.read("*n", "*n", "*l")
local s = io.read()
local red, blue = {}, {}
local t = {}
local use = {}
for i = 1, 30 do
  use[i] = true
  t[i] = s:sub(i, i)
  if t[i] == "R" then
    table.insert(red, i)
  elseif t[i] == "B" then
    table.insert(blue, i)
  end
end
local ret = 10
local tot = bls(1, 20)
for i = 0, tot - 1 do
  local ti = i
  for j = 1, 10 do
    local tgt = red[j]
    use[tgt] = ti % 2 == 1
    ti = brs(ti, 1)
  end
  for j = 1, 10 do
    local tgt = blue[j]
    use[tgt] = ti % 2 == 1
    ti = brs(ti, 1)
  end
  local w = {}
  for j = 1, 30 do
    if use[j] then
      table.insert(w, t[j])
    end
  end
  local valid = true
  for j = 1, #w - kr do
    if w[j] == "R" and w[j + kr] == "R" then valid = false break end
  end
  for j = 1, #w - kb do
    if w[j] == "B" and w[j + kb] == "B" then valid = false break end
  end
  if valid then
    ret = mma(ret, #w)
  end
end
print(ret)
0