QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#797808 | #9810. Obliviate, Then Reincarnate | ucup-team4975 | WA | 0ms | 3808kb | C++14 | 1.7kb | 2024-12-03 18:54:21 | 2024-12-03 18:54:21 |
Judging History
answer
#define LOCAL
#include <bits/stdc++.h>
#define fir first
#define sec second
#define el '\n'
#ifdef LOCAL
#define FINISH cerr << "FINISH" << endl;
#else
#define FINISH ;
#endif
#ifdef LOCAL
#define debug(x) cerr << setw(4) << #x << " == " << x << endl
#else
#define debug(x)
#endif
#ifdef LOCAL
#define debugv(x) \
cerr << setw(4) << #x << ":: "; \
for (auto i : x) \
cerr << i << " "; \
cerr << endl
#else
#define debugv(x)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
ostream& operator<<(ostream& out, PII& x)
{
out << x.fir << " " << x.sec << endl;
return out;
}
const int mod = 998244353;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int N = 200020;
void solve()
{
int n,m,q;
cin>>n>>m>>q;
vector<vector<ll>> G(n+1,vector<ll>());
for(int i=0;i<m;i++){
ll a,b;
cin>>a>>b;
a=((a%n)+n)%n;
if(b!=0)G[a].push_back(b);
}
vector<bool> ans(n,0);
vector<int> vis(n,0);
function<bool(ll,ll)> dfs=[&](ll x,ll d){
if(vis[x]==1){
return (bool)ans[x];
}
else if(vis[x]==2){
if(d!=x)return true;
else return false;
}
vis[x]=2;
bool res=false;
for(ll y:G[x]){
res|=dfs((((x+d)%n)+n)%n,x+d);
}
vis[x]=1;
ans[x]=res;
return res;
};
for(int i=0;i<n;i++)dfs(i,i);
while(q--){
ll x;
cin>>x;
x=((x%n)+n)%n;
if(ans[x])cout<<"Yes\n";
else cout<<"No\n";
}
return;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int T = 1;
//cin >> T;
while (T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3576kb
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: 3580kb
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: 0ms
memory: 3808kb
input:
1 1 1 0 1000000000 -1000000000
output:
No
result:
wrong answer 1st words differ - expected: 'Yes', found: 'No'