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;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
const int MAX=1e9;
const int MAX_N=1e5;
vector<vii> G;
bool vis[MAX_N],ll[MAX_N],isq[MAX_N];
vector<vi> pen;
std::vector<int> find_reachable(std::vector<int> r, std::vector<int> u, std::vector<int> v, std::vector<int> c) {
int n=r.size(); int m=u.size();
vector<int> ans(n,0);
int mi=MAX;
G.resize(n+1);
for(int i=0;i<m;i++){
int a=u[i],b=v[i],w=c[i];
G[a].push_back(ii(b,w));
G[b].push_back(ii(a,w));
}
for(int i=0;i<n;i++){
memset(vis,0,sizeof vis); memset(ll,0,sizeof ll);
memset(isq,0,sizeof isq);
queue<int> q;
q.push(i);
pen.clear(); pen.resize(n);
int c=0;
while(!q.empty()){
int x=q.front(); q.pop();
vis[x]=ll[r[x]]=1;
isq[x]=0;
// cout<<x<<": ";
for(int j=pen[r[x]].size()-1;j>=0;j--){
if(!isq[pen[r[x]][j]]){
q.push(pen[r[x]][j]);
//cout<<pen[r[x]][j]<<" ";
isq[pen[r[x]][j]]=1;
}
}
//cout<<" , ";
pen[r[x]].clear();
for(auto &v:G[x]){
if(!vis[v.first]){
if(ll[v.second]){
if(!isq[v.first]){
// cout<<v.first<<" ";
q.push(v.first);
isq[v.first]=1;
}
}
else{
pen[v.second].push_back(v.first);
}
}
}
//cout<<endl;
}
for(int j=0;j<n;j++){
c+=vis[j];
}
if(mi>c){
for(int j=0;j<n;j++) ans[j]=0;
mi=c;
}
if(mi==c){
ans[i]=1;
}
//cout<<tam[findset(i)]<<endl;
}
return ans;
}
# | 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... |