結果
| 問題 |
No.96 圏外です。
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-12-07 21:50:27 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,064 bytes |
| コンパイル時間 | 62 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 14,016 KB |
| 最終ジャッジ日時 | 2024-06-11 17:36:04 |
| 合計ジャッジ時間 | 9,947 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 WA * 1 TLE * 1 -- * 22 |
コンパイルメッセージ
Syntax OK
ソースコード
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