QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#789377 | #9810. Obliviate, Then Reincarnate | jdyt11 | WA | 4ms | 11764kb | C++23 | 1.7kb | 2024-11-27 20:05:52 | 2024-11-27 20:05:57 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ll long long
#define inf 0x3f3f3f3f
#define ull unsigned long long
#define pll pair<ll,ll>
#define ls d*2
#define rs d*2+1
#define mid (l+r)/2
#define lowbit(x) (x&(-x))
//#define endl "\n"
#define all(x) x.begin(),x.end()
#define int long long
//mt19937 seed;
//uniform_int_distribution<int>num(0,2e9);
const int N=1e6+10;
const int M=33;
int n,m,q;
vector<pii>e[N];
vector<int>scc[N];
int cnt,id[N];
bool insta[N];
stack<int>s;
int low[N],dfn[N],dep;
bool is[N],ans[N];
int dis[N];
int dp[N];
void tarjan(int u){
dfn[u]=low[u]=++dep;
s.push(u);
insta[u]=1;
for(auto [v,w]:e[u]){
if(!dfn[v]){
dis[v]=dis[u]+w;
tarjan(v);
low[u]=min(low[u],low[v]);
}
else if(insta[v]){
low[u]=min(low[u],dfn[v]);
if(dis[v]!=dis[u]+w)dp[v]=1;
}
dp[u]|=dp[v];
}
if(dfn[u]==low[u]){
int y;
cnt++;
int tot=0;
while(1){
y=s.top();
s.pop();
insta[y]=0;
tot++;
id[y]=cnt;
dp[y]|=dp[u];
if(u==y)break;
}
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int _=1;//cin>>_;
while(_--){
cin>>n>>m>>q;
int temp=1e10;
for(int i=0;i<m;i++){
int a,b;
cin>>a>>b;
if(b==0)continue;
int u=a+temp*n;
u%=n;
if(u==0)u=n;
int v=a+b+temp*n;
v%=n;
if(v==0)v=n;
if(u==v){
is[u]=1;
continue;
}
e[u].push_back({v,b});
}
for(int i=1;i<=n;i++)if(!dfn[i])tarjan(i);
while(q--){
int x;
cin>>x;
x=x+temp*n;
x%=n;
if(x==0)x=n;
if(dp[x])cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 4ms
memory: 11764kb
input:
3 2 3 1 1 -1 3 1 2 3
output:
No No No
result:
wrong answer 1st words differ - expected: 'Yes', found: 'No'