QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#805327 | #9810. Obliviate, Then Reincarnate | ucup-team3691# | WA | 0ms | 17148kb | C++14 | 2.1kb | 2024-12-08 15:42:17 | 2024-12-08 15:42:18 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
using ll = long long;
using ull = unsigned long long;
string to_string(const string &s) {
return '"' + s + '"';
}
string to_string(bool b) {
return b ? "true" : "false";
}
template <typename A, typename B>
string to_string(const pair<A, B> &p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename T>
string to_string(const T &v) {
string s = "{";
bool first = true;
for (const auto &it : v) {
if (!first)
s += ", ";
else
first = false;
s += to_string(it);
}
return s += "}";
}
void debug_out() {
cerr << endl;
}
template <typename T, typename... Args>
void debug_out(const T &first, const Args&... rest) {
cerr << to_string(first) << " ";
debug_out(rest...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
auto startTime = high_resolution_clock::now();
int get_time() {
auto stopTime = chrono::high_resolution_clock::now();
auto duration = duration_cast<milliseconds>(stopTime - startTime);
return duration.count(); // in ms
}
const int DIM = 5e5 + 5;
bool cyc[DIM];
int viz[DIM];
vector<int> v[DIM];
void dfs(int nod) {
viz[nod] = 1;
for (auto it : v[nod]) {
if (!viz[it])
dfs(it);
if (cyc[it] || (viz[it] == 1)) {
cyc[nod] = true;
}
}
viz[nod] = 2;
}
void solve() {
int n, m, q;
cin >> n >> m >> q;
for (int i = 1; i <= m; ++i) {
int a, b;
cin >> a >> b;
if (b == 0)
continue;
a = (a % n + n) % n;
b = (a + b % n + n) % n;
v[a].push_back(b);
}
for (int i = 1; i <= n; ++i) {
if (!viz[i])
dfs(i);
}
for (int i = 1; i <= q; ++i) {
int x;
cin >> x;
x = (x % n + n) % n;
if (cyc[x]) {
cout << "Yes\n";
} else {
cout << "No\n";
}
}
}
int main() {
cin.tie(NULL);
ios_base::sync_with_stdio(false);
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: 17148kb
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: 16724kb
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: 15556kb
input:
1 1 1 0 1000000000 -1000000000
output:
No
result:
wrong answer 1st words differ - expected: 'Yes', found: 'No'