結果
問題 |
No.94 圏外です。(EASY)
|
ユーザー |
👑 |
提出日時 | 2019-04-22 23:51:08 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 6 ms / 5,000 ms |
コード長 | 1,069 bytes |
コンパイル時間 | 490 ms |
コンパイル使用メモリ | 5,504 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-12 04:44:41 |
合計ジャッジ時間 | 1,077 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
ソースコード
local n = io.read("*n") local x, y = {}, {} local parent = {} for i = 1, n do x[i], y[i] = io.read("*n", "*n") parent[i] = 0 end local function getroot(idx) while(parent[idx] ~= 0) do idx = parent[idx] end return idx end local function getsqlen(idx1, idx2) return (x[idx1] - x[idx2]) * (x[idx1] - x[idx2]) + (y[idx1] - y[idx2]) * (y[idx1] - y[idx2]) end for i = 1, n - 1 do for j = i + 1, n do if(getsqlen(i, j) <= 100) then local ip, jp = getroot(i), getroot(j) if(ip ~= jp) then parent[jp] = ip end if(ip ~= i) then parent[i] = ip end if(ip ~= j) then parent[j] = ip end end end end local rootlist = {} for i = 1, n do local r = getroot(i) if(rootlist[r] == nil) then rootlist[r] = {} end table.insert(rootlist[r], i) end local totmaxlen = 0 for key, val in pairs(rootlist) do for i = 1, #val - 1 do for j = i + 1, #val do totmaxlen = math.max(totmaxlen, getsqlen(val[i], val[j])) end end end if(n == 0) then print(1) else print(string.format("%.8f", 2 + math.sqrt(totmaxlen))) end