結果

問題 No.168 ものさし
ユーザー gigurururugigurururu
提出日時 2015-04-01 21:54:37
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,559 ms / 2,000 ms
コード長 651 bytes
コンパイル時間 227 ms
コンパイル使用メモリ 11,584 KB
実行使用メモリ 47,684 KB
最終ジャッジ日時 2023-08-25 20:55:32
合計ジャッジ時間 12,003 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 527 ms
22,320 KB
testcase_01 AC 79 ms
15,044 KB
testcase_02 AC 79 ms
15,128 KB
testcase_03 AC 79 ms
15,116 KB
testcase_04 AC 80 ms
15,272 KB
testcase_05 AC 80 ms
15,004 KB
testcase_06 AC 79 ms
15,284 KB
testcase_07 AC 79 ms
15,040 KB
testcase_08 AC 79 ms
15,160 KB
testcase_09 AC 87 ms
15,264 KB
testcase_10 AC 113 ms
15,560 KB
testcase_11 AC 265 ms
21,548 KB
testcase_12 AC 761 ms
39,064 KB
testcase_13 AC 1,037 ms
47,524 KB
testcase_14 AC 865 ms
47,472 KB
testcase_15 AC 79 ms
15,284 KB
testcase_16 AC 89 ms
15,080 KB
testcase_17 AC 104 ms
15,244 KB
testcase_18 AC 140 ms
16,700 KB
testcase_19 AC 1,559 ms
47,296 KB
testcase_20 AC 1,477 ms
47,480 KB
testcase_21 AC 1,269 ms
47,560 KB
testcase_22 AC 1,374 ms
47,684 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

UF=Hash.new{|_,k|k}
def u a,b;UF[f a]=UF[f b]end
def f c;c==UF[c]?c:UF[c]=f(UF[c])end

n=gets.to_i
t=(1..n).map{|i|[i]+gets.split.map(&:to_i)}
l=t.combination(2).map{|(i,ix,iy),(j,jx,jy)|[(ix-jx)**2+(iy-jy)**2,i,j]}
_,tx,ty=t[0]
_,ux,uy=t[n-1]
mx=(tx-ux)**2+(ty-uy)**2
mn=l.map(&:first).min
p (1..200000000).bsearch{|a|
  b=(a*10)**2
  if mn>b
    false
  elsif mx<=b
    true
  else
    UF.clear
    tmn=2000000000
    tmx=10
    l.each{|d,i,j|
      if b>=d
        u(i,j)
        tmx=d if tmx<d
      else
        tmn=d if tmn>d
      end
    }
    if ret=f(1)==f(n)
      mx=tmx if mx>tmx
    else
      mn=tmn if mn<tmn
    end
    ret
  end
}*10
0