結果
問題 | 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 dox[i], y[i] = io.read("*n", "*n")parent[i] = 0endlocal function getroot(idx)while(parent[idx] ~= 0) doidx = parent[idx]endreturn idxendlocal function getsqlen(idx1, idx2)return (x[idx1] - x[idx2]) * (x[idx1] - x[idx2]) + (y[idx1] - y[idx2]) * (y[idx1] - y[idx2])endfor i = 1, n - 1 dofor j = i + 1, n doif(getsqlen(i, j) <= 100) thenlocal ip, jp = getroot(i), getroot(j)if(ip ~= jp) then parent[jp] = ip endif(ip ~= i) then parent[i] = ip endif(ip ~= j) then parent[j] = ip endendendendlocal rootlist = {}for i = 1, n dolocal r = getroot(i)if(rootlist[r] == nil) then rootlist[r] = {} endtable.insert(rootlist[r], i)endlocal totmaxlen = 0for key, val in pairs(rootlist) dofor i = 1, #val - 1 dofor j = i + 1, #val dototmaxlen = math.max(totmaxlen, getsqlen(val[i], val[j]))endendendif(n == 0) thenprint(1)elseprint(string.format("%.8f", 2 + math.sqrt(totmaxlen)))end