# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
580512 | Vanilla | Werewolf (IOI18_werewolf) | C++17 | 257 ms | 19668 KiB |
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"
using namespace std;
const int maxn = 3e3 + 2;
vector <int> ad [maxn];
bitset <maxn> vis1, vis2;
void dfs1 (int u, int l, int r) {
vis1[u] = 1;
for (int v: ad[u]) {
if (v < l || vis1[v]) continue;
dfs1(v, l, r);
}
}
int dfs2 (int u, int l, int r) {
vis2[u] = 1;
bool b = (vis1[u] && u >= l && u <= r);
for (int v: ad[u]) {
if (v > r || vis2[v]) continue;
b|=dfs2(v, l, r);
}
return b;
}
vector<int> check_validity(int N, vector<int> X, vector<int> Y,
vector<int> S, vector<int> E,
vector<int> L, vector<int> R) {
for (int i = 0; i < X.size(); i++){
ad[X[i]].push_back(Y[i]);
ad[Y[i]].push_back(X[i]);
}
int Q = S.size();
vector<int> A(Q);
for (int i = 0; i < Q; ++i) {
vis1 = vis2 = 0;
dfs1(S[i], L[i], R[i]);
A[i] = dfs2(E[i], L[i], R[i]);
}
return A;
}
Compilation message (stderr)
# | 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... |