QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#784235 | #9810. Obliviate, Then Reincarnate | Tom22l | WA | 1ms | 5824kb | C++17 | 1.1kb | 2024-11-26 14:13:57 | 2024-11-26 14:14:00 |
Judging History
This is the latest submission verdict.
- [2024-11-26 23:19:26]
- hack成功,自动添加数据
- (/hack/1260)
- [2024-11-26 14:13:57]
- Submitted
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
int Read(){
int x=0;
char ch=getchar();bool f=0;
while(ch<'0'||ch>'9') if(ch=='-')f=1,ch=getchar(); else if(ch==EOF)return 0; else ch=getchar();
while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
return f?-x:x;
}
int h[500003];
int nxt[500005];
int to[500005];
int cnt;
int ans[500005];
void link(int x,int y){
nxt[++cnt]=h[x];
h[x]=cnt;
to[cnt]=y;
return ;
}
bool vis[500005];
int pth[500005];
int n,m,q;
bool dfs(int x){
vis[x]=1;
for(int i=h[x];i;i=nxt[i]){
int y=to[i];
int k=((x+y)%n+n)%n;
if(vis[k]){
if(pth[x]-pth[k]+y){
ans[k]=1;ans[x]=1;return 1;
}else continue;
}if(dfs(k)){
ans[x]=1;return 1;
}
}ans[x]=2;
return 0;
}
signed main(){
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
n=Read(),m=Read(),q=Read();
while(m--){
int x=Read(),y=Read();
x=(x%n+n)%n;
link(x,y);
}
for(int i=1;i<=n;i++){
if(!ans[i]){
dfs(i);
}
}while(q--){
int x=Read();x=(x%n+n)%n;
if(ans[x]==1) printf("Yes\n");
else printf("No\n");
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5696kb
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: 5760kb
input:
3 2 3 1 1 -1 0 1 2 3
output:
No No No
result:
ok 3 tokens
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 5824kb
input:
1 1 1 0 1000000000 -1000000000
output:
No
result:
wrong answer 1st words differ - expected: 'Yes', found: 'No'