Rectangular area intersection-line segment tree

Source: Internet
Author: User

HDU-1255

The world is always so impermanence, and many things are always unexpected.

For example, this question.

I don't know how it is wrong, because binary is not well written?

After the perimeter of the rectangle is completed, the code is added with two zeros.

It's a small version of maxn.

The following is the correct code.

Suggestion: Learn the perimeter and area of the rectangle, first learn the area of the rectangle and.

Pro: 0sol: Date: */# include <iostream >#include <cstdio >#include <algorithm> # include <cstring> # define EPS 1e-10 # define maxn 101000 # define lson l, m, RT <1 # define rson m + 1, R, RT <1 | 1 using namespace STD; struct seg {double L, R, Y; int sign; seg () {} seg (double LL, double RR, double YY, int SS): L (LL), R (RR), y (yy), sign (SS) {} bool operator <(const seg & CMP) const {If (y = CMP. y) return sign> CMP. sign; R Eturn Y <CMP. Y ;}} seg [maxn <1]; // sum stores the fully overwritten length, rep stores the double sum [maxn <2], rep [maxn]; // C stores the int C [maxn <2]; // stores the original value for discretization of Double X [maxn <1]; void push_up (int rt, int L, int R) {If (C [RT]) sum [RT] = x [R + 1]-X [l]; else if (L = r) sum [RT] = 0.0; else sum [RT] = sum [RT <1] + sum [RT <1 | 1]; if (C [RT]> = 2) rep [RT] = x [R + 1]-X [l]; else if (L = r) rep [RT] = 0.0; // here we need to discuss else If (C [RT] = 1) rep [RT] = sum [RT <1] + sum [RT <1 | 1]; else rep [RT] = rep [RT <1] + rep [RT <1 | 1];} void Update (int l, int R, int SS, int l, int R, int RT) {If (L <= L & R <= r) {C [RT] + = SS; push_up (RT, L, R ); return;} int M = (L + r)> 1; if (L <= m) Update (L, R, SS, lson); If (r> m) update (L, R, SS, rson); push_up (RT, L, R);} // pay attention to double in binary mode // int Bin (INT low, int High, double key) {// int mid; // W Hile (low 

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.