結果

問題 No.2602 Real Collider
ユーザー kotatsugamekotatsugame
提出日時 2024-01-12 22:12:11
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,457 ms / 2,000 ms
コード長 860 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 79,744 KB
最終ジャッジ日時 2024-01-12 22:13:00
合計ジャッジ時間 48,135 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
16,256 KB
testcase_01 AC 83 ms
16,256 KB
testcase_02 AC 84 ms
16,256 KB
testcase_03 AC 86 ms
16,256 KB
testcase_04 AC 86 ms
16,256 KB
testcase_05 AC 85 ms
16,256 KB
testcase_06 AC 84 ms
16,256 KB
testcase_07 AC 83 ms
16,256 KB
testcase_08 AC 85 ms
16,256 KB
testcase_09 AC 93 ms
16,256 KB
testcase_10 AC 1,457 ms
79,744 KB
testcase_11 AC 609 ms
38,400 KB
testcase_12 AC 537 ms
39,680 KB
testcase_13 AC 278 ms
29,312 KB
testcase_14 AC 557 ms
40,064 KB
testcase_15 AC 487 ms
29,824 KB
testcase_16 AC 690 ms
39,168 KB
testcase_17 AC 778 ms
39,680 KB
testcase_18 AC 397 ms
37,504 KB
testcase_19 AC 438 ms
38,784 KB
testcase_20 AC 824 ms
40,704 KB
testcase_21 AC 385 ms
36,096 KB
testcase_22 AC 447 ms
38,656 KB
testcase_23 AC 335 ms
29,568 KB
testcase_24 AC 439 ms
38,400 KB
testcase_25 AC 428 ms
38,656 KB
testcase_26 AC 442 ms
29,824 KB
testcase_27 AC 508 ms
39,296 KB
testcase_28 AC 657 ms
39,552 KB
testcase_29 AC 464 ms
38,528 KB
testcase_30 AC 433 ms
38,912 KB
testcase_31 AC 726 ms
39,168 KB
testcase_32 AC 604 ms
38,400 KB
testcase_33 AC 739 ms
39,168 KB
testcase_34 AC 697 ms
39,296 KB
testcase_35 AC 483 ms
29,696 KB
testcase_36 AC 433 ms
29,696 KB
testcase_37 AC 761 ms
39,552 KB
testcase_38 AC 791 ms
39,808 KB
testcase_39 AC 795 ms
39,552 KB
testcase_40 AC 402 ms
29,184 KB
testcase_41 AC 862 ms
40,320 KB
testcase_42 AC 701 ms
38,912 KB
testcase_43 AC 641 ms
39,040 KB
testcase_44 AC 890 ms
40,448 KB
testcase_45 AC 565 ms
37,504 KB
testcase_46 AC 544 ms
36,096 KB
testcase_47 AC 811 ms
39,680 KB
testcase_48 AC 601 ms
38,400 KB
testcase_49 AC 532 ms
35,584 KB
testcase_50 AC 432 ms
29,312 KB
testcase_51 AC 468 ms
29,568 KB
testcase_52 AC 333 ms
27,136 KB
testcase_53 AC 708 ms
39,168 KB
testcase_54 AC 586 ms
37,504 KB
testcase_55 AC 626 ms
38,528 KB
testcase_56 AC 617 ms
38,528 KB
testcase_57 AC 576 ms
38,144 KB
testcase_58 AC 278 ms
23,552 KB
testcase_59 AC 684 ms
39,040 KB
testcase_60 AC 565 ms
38,528 KB
testcase_61 AC 520 ms
34,304 KB
testcase_62 AC 707 ms
39,296 KB
testcase_63 AC 821 ms
40,064 KB
testcase_64 AC 953 ms
40,960 KB
testcase_65 AC 488 ms
34,176 KB
testcase_66 AC 779 ms
39,680 KB
testcase_67 AC 396 ms
29,184 KB
testcase_68 AC 452 ms
29,568 KB
testcase_69 AC 336 ms
27,392 KB
testcase_70 AC 389 ms
29,184 KB
testcase_71 AC 505 ms
29,824 KB
testcase_72 AC 687 ms
39,040 KB
testcase_73 AC 607 ms
38,272 KB
testcase_74 AC 708 ms
39,168 KB
testcase_75 AC 778 ms
39,552 KB
testcase_76 AC 658 ms
38,784 KB
testcase_77 AC 706 ms
39,040 KB
testcase_78 AC 888 ms
40,320 KB
testcase_79 AC 718 ms
39,424 KB
testcase_80 AC 833 ms
40,192 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

Q=gets.to_i
Inputs=gets(p).split.map(&:to_r)
def read()
  x,y=Inputs.shift(2)
  return x+y*1i
end
def assert(f)
  raise "Error" unless f
end
x=[read(),read(),read()]
assert(x.uniq.size==3)
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=0+0i
r=10**20
if !parallel(x[1]-x[0],x[2]-x[0])
  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)
  assert(d1+d2!=0)
  o=b1+(b2-b1)*(d1/(d1+d2))
  r=x.map{|x|(x-o).abs2}
  assert(r.uniq.size==1)
  r=r.max
end
x.combination(2).each{|a,b|
  no=(a+b)/2
  nr=(a-b).abs2/4
  if nr<r&&x.all?{|t|(no-t).abs2<=nr}
    o,r=no,nr
  end
}
assert(Inputs.size==2*Q)
Q.times{
  d=(o-read()).abs2
  puts d<=r ? "Yes" : "No"
}
0