This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bits/extc++.h"
using namespace std;
template <typename T>
void dbgh(const T& t) {
cerr << t << endl;
}
template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
cerr << t << " | ";
dbgh(u...);
}
#ifdef DEBUG
#define dbg(...) \
cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]: "; \
dbgh(__VA_ARGS__);
#else
#define dbg(...)
#define cerr \
if (false) \
cerr
#endif
using vi = vector<int>;
#define endl "\n"
#define long int64_t
#define sz(x) int((x).size())
vi check_validity(int n, vi us, vi vs, vi qsrc, vi qdest, vi ql, vi qr) {
int m = sz(us), q = sz(qsrc);
if (n <= 3000 && m <= 6000 && q <= 3000) {
vector<int> graph[n];
for (int i = 0; i < m; i++) {
graph[us[i]].push_back(vs[i]);
graph[vs[i]].push_back(us[i]);
}
vector<int> ans(q);
for (int qi = 0; qi < q; qi++) {
int src = qsrc[qi], dest = qdest[qi], l = ql[qi], r = qr[qi];
bool vis[n][2] {};
vector<pair<int, int>> q;
auto push = [&](int u, int t) -> void {
if (!vis[u][t]) {
vis[u][t] = true;
q.emplace_back(u, t);
}
};
push(src, 0);
while (sz(q)) {
auto [u, t] = q.back();
q.pop_back();
if (l <= u && u <= r && !t) {
push(u, 1);
}
for (auto& v : graph[u]) {
if ((!t && v >= l) || (t && v <= r)) {
push(v, t);
}
}
}
ans[qi] = vis[dest][1];
}
return ans;
}
}
Compilation message (stderr)
werewolf.cpp: In function 'vi check_validity(int, vi, vi, vi, vi, vi, vi)':
werewolf.cpp:69:1: warning: control reaches end of non-void function [-Wreturn-type]
69 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |