# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
413140 | schse | Werewolf (IOI18_werewolf) | C++14 | 4053 ms | 33184 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 "werewolf.h"
#include <bits/stdc++.h>
#ifndef EVAL
#include "grader.cpp"
#endif
using namespace std;
struct node
{
bool human = false;
bool wolf = false;
vector<int> edges;
};
vector<node> g;
void humanfdfs(int n, int l)
{
if (n < l || g[n].human)
return;
g[n].human = true;
for (auto i : g[n].edges)
{
humanfdfs(i, l);
}
}
bool wolfdfs(int n, int r)
{
if (n > r || g[n].wolf)
return false;
g[n].wolf = true;
if (g[n].wolf && g[n].human)
return true;
for (auto i : g[n].edges)
{
if (wolfdfs(i, r))
return true;
}
return false;
}
std::vector<int> check_validity(int N, std::vector<int> X, std::vector<int> Y,
std::vector<int> S, std::vector<int> E,
std::vector<int> L, std::vector<int> R)
{
g.resize(N);
for (int i = 0; i < X.size(); i++)
{
g[X[i]].edges.push_back(Y[i]);
g[Y[i]].edges.push_back(X[i]);
}
vector<int> out;
for (int i = 0; i < S.size(); i++)
{
humanfdfs(S[i], L[i]);
out.push_back(wolfdfs(E[i], R[i]));
for (int e = 0; e < N; e++)
g[e].wolf = g[e].human = false;
}
return out;
}
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... |