QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#795877 | #9810. Obliviate, Then Reincarnate | ucup-team1134# | WA | 2ms | 3844kb | C++23 | 2.2kb | 2024-12-01 03:10:56 | 2024-12-01 03:10:58 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vvii vector<vector<pair<int,int>>>
#define vvll vector<vector<pair<ll,ll>>>
#define vst vector<string>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define mkunique(x) sort(all(x));(x).erase(unique(all(x)),(x).end())
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=500005,INF=15<<26;
vi G[MAX],rG[MAX];
bool ok[MAX];
int main(){
std::ifstream in("text.txt");
std::cin.rdbuf(in.rdbuf());
cin.tie(0);
ios::sync_with_stdio(false);
ll N,M,Q;cin>>N>>M>>Q;
vi indeg(N);
for(int i=0;i<M;i++){
ll a,b;cin>>a>>b;
a%=N;
if(a<0) a+=N;
if(b==0) continue;
b=(a+b)%N;
if(b<0) b+=N;
G[a].pb(b);
rG[b].pb(a);
indeg[b]++;
}
{
queue<int> Q;
for(int i=0;i<N;i++){
if(indeg[i]==0) Q.push(i);
}
while(!Q.empty()){
int u=Q.front();Q.pop();
for(int to:G[u]){
if(indeg[to]){
indeg[to]--;
if(indeg[to]==0) Q.push(to);
}
}
}
for(int i=0;i<N;i++){
if(indeg[i]){
ok[i]=true;
Q.push(i);
}
}
while(!Q.empty()){
int u=Q.front();Q.pop();
for(int to:rG[u]){
if(!ok[to]){
ok[to]=true;
Q.push(to);
}
}
}
}
while(Q--){
ll x;cin>>x;
x%=N;
if(x<0) x+=N;
if(ok[x]) cout<<"Yes\n";
else cout<<"No\n";
}
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3844kb
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: 3608kb
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: 3504kb
input:
1 1 1 0 1000000000 -1000000000
output:
Yes
result:
ok "Yes"
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3540kb
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'