为啥int开8888888会MLE啊
查看原帖
为啥int开8888888会MLE啊
1328928
only_once楼主2024/12/5 19:57
#include<bits/stdc++.h>
#define L (root%262150)*2+root/262150*262150
#define R (root%262150)*2+1+root/262150*262150
#define TL tree[root].l
#define TR tree[root].r
using namespace std;
int n,m,maxx=0,kkll;
struct node{
	int l,r,sum,lazy=-1e9,lson,rson;
}tree[8888888];
void pushdown(int root){
	tree[root].sum=tree[L].sum+tree[R].sum;
}
void build(int l,int r,int k,int root){
	maxx=max(maxx,root+k);
	tree[root+k].l=l;
	tree[root+k].r=r;
	if(l==r){
		tree[root+k].sum=0;
		return ;
	}
	//if(root+k>=6000000) cout<<root+k<<' '<<l<<' '<<r<<endl;
	int mid=(l+r)>>1;
	build(l,mid,k,L);
	build(mid+1,r,k,R);
	pushdown(root+k);
}
void spread(int root){
	if(tree[root].lazy!=-1e9){
		int op=tree[root].lazy;
		tree[L].lazy=op;
		tree[R].lazy=op;
		tree[L].sum=(tree[L].r-tree[L].l+1)*op;
		tree[R].sum=(tree[R].r-tree[R].l+1)*op;
		tree[root].lazy=-1e9;
	}
}
void update(int root,int l,int r,int k){
	if(l<=TL&&r>=TR){
		tree[root].sum=k;
		tree[root].lazy=k;
		return ;
	}
	spread(root);
	int mid=(TL+TR)>>1;
	if(l<=mid) update(L,l,r,k);
	if(r>mid) update(R,l,r,k);
	pushdown(root);
	//if(TL==1&&TR==2) cout<<root/262150+1<<tree[root].sum<<endl;
}
int chack(int root,int l,int r){
	int ans=0;
	if(l<=TL&&r>=TR){
		return tree[root].sum;
	}
	//if(TL==1&&TR==4) cout<<tree[root].lazy<<' '<<tree[L].sum<<endl;
	spread(root);
	int mid=(TR+TL)>>1;
	if(l<=mid) ans+=chack(L,l,r);
	if(r>mid) ans+=chack(R,l,r);
	pushdown(root);
	return ans;
}
signed main(){
	cin>>n>>kkll>>m;
	for(int i=1;i<=30;i++){
		//cout<<maxx<<endl;
		//printf("%d\n",((i-1)*262150));
		build(1,100000,(i-1)*262150,1);
	}
	build(1,100000,30*262150,1);
	update(30*262150+1,1,100000,1);
	//cout<<"haha";
	while(m--){
		char op;
		int x,y,k;
		cin>>op;
		if(op=='C'){
			//cout<<chack(30*262150+1,1,2)<<endl;
			cin>>x>>y>>k;
			for(int i=1;i<=31;i++){
				update((i-1)*262150+1,x,y,0);
			}
			update((k-1)*262150+1,x,y,1);
			//cout<<chack(30*262150+1,1,2)<<endl;
		} 
		else{
			cin>>x>>y;
			int ans=0;
			for(int i=1;i<=31;i++){
				//printf("%d %d\n",i,chack((i-1)*262150+1,x,y));
				if(chack((i-1)*262150+1,x,y)>0){
					ans++;
					//cout<<i<<endl;
				}
			} 
			cout<<ans<<'\n';
		}
	}
	return 0;
}
2024/12/5 19:57
加载中...