QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#840276 | #9810. Obliviate, Then Reincarnate | frankly6# | WA | 1ms | 5672kb | C++17 | 986b | 2025-01-02 16:48:16 | 2025-01-02 16:48:16 |
Judging History
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();
x=(x%N+N)%N;
if(ring[find(x)]) cout << "Yes\n";
else cout << "No\n";
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
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: 3544kb
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: 1ms
memory: 5672kb
input:
1 1 1 0 1000000000 -1000000000
output:
Yes
result:
ok "Yes"
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 5588kb
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'