이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |