QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#885324#9810. Obliviate, Then Reincarnatewol_qwqCompile Error//C++201.5kb2025-02-06 15:16:152025-02-06 15:16:18

Judging History

This is the latest submission verdict.

  • [2025-02-06 15:16:18]
  • Judged
  • [2025-02-06 15:16:15]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+5;
struct edge{
	int to,nxt,w;
}e[maxn];
int n,m,q,cnt,head[maxn],dfn[maxn],tot,low[maxn],dep[maxn];
bool ans[maxn],vis[maxn];
void add(int u,int v,int w){
//	cout<<u<<" "<<v<<" "<<w<<"\n";
	e[++cnt].nxt=head[u];
	head[u]=cnt;
	e[cnt].to=v;
	e[cnt].w=w;
}
stack<int>stk;
void tarjan(int x){
	dfn[x]=low[x]=tot++;
	vis[x]=1;
	stk.push(x);
	for(int i=head[x];i;i=e[i].nxt){
		if(dfn[e[i].to]==-1){
			dep[e[i].to]=dep[x]+e[i].w;
			tarjan(e[i].to);
			low[x]=min(low[x],low[e[i].to]);
		} 
		else if(vis[e[i].to]){
			if(dep[x]-dep[e[i].to]+e[i].w){
//				cerr<<"tmp\n";
				ans[x]=1;
			}
			low[x]=min(low[x],dfn[e[i].to]);
		}
		ans[x]|=ans[e[i].to];
	}
	if(dfn[x]==low[x]){
		bool flag=ans[x];
		queue<int>p,tmp;
		while(stk.top()!=x) {
			p.push(stk.top());
			flag|=ans[stk.top()];
			vis[stk.top()]=0;
			stk.pop();
		}
		while(!p.empty()){
			tmp.push(p.front());
			ans[p.front()]=flag;
			p.pop();
		}
		while(!tmp.empty()){
			p.push(tmp.front());
			tmpp.pop();
		}
		vis[x]=0;
		stk.pop();
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	memset(dfn,-1,sizeof(dfn));
	memset(low,-1,sizeof(low));
	cin>>n>>m>>q;
	for(int i=1;i<=m;i++){
		int x,y;
		cin>>x>>y;
		x=(x%n+n)%n;
		add(x,((x+y)%n+n)%n,y);
	}
	for(int i=0;i<n;i++){	
		if(dfn[i]==-1){
			tarjan(i);
		}
	}
	while(q--){
		int x;
		cin>>x;
		x=(x%n+n)%n;
		cout<<(ans[x]?"Yes\n":"No\n");
	}
	return 0;
}

詳細信息

answer.code: In function ‘void tarjan(int)’:
answer.code:52:25: error: ‘tmpp’ was not declared in this scope; did you mean ‘tmp’?
   52 |                         tmpp.pop();
      |                         ^~~~
      |                         tmp