Submission #40337287


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 'ON' if 線上?[A,q]||線上?[Z,q]
	next 'OUT' if CP[A,q]<=0||0<=CP[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 594 Byte
Status WA
Exec Time 2212 ms
Memory 56884 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 2
AC × 23
WA × 3
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 56 ms 14332 KiB
hack_02.txt AC 55 ms 14168 KiB
hand_01.txt AC 51 ms 14480 KiB
hand_02.txt AC 62 ms 14212 KiB
random_01.txt WA 57 ms 14312 KiB
random_02.txt WA 57 ms 14256 KiB
random_03.txt AC 2153 ms 56832 KiB
random_04.txt AC 2030 ms 41556 KiB
random_05.txt AC 2129 ms 56660 KiB
random_06.txt AC 2166 ms 56280 KiB
random_07.txt AC 2053 ms 45336 KiB
random_08.txt AC 2068 ms 45728 KiB
random_09.txt AC 2176 ms 56880 KiB
random_10.txt AC 2064 ms 49424 KiB
random_11.txt AC 2043 ms 44452 KiB
random_12.txt AC 2049 ms 47136 KiB
random_13.txt AC 2028 ms 43200 KiB
random_14.txt AC 2183 ms 55892 KiB
random_15.txt AC 2197 ms 56400 KiB
random_16.txt AC 2175 ms 56884 KiB
random_17.txt AC 2212 ms 56696 KiB
random_18.txt AC 58 ms 14328 KiB
random_19.txt AC 1101 ms 27652 KiB
random_20.txt WA 58 ms 14284 KiB
sample_01.txt AC 56 ms 14208 KiB
sample_02.txt AC 55 ms 14356 KiB