結果

問題 No.199 星を描こう
ユーザー 👑 obakyanobakyan
提出日時 2020-04-24 21:15:55
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,616 bytes
コンパイル時間 390 ms
コンパイル使用メモリ 6,684 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-23 02:45:27
合計ジャッジ時間 1,035 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 3 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 3 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 1 ms
6,940 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 1 ms
6,940 KB
testcase_24 AC 3 ms
6,940 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 1 ms
6,940 KB
testcase_27 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local mfl, mce = math.floor, math.ceil
local x, y = {}, {}
for i = 1, 5 do
  x[i], y[i] = io.read("*n", "*n")
end

local function getpattern(n, patall, idx)
  local used = {}
  local retary = {}
  local div = patall
  for i = 1, n do used[i] = false end
  for i = n, 1, -1 do
    div = mfl(div / i)
    local v_idx = mfl(idx / div)
    idx = idx % div
    local tmp_idx = 0
    for j = 1, n do
      if not used[j] then
        if tmp_idx == v_idx then
          table.insert(retary, j)
          used[j] = true
          break
        else
          tmp_idx = tmp_idx + 1
        end
      end
    end
  end
  return retary
end

local function getLenFlag(p1, p2, q)
  local x1, y1 = x[p1], y[p1]
  local x2, y2 = x[p2], y[p2]
  local xq, yq = x[q], y[q]
  -- y = y1 + (y2 - y1) * (x - x1) / (x2 - x1)
  -- (y2-y1)x - (x2-x1)y - (y2-y1)x1 + (x2-x1)y1 = 0
  return (y2 - y1) * (xq - x1) - (x2 - x1) * (yq - y1)
end

local function solvepart(t, i1)
  local f = true
  local i2, i3, i4, i5 = i1 + 1, i1 + 2, i1 + 3, i1 + 4
  if 5 < i2 then i2 = i2 - 5 end
  if 5 < i3 then i3 = i3 - 5 end
  if 5 < i4 then i4 = i4 - 5 end
  if 5 < i5 then i5 = i5 - 5 end
  f = f and 0 < getLenFlag(t[i1], t[i3], t[i2])
  f = f and 0 > getLenFlag(t[i1], t[i3], t[i4])
  f = f and 0 > getLenFlag(t[i1], t[i3], t[i5])
  return f
end
local function solve(t)
  local f = true
  for i = 1, 5 do
    f = f and solvepart(t, i)
  end
  return f
end

local ret = false
for i = 0, 119 do
  local ary = getpattern(5, 120, i)
  if solve(ary) then
    -- print(table.concat(ary, " "))
    ret = true
    break
  end
end
print(ret and "YES" or "NO")
0