結果

問題 No.168 ものさし
ユーザー gigurururugigurururu
提出日時 2015-04-01 21:53:26
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,657 ms / 2,000 ms
コード長 498 bytes
コンパイル時間 206 ms
コンパイル使用メモリ 11,268 KB
実行使用メモリ 47,748 KB
最終ジャッジ日時 2023-08-25 20:55:06
合計ジャッジ時間 12,829 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 551 ms
22,268 KB
testcase_01 AC 81 ms
15,184 KB
testcase_02 AC 80 ms
15,280 KB
testcase_03 AC 81 ms
15,076 KB
testcase_04 AC 79 ms
15,096 KB
testcase_05 AC 79 ms
15,124 KB
testcase_06 AC 81 ms
15,156 KB
testcase_07 AC 79 ms
15,140 KB
testcase_08 AC 80 ms
15,220 KB
testcase_09 AC 88 ms
15,292 KB
testcase_10 AC 110 ms
15,712 KB
testcase_11 AC 250 ms
21,648 KB
testcase_12 AC 704 ms
38,952 KB
testcase_13 AC 999 ms
47,532 KB
testcase_14 AC 838 ms
47,700 KB
testcase_15 AC 80 ms
15,368 KB
testcase_16 AC 91 ms
15,260 KB
testcase_17 AC 110 ms
15,320 KB
testcase_18 AC 155 ms
16,540 KB
testcase_19 AC 1,607 ms
47,176 KB
testcase_20 AC 1,657 ms
47,748 KB
testcase_21 AC 1,584 ms
47,496 KB
testcase_22 AC 1,582 ms
47,444 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:20: warning: assigned but unused variable - tmn
Main.rb:21: warning: assigned but unused variable - tmx
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|
      u(i,j) if b>=d
    }
    f(1)==f(n)
  end
}*10
0