| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 500161 | aymanrs | Werewolf (IOI18_werewolf) | C++14 | 4035 ms | 43524 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;
struct node {
int id;
list<node*> l;
bool v;
};
vector<node> g;
void wolf(node*n, int r, bool w[]){
w[n->id] = true;
for(node* c : n->l){
if(!w[c->id] && c->id <= r) wolf(c, r, w);
}
}
bool human(node* n, int l, bool w[], int r){
n->v = true;
for(node* c : n->l){
if(w[c->id] && (c->id >= l || n->id <= r)) return true;
if(!c->v && c->id >= l && human(c, l, w, r)) return true;
}
return false;
}
vector<int> check_validity(int N, vector<int> X, vector<int> Y, vector<int> S, vector<int> E, vector<int> L, vector<int> R){
g.resize(N);
for(int i = 0;i < N;i++) g[i].id=i;
for(int i = 0;i < X.size();i++){
g[X[i]].l.push_back(&g[Y[i]]);
g[Y[i]].l.push_back(&g[X[i]]);
}
vector<int> ans(S.size(), 0);
for(int i = 0;i < S.size();i++){
for(int j = 0;j < N;j++) g[i].v = false;
bool w[N] = {false};
wolf(&g[E[i]], R[i], w);
if(human(&g[S[i]], L[i], w, R[i])) ans[i] = 1;
}
return ans;
}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... | ||||
