Submission #209671

#TimeUsernameProblemLanguageResultExecution timeMemory
209671TAISA_Werewolf (IOI18_werewolf)C++14
15 / 100
4046 ms22252 KiB
#include "werewolf.h" #include <bits/stdc++.h> using namespace std; struct UF{ vector<int> par,sz; UF(int n){ par.resize(n); sz.resize(n,1); for(int i=0;i<n;i++)par[i]=i; } int find(int x){ if(par[x]==x)return par[x]; return par[x]=find(par[x]); } void unite(int u,int v){ u=find(u);v=find(v); if(u==v)return; if(sz[u]<sz[v])swap(u,v); par[v]=u; sz[u]+=sz[v]; } bool same(int u,int v){ return find(u)==find(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) { int n=N,m=X.size(),q=S.size(); vector<int> res(q); for(int i=0;i<q;i++){ UF ua(n),ub(n); for(int j=0;j<m;j++){ if(X[j]<=R[i]&&Y[j]<=R[i]){ ua.unite(X[j],Y[j]); } if(X[j]>=L[i]&&Y[j]>=L[i]){ ub.unite(X[j],Y[j]); } } for(int j=0;j<n;j++){ if(ua.same(E[i],j)&&ub.same(j,S[i])){ res[i]=1; } } } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...