Area of the scanned line of the hdu 1542 line segment tree and

Source: Internet
Author: User

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
      
       

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.