- 首页 > it技术 > >
#include
using namespace std;
const int MAXN=10005;
int a[MAXN];
int sumv[MAXN<<2],lzt[MAXN<<2];
struct xds{
#define lson (o<<1)
#define rson (o<<1|1)
#define mid ((l+r)>>1)
inline void pushup(int o){sumv[o]=sumv[lson]+sumv[rson];
}
inline void pushdown(int o,int l,int r)
{
if(lzt[o]==-10)return;
sumv[lson]=(mid-l+1)*lzt[o];
sumv[rson]=(r-mid)*lzt[o];
//if(lzt[lson]==0&&lzt[o]==1)
lzt[lson]=lzt[o];
lzt[rson]=lzt[o];
lzt[o]=-10;
}
inline void buildt(int o,int l,int r){
lzt[o]=-10;
if(l==r){sumv[o]=1;
return;
}
buildt(lson,l,mid);
buildt(rson,mid+1,r);
pushup(o);
}
inline int query(int o,int l,int r,int ql,int qr){
if(ql<=l&&qr>=r){return sumv[o];
}
pushdown(o,l,r);
int ans=0;
if(ql<=mid)ans+=query(lson,l,mid,ql,qr);
if(qr>mid)ans+=query(rson,mid+1,r,ql,qr);
return ans;
}
inline void change(int o,int l,int r,int ql,int qr,int v){
if(ql<=l&&qr>=r){sumv[o]=(r-l+1)*v;
lzt[o]=v;
return ;
}
pushdown(o,l,r);
if(ql<=mid)change(lson,l,mid,ql,qr,v);
if(qr>mid)change(rson,mid+1,r,ql,qr,v);
pushup(o);
}
};
xds wa;
int l,n,shu[MAXN],aa,b,c;
int main(){
scanf("%d%d",&l,&n);
l=l+2;
wa.buildt(1,1,l);
//cout<
推荐阅读