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