結果
| 問題 |
No.2602 Real Collider
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-01-12 22:01:19 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 716 bytes |
| コンパイル時間 | 277 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 77,440 KB |
| 最終ジャッジ日時 | 2024-09-27 22:13:59 |
| 合計ジャッジ時間 | 47,342 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 65 WA * 13 |
コンパイルメッセージ
Syntax OK
ソースコード
Q=gets.to_i
Inputs=gets(p).split.map(&:to_r)
def read()
x,y=Inputs.shift(2)
return x+y*1i
end
x=[read(),read(),read()]
def cross(a,b)
return a.real*b.imag-a.imag*b.real
end
def parallel(a,b)
return cross(a,b)==0
end
o=r=nil
if parallel(x[1]-x[0],x[2]-x[0])
maxr=0
x.combination(2).each{|a,b|
d=(b-a).abs2
if maxr<d
maxr=d
r=d/4
o=(a+b)/2
end
}
else
def line(x,y)
a1=(x+y)/2
t=y-x
a2=Complex(a1.real-t.imag,a1.imag+t.real)
return a1,a2
end
a1,a2=line(x[0],x[1])
b1,b2=line(x[0],x[2])
d1=cross(a2-a1,b1-a1)
d2=-cross(a2-a1,b2-a1)
o=b1+(b2-b1)*(d1/(d1+d2))
r=x.map{|x|(x-o).abs2}.max
end
Q.times{
d=(o-read()).abs2
puts d<=r ?"Yes":"No"
}