现在想起来自己好像从来都没有写过线段树lazy tag呢,唉真是惭愧。现在老师开始讲线段树了,我就被要求滚去写线段树啦。。
这道题就是区间都加上一个值;区间都变为一个值;求区间和,最大值,最小值。其中行数<=20行,所以拆成20个线段树就好了。结果写了两h+(真是弱),然后全局变量pos在main()前面加了个int调了1h+,初始化还写炸了runtime error好几发。。好了不说了。
AC代码如下:
#include<iostream>
#include<cstdio>
#include<cstring>
#define N 500005
#define inf 1000000000
using namespace std;
int n,m,pos; struct node{ int x,y,z; };
int read(){
int x=0; char ch=getchar();
while (ch<'0' || ch>'9') ch=getchar();
while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
return x;
}
struct sgtree{
int c[N][2],val[N],add[N]; node p[N];