提出 #40350677


ソースコード 拡げる

CP = lambda{|a,b| (a.conj*b).imag }
上方? = lambda{|a,x| 0<CP[a,x] }
下方? = lambda{|a,x| CP[a,x]<0 }
線上? = lambda{|a,x| [0,1].index(a.conj*x<=>0)&&x.abs2<=a.abs2 }

N = gets.to_i
O,*Ps = N.times.map{ Complex(*gets.split) }
Ps.map!{|p| p-O }
A,Z = Ps[0],Ps[-1]

puts gets.to_i.times.map{
	q = Complex(*gets.split)-O
	next 'OUT' if 下方?[A,q]||上方?[Z,q]
	next 'ON' if 線上?[A,q]||線上?[Z,q]
#warn [A.conj*q,Z.conj*q].inspect
	i = Ps.bsearch_index{|p| 下方?[p,q] }||-1
	r,s = Ps[i-1],Ps[i]
#warn [O,r,s,q].inspect
	next %w[ON IN OUT][CP[s-r,q-r]<=>0]
}

提出情報

提出日時
問題 G - Polygon and Points
ユーザ ds14050
言語 Ruby (2.7.1)
得点 600
コード長 606 Byte
結果 AC
実行時間 2254 ms
メモリ 56864 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 600 / 600
結果
AC × 2
AC × 26
セット名 テストケース
Sample sample_01.txt, sample_02.txt
All hack_01.txt, hack_02.txt, hand_01.txt, hand_02.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, sample_01.txt, sample_02.txt
ケース名 結果 実行時間 メモリ
hack_01.txt AC 60 ms 14208 KiB
hack_02.txt AC 57 ms 14224 KiB
hand_01.txt AC 56 ms 14208 KiB
hand_02.txt AC 54 ms 14328 KiB
random_01.txt AC 58 ms 14412 KiB
random_02.txt AC 55 ms 14388 KiB
random_03.txt AC 2179 ms 56680 KiB
random_04.txt AC 2011 ms 42136 KiB
random_05.txt AC 2208 ms 56864 KiB
random_06.txt AC 2178 ms 55268 KiB
random_07.txt AC 2086 ms 45392 KiB
random_08.txt AC 2047 ms 45920 KiB
random_09.txt AC 2196 ms 56760 KiB
random_10.txt AC 2085 ms 49644 KiB
random_11.txt AC 2101 ms 44180 KiB
random_12.txt AC 2074 ms 47168 KiB
random_13.txt AC 2136 ms 43236 KiB
random_14.txt AC 2216 ms 52564 KiB
random_15.txt AC 2217 ms 55800 KiB
random_16.txt AC 2240 ms 56840 KiB
random_17.txt AC 2254 ms 56648 KiB
random_18.txt AC 57 ms 14424 KiB
random_19.txt AC 1030 ms 27784 KiB
random_20.txt AC 57 ms 14364 KiB
sample_01.txt AC 56 ms 14132 KiB
sample_02.txt AC 56 ms 14212 KiB