QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#793326#9810. Obliviate, Then ReincarnateLittleXi#WA 2ms9988kbC++201.4kb2024-11-29 18:41:222024-11-29 18:41:24

Judging History

This is the latest submission verdict.

  • [2024-11-29 18:41:24]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 9988kb
  • [2024-11-29 18:41:22]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rof(i,a,b) for(int i=(a);i>=(b);i--)
#define wln putchar('\n')
#define pii pair<int,int>
#define ll long long
const int N=500005,B=19;
int n,m,q;
int fa[N],dfn[N],low[N],now,sta[N],top,col[N],ccnt;
ll dis[N];
bool insta[N],f[N];
vector<pii> e[N];
void tarjan(int x)
{
    dfn[x]=low[x]=++now;
    sta[++top]=x;
    insta[x]=1;
    for(auto [y,z]:e[x])
        if(!dfn[y])
        {
            fa[y]=x;
            dis[y]=dis[x]+1;
            tarjan(y);
            low[x]=min(low[x],low[y]);
            f[x]|=f[y];
        }
        else if(insta[y])
        {
            low[x]=min(low[x],sta[y]);
            if(dis[x]-dis[y]+z!=0)f[x]=1;
        }
    if(low[x]==dfn[x])
    {
        while(sta[top]!=x)
        {
            insta[sta[top]]=0;
            top--;
        }
        insta[x]=0;
        top--;
    }
}
int main()
{
    scanf("%d%d%d",&n,&m,&q);
    For(i,1,m)
    {
        int x,y,z;
        scanf("%d%d",&x,&z);
        y=x+z;
        x=(x%n+n)%n;
        y=(y%n+n)%n;
        e[x].push_back({y,z});
    }
    For(i,0,n-1)
        if(!dfn[i])tarjan(i);
    For(i,1,q)
    {
        int x;
        scanf("%d",&x);
        x=(x%n+n)%n;
        if(f[x])printf("Yes\n");
        else printf("No\n");
    }
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 9988kb

input:

3 2 3
1 1
-1 3
1
2
3

output:

Yes
Yes
No

result:

ok 3 tokens

Test #2:

score: 0
Accepted
time: 1ms
memory: 7916kb

input:

3 2 3
1 1
-1 0
1
2
3

output:

No
No
No

result:

ok 3 tokens

Test #3:

score: 0
Accepted
time: 0ms
memory: 7860kb

input:

1 1 1
0 1000000000
-1000000000

output:

Yes

result:

ok "Yes"

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 8004kb

input:

3 2 3
0 1000000000
1 -1000000000
-1000000000
0
-1000000000

output:

No
Yes
No

result:

wrong answer 2nd words differ - expected: 'No', found: 'Yes'