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 <vector>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//#define int ll
#define rep(n) rep1(i,n)
#define rep1(i,n) rep2(i,0,n)
#define rep2(i,a,b) for(int i=a; i<(b); ++i)
#define rep3(i,a,b) for(int i=a; i>=(b); --i)
#define chkmax(a,b) (a=max(a,b))
#define chkmin(a,b) (a=min(a,b))
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define pb push_back
#define pii pair<int,int>
#define pow2(x) (1ll<<(x))
#ifdef zisk
#define bug(...) cerr << "#" << __LINE__ << ": " << #__VA_ARGS__ << "- ", _do(__VA_ARGS__)
template<typename T> void _do(T x){cerr << x << endl;}
template<typename T, typename ...S> void _do(T x, S... y){cerr << x << ", "; _do(y...);}
#else
#define bug(...) 49
#endif
const int maxn=2005;
int n,m,val[maxn];
vector<pii> vec[maxn];
bool vis[maxn],vis2[maxn];
queue<int> q;
vector<int> vec2[maxn];
int par[maxn];
int Find(int x){return x==par[x]?x:par[x]=Find(par[x]);}
void Union(int x, int y){
x=Find(x),y=Find(y);
if(x==y) return;
par[y]=x;
}
vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) {
n=sz(r);
m=sz(u);
rep(m) vec[c[i]].pb({u[i],v[i]});
rep1(j,n){
rep(n) vis[i]=0,vis2[i]=0,par[i]=i,vec2[i].clear();
rep(n) vec2[i].pb(r[i]);
q.push(r[j]);
vis[r[j]]=1;
while(!q.empty()){
int x=q.front();
q.pop();
for(auto [u,v]: vec[x]){
u=Find(u),v=Find(v);
if(u==v) continue;
if(sz(vec2[u])<sz(vec2[v])) swap(u,v);
if(Find(j)==v){
for(auto i: vec2[u]) if(!vis[i]){
q.push(i);
vis[i]=1;
}
}
if(Find(j)==u){
for(auto i: vec2[v]) if(!vis[i]){
q.push(i);
vis[i]=1;
}
}
for(auto i: vec2[v]) vec2[u].pb(i);
vec2[v].clear();
par[v]=u;
}
}
rep(n) if(Find(i)==Find(j)) val[j]++;
}
int minn=*min_element(val,val+n);
vector<int> res(n);
rep(n) res[i]=minn==val[i];
return res;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |