QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#840275#9810. Obliviate, Then Reincarnatefrankly6#RE 0ms3572kbC++171003b2025-01-02 16:47:012025-01-02 16:47:02

Judging History

This is the latest submission verdict.

  • [2025-01-02 16:47:02]
  • Judged
  • Verdict: RE
  • Time: 0ms
  • Memory: 3572kb
  • [2025-01-02 16:47:01]
  • Submitted

answer

#include<iostream>
#include<cstdio>
using namespace std;
const int MX=500050;

int T, N, M, Q;
int fa[MX];
bool ring[MX];
int read()
{
    int r=0, f=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') {r=r*10+ch-'0'; ch=getchar();}
    return r*f;
}
int find(int x){return x==fa[x]?x:fa[x]=find(fa[x]);}
void merge(int x, int y)
{
    x=find(x); y=find(y);
    if(x==y) ring[y]=1;
    fa[x]=y;
}
int main()
{
    // freopen("testdata.in","r",stdin);
    N=read(); M=read(); Q=read();
    for(int i=1;i<=N;i++) fa[i]=i;
    for(int i=1;i<=M;i++)
    {
        int a=read(), b=read();
        // cout << "a=" << a << ", b=" << b << '\n';
        a=(a%N+N)%N;
        if(b==0) continue;
        int to=((a+b)%N+N)%N;
        merge(a,to);
    }
    while(Q--)
    {
        int x=read();
        // cout << "x=" << x << '\n';
        if(ring[find(x)]) cout << "Yes\n";
        else cout << "No\n";
    }
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3568kb

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: 0ms
memory: 3572kb

input:

3 2 3
1 1
-1 0
1
2
3

output:

No
No
No

result:

ok 3 tokens

Test #3:

score: -100
Runtime Error

input:

1 1 1
0 1000000000
-1000000000

output:


result: