# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
289656 | DanerZein | Werewolf (IOI18_werewolf) | C++14 | 4059 ms | 34952 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>
using namespace std;
typedef vector<int> vi;
int l,r;
bitset<200010> vh,vw;
vector<vi> G;
void dfs_human(int u){
if(u<l) return;
vh[u]=1;
for(auto &v:G[u]){
if(!vh[v]){
dfs_human(v);
}
}
}
void dfs_wolf(int u){
if(u>r) return;
vw[u]=1;
for(auto &v:G[u]){
if(!vw[v]){
dfs_wolf(v);
}
}
}
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+1);
for(int i=0;i<X.size();i++){
int u=X[i],v=Y[i];
G[u].push_back(v);
G[v].push_back(u);
}
vector<int> res;
for(int i=0;i<S.size();i++){
l=L[i];
r=R[i];
vh.reset();
vw.reset();
dfs_human(S[i]);
dfs_wolf(E[i]);
bool sw=0;
for(int i=0;i<N;i++){
if(vh[i]==1 and vw[i]==1){
sw=1;
break;
}
}
res.push_back(sw);
}
return res;
}
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... |