QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#795045 | #9810. Obliviate, Then Reincarnate | ucup-team3670# | WA | 1ms | 3684kb | C++20 | 1.4kb | 2024-11-30 17:36:39 | 2024-11-30 17:36:40 |
Judging History
answer
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
using namespace std;
const int N = 500043;
bool used[N];
int comp[N];
vector<int> g[N];
vector<int> order;
vector<int> gt[N];
bool source[N];
bool used2[N];
void dfs1(int x)
{
used[x] = true;
for(auto y : g[x]) if(!used[y]) dfs1(y);
order.push_back(x);
}
void dfs2(int x, int c)
{
comp[x] = c;
for(auto y : gt[x])
if(comp[y] == 0)
dfs2(y, c);
}
void dfs3(int x)
{
if(used2[x]) return;
used2[x] = true;
for(auto y : gt[x])
dfs3(y);
}
int main(){
#ifdef _DEBUG
freopen("input.txt", "r", stdin);
#endif
cin.tie(0);
ios::sync_with_stdio(false);
int n, m, q;
cin >> n >> m >> q;
forn(i, m)
{
int a, b;
cin >> a >> b;
if(b == 0) continue;
int aa = (a % n + n) % n;
int bb = ((aa + b) % n + n) % n;
g[aa].push_back(bb);
gt[bb].push_back(aa);
//cout << aa << " " << bb << endl;
}
forn(i, n) if(!used[i]) dfs1(i);
reverse(order.begin(), order.end());
int cc = 0;
for(auto x : order) if(comp[x] == 0) dfs2(x, ++cc);
for(int i = 1; i <= cc; i++) source[i] = true;
forn(i, n) for(auto j : g[i]) if(comp[i] == comp[j]) dfs3(i);
forn(i, q)
{
int x;
cin >> x;
int v = (x % n + n) % n;
if(used2[v])
cout << "Yes\n";
else cout << "No\n";
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3628kb
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: 3676kb
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: 3672kb
input:
1 1 1 0 1000000000 -1000000000
output:
Yes
result:
ok "Yes"
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 3684kb
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'