Sweep Line & Interval
思路:
不需要检测每一时刻,只需要检测起点或者终点的位置!(交点变化的位置只有起点或者终点)
将数据拆成二元组 [起点/终点标识,时刻]
按照时刻排序
依次扫描
...the simple but powerful idea of a sweep line: a vertical line that is conceptually “swept” across the plane. In practice, of course, we cannot simulate all points in time and so we consider only some discrete points.
-- TopCoder: https://www.topcoder.com/community/competitive-programming/tutorials/line-sweep-algorithms/
Template for Point
Reference
https://www.topcoder.com/community/competitive-programming/tutorials/line-sweep-algorithms/ 👍
https://courses.csail.mit.edu/6.006/spring11/lectures/lec24.pdf
https://blog.csdn.net/luoshengkim/article/details/72568519
https://en.wikipedia.org/wiki/Sweep_line_algorithm
https://www.hackerearth.com/practice/math/geometry/line-sweep-technique/tutorial/
Last updated