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/stdc++.h>
#include "werewolf.h"
// #include "grader.cpp"
#define pb push_back
using namespace std;
const int N = 6e3 + 7;
int was[N];
int used[N];
vector < int > gr[N];
int l, r;
int n;
void dfs1(int v, int pr) {
was[v]++;
used[v] = 1;
for (int to : gr[v]) {
if (!used[to] && to >= l) dfs1(to, v);
}
}
void dfs2(int v, int pr) {
was[v]++;
used[v] = 1;
for (int to : gr[v]) {
if (!used[to] && to <= r) dfs2(to, v);
}
}
vector < int > check_validity(int N, vector < int > X, vector < int > Y, vector < int > S, vector < int > E, vector < int > L, vector < int > R) {
n = N;
for (int i = 0; i < (int)X.size(); i++) {
gr[X[i]].pb(Y[i]);
gr[Y[i]].pb(X[i]);
}
vector < int > ans;
int q = S.size();
for (int i = 0; i < q; i++) {
l = L[i];
r = R[i];
memset(was, 0, sizeof was);
dfs1(S[i], S[i]);
memset(used, 0, sizeof used);
dfs2(E[i], E[i]);
memset(used, 0, sizeof used);
int ok = 1;
for (int j = l; j <= r; j++) {
if (was[j] == 2) {
ans.pb(1);
ok = 0;
break;
}
}
if (ok) {
ans.pb(0);
}
}
return ans;
}
# | 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... |