QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#780110#9810. Obliviate, Then ReincarnatecuongsonWA 0ms17892kbC++201.5kb2024-11-25 01:16:372024-11-25 01:16:37

Judging History

This is the latest submission verdict.

  • [2024-11-26 23:19:26]
  • hack成功,自动添加数据
  • (/hack/1260)
  • [2024-11-25 01:16:37]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 17892kb
  • [2024-11-25 01:16:37]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define fuck cout<<"fuck\n";
const int N=1e6+10;
int n,m,q;
int cnt,head[N],nxt[N],to[N],val[N];
int num,dfn[N],low[N];
int tp,stk[N],ins[N];
int c[N];
int f[N],dis[N];

void add(int u,int v,int w){
    nxt[++cnt]=head[u];
    head[u]=cnt;
    to[cnt]=v;
    val[cnt]=w;
}


void tarjan(int u){
    
    dfn[u]=low[u]=++num;
    stk[++tp]=u,ins[u]=1;
    for(int i=head[u];i;i=nxt[i]){
        int v=to[i];
        // f[u]=max(f[u],f[v]);
        if(!dfn[v]){
            dis[v]=dis[u]+val[i];
            tarjan(v);
            low[u]=min(low[u],low[v]);
        }
        else if(ins[v]){
            low[u]=min(low[u],dfn[v]);
            if(dis[v]!=dis[u]+val[i])   f[u]=1;
        }
        f[u]=max(f[u],f[v]);
    }
    if(dfn[u]==low[u]){
        int y;
        do{
            y=stk[tp--],ins[y]=0;
            f[y]=max(f[y],f[u]);
        }while(u!=y);
    }
}
void solve(){
    // cout<<"fuck\n";
    cin>>n>>m>>q;
    for(int i=1;i<=m;++i){
        int x,y,u,v;
        cin>>x>>y;
        u=(x%n+n-1)%n+1;
        v=((x+y)%n+n-1)%n+1;
        add(u,v,y);
    }    
    for(int i=1;i<=n;++i){
        if(!dfn[i]) tarjan(i);
    }
    // cout<<"fuck\n";
    while(q--){
        int x;
        cin>>x;
        x=(x%n+n-1)%n;
        cout<<(f[x]?"Yes":"No")<<'\n';
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T=1;
    // cin>>T;
    while(T--)  solve();
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 17892kb

input:

3 2 3
1 1
-1 3
1
2
3

output:

No
Yes
Yes

result:

wrong answer 1st words differ - expected: 'Yes', found: 'No'