QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#785630#9810. Obliviate, Then ReincarnateTom22lCompile Error//C++171.6kb2024-11-26 18:37:352024-11-26 18:37:36

Judging History

This is the latest submission verdict.

  • [2024-11-26 23:19:26]
  • hack成功,自动添加数据
  • (/hack/1260)
  • [2024-11-26 18:37:36]
  • Judged
  • [2024-11-26 18:37:35]
  • 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);
		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;
}

Details

answer.code: In function ‘long long int dfs(long long int, long long int)’:
answer.code:35:43: error: expected ‘)’ before ‘!’ token
   35 |                 }if(ans[k]==res){if(pth[k]!=pth[x]+y){pth[k]=pth[x]+y;ans[k]=1;dfs(k,res);return 1;}}
      |                                    ~      ^
      |                                           )
answer.code:35:78: error: expected ‘;’ before ‘=1’
   35 |                 }if(ans[k]==res){if(pth[k]!=pth[x]+y){pth[k]=pth[x]+y;ans[k]=1;dfs(k,res);return 1;}}
      |                                                                              ^~~
      |                                                                              ;
answer.code:41:37: error: expected ‘;’ before ‘=res’
   41 |                         }else{ans[k]=res;ans[x]=res;continue;}
      |                                     ^~~~~
      |                                     ;
answer.code:45:20: error: ‘yeu’ was not declared in this scope
   45 |                 if(yeu==1){
      |                    ^~~
answer.code: In function ‘int main()’:
answer.code:64:33: error: ‘ccnt’ was not declared in this scope; did you mean ‘cnt’?
   64 |                         dfs(i,++ccnt);
      |                                 ^~~~
      |                                 cnt