QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#885612#9810. Obliviate, Then ReincarnatefurrywolfWA 1ms5864kbC++201.4kb2025-02-06 16:36:312025-02-06 16:36:31

Judging History

This is the latest submission verdict.

  • [2025-02-06 16:36:31]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 5864kb
  • [2025-02-06 16:36:31]
  • Submitted

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'