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>
using namespace std;
#include "werewolf.h"
typedef vector<int> Vec;
const int maxN=400100;
int Fp[maxN],Fw[maxN];
int find1(int x){return x==Fp[x]?x:Fp[x]=find1(Fp[x]);}
int find2(int x){return x==Fw[x]?x:Fw[x]=find2(Fw[x]);}
void uni1(int x,int y){
int Fx=find1(x),Fy=find1(y);
if(Fx==Fy)return;
Fp[Fx]=Fy;
}
void uni2(int x,int y){
int Fx=find2(x),Fy=find2(y);
if(Fx==Fy)return;
Fw[Fx]=Fy;
}
Vec check_validity(int N,Vec X,Vec Y,Vec S,Vec E,Vec L,Vec R) {
int M=X.size(),Q=S.size();
Vec A;
A.clear();
for (int q=0;q<Q;q++){
for (int i=0;i<N;i++)Fp[i]=i,Fw[i]=i;
for (int i=0;i<M;i++){
//People
if (X[i]>=L[q]&&Y[i]>=L[q])uni1(X[i],Y[i]);
//Wolf
if (X[i]<=R[q]&&Y[i]<=R[q])uni2(X[i],Y[i]);
}
int no=1;
// printf("Case %d\n",q);
// for (int i=0;i<N;i++)printf("City %d: Fp:%d Fw:%d\n",i,find1(Fp[i]),find2(Fw[i]));
for (int i=L[q];i<=R[q];i++)
if (find1(Fp[S[q]])==find1(Fp[i])&&find2(Fw[E[q]])==find2(Fw[i])){
no=0;A.push_back(1);break;
}
if(no)A.push_back(0);
}
return A;
}
# | 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... |