結果
| 問題 | No.199 星を描こう |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-24 21:15:55 |
| 言語 | Lua (LuaJit 2.1.1734355927) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 1,616 bytes |
| コンパイル時間 | 355 ms |
| コンパイル使用メモリ | 5,120 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-15 02:10:44 |
| 合計ジャッジ時間 | 1,200 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
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")