# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
82515 | farukkastamonuda | Werewolf (IOI18_werewolf) | C++14 | 0 ms | 0 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>
#define fi first
#define se second
#define lo long long
#define inf 1000000009
#define md 1000000007
#define li 200005
#define mp make_pair
#define pb push_back
#define mid (start+end)/2
using namespace std;
int vis[li][2];
queue< pair<int,int> > q;
vector<int> v[li],ans;
vector<int> chechk_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<N;i++){
for(int j=0;j<N;j++) v[j].clear();
memset(vis,0,sizeof(vis));
for(int j=0;j<(int)X.size();j++){
v[X[j]].pb(Y[j]);
v[Y[j]].pb(X[j]);
}
if(S[i]<L[i]) {ans.pb(0);continue;}
if(S[i]>=L[i] && S[i]<=R[i]) q.push(mp(S[i],1));
q.push(mp(S[i],0));
int flag=0;
while(!q.empty()){
pair<int,int> temp=q.front();
q.pop();
int seh=temp.fi;
int tur=temp.se;
if(tur==0 && seh<L[i]) continue;
if(tur==1 && seh>R[i]) continue;
if(vis[seh][tur]==1) continue;
if(seh==E[i] && tur==1){
flag=1;
break;
}
vis[seh][tur]=1;
for(int j=0;j<(int)v[seh].size();j++){
int go=v[seh][j];
if(go>=L[i] && go<=R[i]) q.push(mp(go,1));
q.push(mp(go,tur));
}
}
if(flag==1) ans.pb(1);
else ans.pb(0);
}
return ans;
}
//int main(){
// return 0;
//}