Submission #40336676


Source Code Expand

CP = lambda{|a,b| (a.conj*b).imag }
線上? = lambda{|a,x|
	0==CP[x,a] && x.abs2<=a.abs2
}
内部? = lambda{|a,b,c,x|
	0<CP[b-a,x-a] && 0<CP[c-b,x-b] && 0<CP[a-c,x-c]
}

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 'ON' if q.abs2==0
	next 'OUT' if CP[A,q]<0||0<CP[Z,q]
	next 'ON' if 線上?[A,q]||線上?[Z,q]
	i = Ps.bsearch_index{|p| CP[p,q]<=0 }
	r,s = Ps[i-1],Ps[i]
	next 'ON' if 線上?[s-r,q-r]
	next 'IN' if 内部?[0,r,s,q]
	next 'OUT'
}

Submission Info

Submission Time
Task G - Polygon and Points
User ds14050
Language Ruby (2.7.1)
Score 0
Code Size 593 Byte
Status WA
Exec Time 2406 ms
Memory 56892 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 2
AC × 24
WA × 2
Set Name Test Cases
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
Case Name Status Exec Time Memory
hack_01.txt AC 58 ms 14436 KiB
hack_02.txt AC 53 ms 14224 KiB
hand_01.txt AC 60 ms 14368 KiB
hand_02.txt AC 59 ms 14308 KiB
random_01.txt WA 59 ms 14220 KiB
random_02.txt WA 59 ms 14400 KiB
random_03.txt AC 2332 ms 56892 KiB
random_04.txt AC 2174 ms 40452 KiB
random_05.txt AC 2359 ms 56748 KiB
random_06.txt AC 2399 ms 56172 KiB
random_07.txt AC 2207 ms 45292 KiB
random_08.txt AC 2176 ms 45716 KiB
random_09.txt AC 2287 ms 56872 KiB
random_10.txt AC 2252 ms 49364 KiB
random_11.txt AC 2243 ms 43840 KiB
random_12.txt AC 2203 ms 47032 KiB
random_13.txt AC 2247 ms 44072 KiB
random_14.txt AC 2370 ms 55832 KiB
random_15.txt AC 2405 ms 56252 KiB
random_16.txt AC 2316 ms 56788 KiB
random_17.txt AC 2406 ms 56632 KiB
random_18.txt AC 58 ms 14252 KiB
random_19.txt AC 1189 ms 27908 KiB
random_20.txt AC 57 ms 14320 KiB
sample_01.txt AC 54 ms 14324 KiB
sample_02.txt AC 58 ms 14168 KiB