Puzzle: Test instructions is very naked ~ ~ ~
Training when said to write Mark permanent, anyway permanent is very water, directly wrote.
But I don't know why I want to be permanent, or I can't understand it deeply, but I'm sure I can analyze it 233.
Probably perhaps it is:
Direct reason: The next pass mark cannot go down.
Root cause:
The segment tree has two layers, so that it can be passed a bit like a topology
Is that the outer segment tree needs to pass to the inner layer segment tree, and then the inner layer segment tree will be passed
So when you sweep somewhere, you need to go back to the root, along the markings on both sides,
Then all kinds of pressure stack ah what, can pass down, and big probability error (code wrong or thinking wrong).
So simply write a sign to make it permanent, (it's very simple anyway.
Konjac Konjac may be wrong, welcome the Big God or Star of the message batch.
Code (short, short, and weak):
(Say you see my define n do not spit groove, its data range may be slightly weak, I am from other people to glue the n~~~~~)
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define N 705using namespace Std;int n,m,q;int h,x0,x1,y0,y1;struct segment_tree{int val[n<<2],flag[n<<2];int query (int note =1,int l=1,int r=m,int l=y0,int r=y1) {if (l==l&&r==r) return Val[note];int mid=l+r>>1,ans=flag[note];if ( R<=mid) return Max (Ans,query (note<<1,l,mid,l,r)), else if (L>mid) return Max (Ans,query (note<<1|1, MID+1,R,L,R); else return Max (Ans,max (Query (note<<1,l,mid,l,mid), query (NOTE<<1|1,MID+1,R,MID+1,R)));} void change (int note=1,int l=1,int r=m,int l=y0,int r=y1,int w=h) {Val[note]=max (val[note],w), if (l==l&&r==r) { Flag[note]=max (flag[note],w); return;} int mid=l+r>>1;if (R<=MID) Change (note<<1,l,mid,l,r), and else if (l>mid) change (note<<1|1,mid+1, R,L,R); else Change (Note<<1,l,mid,l,mid), change (NOTE<<1|1,MID+1,R,MID+1,R);}}; struct Segment_tree{segment_tree val[n<<2],flag[n<<2];int query (int note=1,int l=1,int r=n,int l=x0,int r=x1) {if (l==l&&r==r) return val[note].query (); int mid=l+r>> 1,ans=flag[note].query (); if (R<=mid) return Max (Ans,query (note<<1,l,mid,l,r)); else if (L>mid) return Max ( Ans,query (note<<1|1,mid+1,r,l,r)); else return Max (Ans,max (Query (note<<1,l,mid,l,mid), query (note< <1|1,MID+1,R,MID+1,R)));} void change (int note=1,int l=1,int r=n,int l=x0,int r=x1,int w=h) {val[note].change (); if (l==l&&r==r) {Flag[note ].change (); return;} int mid=l+r>>1;if (R<=MID) Change (note<<1,l,mid,l,r), and else if (l>mid) change (note<<1|1,mid+1, R,L,R); else Change (Note<<1,l,mid,l,mid), change (NOTE<<1|1,MID+1,R,MID+1,R);}} Tree;int Main () {//freopen ("test.in", "R", stdin), scanf ("%d%d%d", &n,&m,&q), while (q--) {scanf ("%d%d%d%d% D ", &x1,&y1,&h,&x0,&y0); X1+=x0,y1+=y0,x0++,y0++;h+=tree.query (); Tree.change ();} x0=y0=1,x1=n,y1=m;printf ("%d\n", Tree.query (1,1,n,1,n)); return 0;}
"BZOJ1513" "POI2006" Tet-tetris 3D two-dimensional segment tree + tag permanence