QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#785675#9810. Obliviate, Then ReincarnateTom22lCompile Error//C++171.6kb2024-11-26 18:45:472024-11-26 18:45:47

Judging History

This is the latest submission verdict.

  • [2024-11-26 23:19:26]
  • hack成功,自动添加数据
  • (/hack/1260)
  • [2024-11-26 18:45:47]
  • Judged
  • [2024-11-26 18:45:47]
  • Submitted

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
int Read(){
	int x=0;
	char ch=getchar();bool f=0;
	while(ch<'0'||ch>'9') if(ch=='-')f=1,ch=getchar(); else if(ch==EOF)return 0; else ch=getchar();
	while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
int h[1000005];
int nxt[1000005];
int to[1000005];
int cnt;
int ans[1000005];
void link(int x,int y){
	nxt[++cnt]=h[x];
	h[x]=cnt;
	to[cnt]=y;
	return ;
}
bool vis[500005];
int pth[500005];
int n,m,q;
int dfs(int x,int res){
//	cout<<x<<':'<<endl;
	vis[x]=1;
	for(int i=h[x];i;i=nxt[i]){
		int y=to[i];
		int k=((x+y)%n+n)%n;
//		cout<<y<<' '<<k<<endl;
		if(ans[k]==1){
			ans[x]=1;
			return 1;
		}
		if(ans[k]==res){
			if(pth[k]!=pth[x]+y){
				pth[k]=pth[x]+y;
				ans[k]=1;
				dfs(k,res);
				return 1;
			}
		}
        if(ans[k])continue;
		if(vis[k]){
			if(pth[x]-pth[k]+y){
//				cout<<x<<' '<<k<<' '<<pth[x]<<' '<<pth[k]<<' '<<y<<endl;
				ans[k]=1;ans[x]=1;return 1;
			}else{
				ans[k]=res;
				ans[x]=res;
				continue;
			}
		}
		pth[k]=pth[x]+y;
        int yeu=dfs(x,res);
		if(yeu==1){
			ans[x]=1;return 1;
		}else if(yeu==res) ans[x]=res;
	}ans[x]=(ans[x]?ans[x]:2);
//	cout<<"end";
	return ans[x];
}
int ccnt=3;
signed main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=Read(),m=Read(),q=Read();
	while(m--){
		int x=Read(),y=Read();
		x=(x%n+n)%n;
		link(x,y);
	}
	for(int i=0;i<n;i++){
		if(!ans[i]){
			dfs(i,++ccnt);
		} 
	}while(q--){
		int x=Read();x=(x%n+n)%n;
		if(ans[x]==1) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:76:33: error: ‘ccnt’ was not declared in this scope; did you mean ‘cnt’?
   76 |                         dfs(i,++ccnt);
      |                                 ^~~~
      |                                 cnt