QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#885612 | #9810. Obliviate, Then Reincarnate | furrywolf | WA | 1ms | 5864kb | C++20 | 1.4kb | 2025-02-06 16:36:31 | 2025-02-06 16:36:31 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define R register int
#define if(x) if(__builtin_expect(x,1))
#define while(x) while(__builtin_expect(x,1))
using namespace std;
const int N=5e5+1;
int n,m,q;
struct node{int to,nxt,w;}e[N];
int head[N],dfn[N],low[N],tot,ts,dep[N];
bool vis[N],ans[N];stack<int>s;
void add(int u,int v,int w){e[++tot]={v,head[u],w};head[u]=tot;}
void tarjan(int u){
dfn[u]=low[u]=++ts;s.push(u);vis[u]=1;
for(R i=head[u]; i; i=e[i].nxt){
int v=e[i].to;
if(!dfn[v])dep[v]=dep[u]+e[i].w,tarjan(v),low[u]=min(low[u],low[v]);
else if(vis[v]){
if(dep[v]-dep[u]+e[i].w)ans[u]=1;
low[u]=min(low[u],dfn[v]);
}
}
if(low[u]==dfn[u]){
vector<int>v;v.clear();
int now=ans[u];
while(s.top()!=u){
vis[s.top()]=0;
v.push_back(s.top());
now|=ans[s.top()];
s.pop();
}
ans[u]=now;s.pop();
for(auto i:v)ans[i]=now;
}
}
int main(){
#ifdef ONLINE_JUDGE
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
#endif
cin>>n>>m>>q;
for(R i=1,u,v; i<=m; i++)
cin>>u>>v,add(u,((u+v)%n+n)%n,v);
for(R i=1; i<=n; i++)
if(!dfn[i])tarjan(i);
while(q--){
int x;cin>>x;
cout<<(ans[x]?"Yes":"No")<<'\n';
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5864kb
input:
3 2 3 1 1 -1 3 1 2 3
output:
No No No
result:
wrong answer 1st words differ - expected: 'Yes', found: 'No'