結果

問題 No.96 圏外です。
ユーザー らっしー(raccy)らっしー(raccy)
提出日時 2014-12-07 21:50:27
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 1,064 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 11,276 KB
実行使用メモリ 15,468 KB
最終ジャッジ日時 2023-09-02 10:55:57
合計ジャッジ時間 9,991 ms
ジャッジサーバーID
(参考情報)
judge16 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,468 KB
testcase_01 AC 82 ms
15,316 KB
testcase_02 AC 84 ms
15,308 KB
testcase_03 WA -
testcase_04 AC 2,590 ms
15,452 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Chukei
  attr_reader :x, :y, :friends
  def initialize(x, y)
    @x = x.to_f
    @y = y.to_f
    @friends = []
  end

  def friend?(other)
    @friends.include?(other)
  end

  def denpa?(other)
    distance(other) <= 10
  end

  def add_friend(other)
    @friends << other
    @friends |= other.friends
  end

  def distance(other)
    return Math.sqrt((@x - other.x)**2 + (@y - other.y)**2)
  end

  def max_dist_friend
    m = -1
    @friends.each do |other|
      kyori = distance(other)
      m = kyori if kyori > m
    end
    return m
  end
end

n = gets.to_i
chukei_list = []
n.times do
  chukei_list << Chukei.new(*(gets.split.map(&:to_i)))
end

chukei_list.each do |chukei|
  chukei_list.each do |other|
    unless chukei.friend?(other)
      if chukei.denpa?(other)
        chukei.add_friend(other)
      end
    end
  end
end

m = -1
chukei_list.each do |chukei|
  chu_m = chukei.max_dist_friend
  m = chu_m if m < chu_m
end
if m == -1
  kotae = 2
else
  kotae = m + 2
end
puts kotae
0