QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#232150#6608. Descent of Dragonsgrass8cowCompile Error//C++141.5kb2023-10-29 22:31:122023-10-29 22:31:13

Judging History

你现在查看的是最新测评结果

  • [2023-10-29 22:31:13]
  • 评测
  • [2023-10-29 22:31:12]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,q,a[500100],B,is[500100],L[810],R[810];
vector<int>g[810];
int mx[810];
#define pb push_back
int fa[500010],ab[501000],wh[501000];
int F(int x){
	if(x==fa[x])return x;
	return fa[x]=F(fa[x]);
}
void cg(int e){
	if(g[e].empty())return;
	for(int i=L[e];i<=R[e];i++){
		if(!ab[a[i]])ab[a[i]]=i,fa[i]=i,wh[i]=a[i];
		else fa[i]=ab[a[i]];
	}
	for(int x:g[e]){
		if(ab[x]&&ab[x+1])fa[ab[x]]=ab[x+1],ab[x]=0;
		else if(ab[x])ab[x+1]=ab[x],ab[x]=0,wh[ab[x+1]]=x+1;
	}
	for(int i=L[e];i<=R[e];i++)a[i]=wh[F(i)];
	for(int i=L[e];i<=R[e];i++)ab[wh[i]]=0;
g[i].clear();
}
int main(){
	scanf("%d%d",&n,&q);B=sqrt(n);
	for(int i=1;i<=n;i++)is[i]=(i-1)/B+1;
	for(int i=1;i<=is[n];i++){
		L[i]=(i-1)*B+1,R[i]=min(n,i*B);
	}
	for(int ii=1,ty,l,r,z;ii<=q;ii++){
		scanf("%d%d%d",&ty,&l,&r);
		int lp=is[l],rp=is[r];
		cg(lp);if(lp<rp)cg(rp);
		if(ty==1){
			scanf("%d",&z);
			if(lp!=rp){
				for(int i=l;i<=R[lp];i++)if(a[i]==z)a[i]=z+1,mx[lp]=max(mx[lp],z+1);
				for(int i=L[rp];i<=r;i++)if(a[i]==z)a[i]=z+1,mx[rp]=max(mx[rp],z+1);
			}
			else{for(int i=l;i<=r;i++)if(a[i]==z)a[i]=z+1,mx[lp]=max(mx[lp],z+1);}
			for(int i=lp+1;i<rp;i++){
				g[i].pb(z);
				if(mx[i]==z)mx[i]=z+1;
			}
		}
		else{
			int ans=0;
			if(lp!=rp){
				for(int i=l;i<=R[lp];i++)ans=max(ans,a[i]);
				for(int i=L[rp];i<=r;i++)ans=max(ans,a[i]);
			}
			else{for(int i=l;i<=r;i++)ans=max(ans,a[i]);}
			for(int i=lp+1;i<rp;i++)ans=max(ans,mx[i]);
			printf("%d\n",ans);
		}
	}
	return 0;
}

Details

answer.code: In function ‘void cg(int)’:
answer.code:24:3: error: ‘i’ was not declared in this scope
   24 | g[i].clear();
      |   ^
answer.code: In function ‘int main()’:
answer.code:27:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   27 |         scanf("%d%d",&n,&q);B=sqrt(n);
      |         ~~~~~^~~~~~~~~~~~~~
answer.code:33:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   33 |                 scanf("%d%d%d",&ty,&l,&r);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~
answer.code:37:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   37 |                         scanf("%d",&z);
      |                         ~~~~~^~~~~~~~~