QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#797810 | #9810. Obliviate, Then Reincarnate | ucup-team4975 | WA | 0ms | 3808kb | C++14 | 1.7kb | 2024-12-03 18:57:47 | 2024-12-03 18:57:48 |
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+y)%n)+n)%n,x+y);
}
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;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
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: 3808kb
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: 0ms
memory: 3804kb
input:
1 1 1 0 1000000000 -1000000000
output:
Yes
result:
ok "Yes"
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3616kb
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'