結果

問題 No.1265 Balloon Survival
ユーザー 👑 obakyanobakyan
提出日時 2020-11-17 23:11:38
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 1,192 ms / 2,000 ms
コード長 941 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 5,296 KB
実行使用メモリ 34,428 KB
最終ジャッジ日時 2023-09-30 14:30:21
合計ジャッジ時間 14,762 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 88 ms
6,304 KB
testcase_15 AC 62 ms
5,788 KB
testcase_16 AC 23 ms
4,380 KB
testcase_17 AC 526 ms
27,944 KB
testcase_18 AC 34 ms
4,376 KB
testcase_19 AC 25 ms
4,384 KB
testcase_20 AC 83 ms
6,244 KB
testcase_21 AC 220 ms
10,388 KB
testcase_22 AC 122 ms
8,792 KB
testcase_23 AC 137 ms
9,116 KB
testcase_24 AC 1,118 ms
34,428 KB
testcase_25 AC 1,171 ms
34,296 KB
testcase_26 AC 1,127 ms
34,248 KB
testcase_27 AC 1,153 ms
34,220 KB
testcase_28 AC 1,192 ms
34,288 KB
testcase_29 AC 1,180 ms
34,212 KB
testcase_30 AC 1,189 ms
34,276 KB
testcase_31 AC 1,185 ms
34,220 KB
testcase_32 AC 1,140 ms
34,284 KB
testcase_33 AC 1,149 ms
34,364 KB
testcase_34 AC 2 ms
4,384 KB
testcase_35 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0