Area of the scanned line of the hdu 1542 line segment tree and
Give you n rectangles, calculate their area, and calculate them repeatedly.
Idea: Use the scanning line of the Line Segment tree. After the X coordinate is discretization, the rectangle is scanned from bottom to top for various processing.
# Include
# Include
# Include
# Include
# Include using namespace std; typedef long ll; const int maxn = 1e3 + 10; # define mm (a) memset (a, 0, sizeof ()) int num1 [maxn * 4]; double num [maxn * 4], X [maxn * 4]; struct edge {double l, r, h; int s; // if the value of s is 1, the value of s is-1, and that of edge () {}; edge (double a, double B, double c, int d): l (), r (B), h (c), s (d) {} bool operator <(const edge & n) const {return h
> 1; if (l <= t) update (l, r, add, le, t, node <1); if (r> t) update (l, r, add, t + 1, ri, node <1 | 1); pushup (le, ri, node);} int main () {int n, t = 1; while (scanf ("% d", & n )! =-1) {if (n = 0) break; double a, B, c, d; int k = 0; for (int I = 0; I