Number of interesctions

Revision en2, by Vasiljko, 2017-11-10 17:59:35

Given convex polygon with N points (clockwise and there are no 3 collinear points). Also given M vertical line segments. Find out how many edges of polygon are intersected by at least one line segment.
Note that if line segment is going through one of the N points, then both edges are counting.

Points are represented as Xi Yi.
Line segments are represented as Ai Pi Ki which means that starting point is at (Ai,Pi) and ending point is at (Ai,Ki)

3 <= N <= 10^5
1 <= M <= 10^5
-10^7 <= Xi,Yi,Ai,Pi,Ki <= 10^7
TL: 1s
ML: 64MB

Tags #geometry, line sweep, line intersections

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Vasiljko 2017-11-10 17:59:35 0 (published)
en1 English Vasiljko 2017-11-10 17:57:55 589 Initial revision (saved to drafts)