結果

問題 No.437 cwwゲーム
ユーザー 👑 obakyanobakyan
提出日時 2019-04-29 14:02:30
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 184 ms / 2,000 ms
コード長 1,426 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 5,372 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-25 21:37:13
合計ジャッジ時間 9,168 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 168 ms
4,380 KB
testcase_01 AC 140 ms
4,384 KB
testcase_02 AC 176 ms
4,384 KB
testcase_03 AC 162 ms
4,384 KB
testcase_04 AC 169 ms
4,384 KB
testcase_05 AC 174 ms
4,380 KB
testcase_06 AC 180 ms
4,380 KB
testcase_07 AC 179 ms
4,384 KB
testcase_08 AC 168 ms
4,384 KB
testcase_09 AC 176 ms
4,380 KB
testcase_10 AC 178 ms
4,384 KB
testcase_11 AC 135 ms
4,380 KB
testcase_12 AC 1 ms
4,384 KB
testcase_13 AC 173 ms
4,384 KB
testcase_14 AC 170 ms
4,380 KB
testcase_15 AC 180 ms
4,384 KB
testcase_16 AC 154 ms
4,380 KB
testcase_17 AC 176 ms
4,380 KB
testcase_18 AC 173 ms
4,380 KB
testcase_19 AC 168 ms
4,384 KB
testcase_20 AC 156 ms
4,384 KB
testcase_21 AC 169 ms
4,384 KB
testcase_22 AC 167 ms
4,380 KB
testcase_23 AC 167 ms
4,380 KB
testcase_24 AC 166 ms
4,380 KB
testcase_25 AC 167 ms
4,380 KB
testcase_26 AC 163 ms
4,384 KB
testcase_27 AC 147 ms
4,384 KB
testcase_28 AC 172 ms
4,380 KB
testcase_29 AC 149 ms
4,384 KB
testcase_30 AC 138 ms
4,380 KB
testcase_31 AC 156 ms
4,380 KB
testcase_32 AC 141 ms
4,380 KB
testcase_33 AC 178 ms
4,384 KB
testcase_34 AC 163 ms
4,380 KB
testcase_35 AC 171 ms
4,380 KB
testcase_36 AC 141 ms
4,384 KB
testcase_37 AC 142 ms
4,380 KB
testcase_38 AC 159 ms
4,380 KB
testcase_39 AC 141 ms
4,380 KB
testcase_40 AC 161 ms
4,384 KB
testcase_41 AC 168 ms
4,384 KB
testcase_42 AC 184 ms
4,380 KB
testcase_43 AC 167 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local str = io.read()
local t = {}
local function cww(i, j, k)
  ret = 0
  if(1 <= t[i] and 0 <= t[j] and 0 <= t[k]) then
    if(t[i] ~= t[j] and t[j] == t[k]) then
      ret = t[i] * 100 + t[j] * 11
    end
  end
  return ret
end

local box = {}
for i = 1, 12 do box[i] = false end

local function setbox(i, j, k, flag)
  box[i], box[j], box[k] = flag, flag, flag
end
local function getbox(idx)
  local i = 1
  for j = 1, 12 do
    if(not box[j]) then
      if(i == idx) then return j
      else i = i + 1 end
    end
  end
  return nil
end
if(str == "1000000000000") then
  print(100)
else
  for i = 1, 12 do
    if(#str < i) then t[i] = -1 else t[i] = tonumber(str:sub(i, i)) end
  end
  local cwwmax = 0
  for i1=1,10 do for j1=i1+1,11 do for k1=j1+1,12 do
    setbox(i1, j1, k1, true)
    for i2=1,7 do for j2=i2+1,8 do for k2=j2+1,9 do
      local i2r, j2r, k2r = getbox(i2), getbox(j2), getbox(k2)
      setbox(i2r, j2r, k2r, true)
      for i3=1,4 do for j3=i3+1,5 do for k3=j3+1,6 do
        local i3r, j3r, k3r = getbox(i3), getbox(j3), getbox(k3)
        setbox(i3r, j3r, k3r, true)
        local i4r, j4r, k4r = getbox(1), getbox(2), getbox(3)
        cwwmax = math.max(cwwmax, cww(i1,j1,k1)+cww(i2r,j2r,k2r)+cww(i3r,j3r,k3r)+cww(i4r,j4r,k4r))
        setbox(i3r, j3r, k3r, false)
      end end end
      setbox(i2r, j2r, k2r, false)
    end end end
    setbox(i1, j1, k1, false)
  end end end
  print(cwwmax)
end
0