# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
295619 | zoooma13 | Werewolf (IOI18_werewolf) | C++14 | 294 ms | 43512 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;
vector <vector <int>> adj;
vector <int> a ,pos;
int gt(int u ,int p=-1){
a.push_back(u);
if(adj[u].size() == 1 && ~p)
return u;
if(adj[u][0] != p)
return gt(adj[u][0] ,u);
return gt(adj[u][1] ,u);
}
int getlastzero(int l ,int r ,int q){
for(int i=r; i>=l; i--) if(a[i] < q)
return i;
return -1;
}
int getfirsttwo(int l ,int r ,int q){
for(int i=l; i<=r; i++) if(a[i] > q)
return i;
return -1;
}
int ex ,pl ,pr;
bool vis[2][3000];
bool go(int u ,bool st=0){
vis[st][u] = 1;
if(pl <= u && u <= pr && ~st && !vis[1][u] && go(u ,1))
return 1;
if(st && u > pr) return 0;
if(!st && u < pl) return 0;
if(u == ex) return 1;
vis[st][u] = 1;
for(int&v : adj[u]) if(!vis[st][v] && go(v ,st))
return 1;
return 0;
}
vector<int> check_validity(int N, vector<int> X, vector<int> Y,vector<int> S, vector<int> E,vector<int> L, vector<int> R) {
adj.resize(N);
for(int i=0; i<X.size(); i++){
adj[X[i]].push_back(Y[i]);
adj[Y[i]].push_back(X[i]);
}
vector <int> ret(R.size());
for(int q = 0; q < R.size(); q++){
ex = E[q] ,pl = L[q] ,pr = R[q];
memset(vis ,0 ,sizeof vis);
ret[q] = go(S[q]);
}
return ret;
}
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... |