Sweep Line
Authors: Benjamin Qi, Andi Qu
Prerequisites
Introduction to line sweep.
Imagine you have a vertical line that "sweeps" the plane from left to right. That's the main idea behind the sweep line.
You might be thinking "wait - isn't keeping track of the sweep line at all possible positions super inefficient?" And you'd be correct. However, we don't actually need to keep track of the sweep line at all possible positions - only at the "critical" positions (e.g. points and intersections).
This section is not complete.
should the reader already be familiar with the 1D case (union of intervals on number line?) never explicitly mentioned in module
| Resources | |||
|---|---|---|---|
| CPH | |||
| TC | |||
Closest Pair
Focus Problem – read through this problem before continuing!
Solution 1
(Divide and Conquer)
Solution 2
(Set)
Line Segments
Focus Problem – read through this problem before continuing!
Solution
This section is not complete.
Problems
| Status | Source | Problem Name | Difficulty | Tags | |||||
|---|---|---|---|---|---|---|---|---|---|
| Old Gold | Normal | Show TagsSweep Line | |||||||
| COI | Hard | Show TagsSweep Line | |||||||
| CEOI | Hard | Show TagsSweep Line | |||||||
| CEOI | Very Hard | Show TagsSweep Line | |||||||
| Baltic OI | Very Hard | Show TagsSweep Line | |||||||
Manhattan MST
Focus Problem – read through this problem before continuing!
(KACTL code)
explanation? topcoder prob has
| Status | Source | Problem Name | Difficulty | Tags | |||||
|---|---|---|---|---|---|---|---|---|---|
| CSA | Hard | Show TagsManhattan MST | |||||||
Radial Sweep
This section is not complete.
Focus Problem – read through this problem before continuing!
Solution - Seeing the Boundary
This section is not complete.
C++
#include <bits/stdc++.h>#define x first#define y secondtypedef long long ll;using namespace std;const double PI = 4 * atan(1);struct Event {short type, id;
Problems
| Status | Source | Problem Name | Difficulty | Tags | |||||
|---|---|---|---|---|---|---|---|---|---|
| CEOI | Easy | Show TagsBinary Search, Radial Sweep | |||||||
| POI | Normal | Show TagsRadial Sweep | |||||||
| APIO | Hard | Show TagsRadial Sweep | |||||||
| JOI | Very Hard | Show TagsRadial Sweep | |||||||
Module Progress:
Join the USACO Forum!
Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!