結果
問題 |
No.1265 Balloon Survival
|
ユーザー |
👑 |
提出日時 | 2020-11-17 23:11:38 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 1,089 ms / 2,000 ms |
コード長 | 941 bytes |
コンパイル時間 | 225 ms |
コンパイル使用メモリ | 6,944 KB |
実行使用メモリ | 34,560 KB |
最終ジャッジ日時 | 2024-07-23 08:32:31 |
合計ジャッジ時間 | 12,975 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
local mma = math.max local mfl, mce, mmi = math.floor, math.ceil, math.min local n = io.read("*n") local x, y = {}, {} for i = 1, n do x[i], y[i] = io.read("*n", "*n") end if n == 1 then print(0) os.exit() end local function lensq(i, j) return (1LL * x[i] - x[j]) * (1LL * x[i] - x[j]) + (1LL * y[i] - y[j]) * (1LL * y[i] - y[j]) end local e1, e2 = {}, {} local v = {} local alive = {} for i = 1, n do alive[i] = true end local c = 0 local idxes = {} for i = 1, n - 1 do for j = i + 1, n do c = c + 1 e1[c], e2[c] = i, j v[c] = lensq(i, j) idxes[c] = c end end table.sort(idxes, function(a, b) return v[a] < v[b] end) local ret = 0 for i = 1, c do local idx = idxes[i] local z1, z2 = e1[idx], e2[idx] if z1 == 1 then if alive[z2] then ret = ret + 1 alive[z2] = false end else if alive[z1] and alive[z2] then alive[z1], alive[z2] = false, false end end end print(ret)