Late_comer's blog

By Late_comer, history, 5 weeks ago, ,

How to solve this problem?

Given n points in a plane and q queries in each query a point P is given, and for each query we have to find the minimum of the dot product of point P taken with the given n points.

1 <= n,q <= 10^5

0 <= |x|,|y| <= 10^9

• +39

 » 5 weeks ago, # |   +26 It can be solved with convex hull trick. For a fixed point, try to rearrange the formula to make it work.
•  » » 5 weeks ago, # ^ | ← Rev. 2 →   +10 It looks to me like a 3D convex hull. How do you rearrange it?
 » 5 weeks ago, # | ← Rev. 2 →   +18 First of all, we find lower convex envelope. Then we can run ternary search. It's the simplest way to do it. For max you would find upper convex envelope instead. If constraints would allow coordinates to be negative you would split points by their x(<0 and >=0) and do two queries.Try problem squad from function cup 2019 it uses this concept but is a bit harder.
 » 5 weeks ago, # | ← Rev. 6 →   +18 X1*x2+y1*y2=sqrt(x1^2+y1^2)*sqrt(x2^2+y2^2)*cos(a)a is angle between vectors (x1, y1) and (x2, y2). |(x1,y1)|*|(x2,y2)| * cos(a) = (projectio)^2This can be done with convex hull of dots and some binary search(lower hull for P.y>0 and upper hull for P.y<0)P.s sorry for my poor english
 » 5 weeks ago, # |   0 I know a trendy question on this concept. ;)
•  » » 5 weeks ago, # ^ |   +16 It’s surprising how little the word “trendy” describes itself.