이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <vector>
#include <bits/stdc++.h>
#define fs first
#define sc second
#define p_q priority_queue
using namespace std;
vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) {
int n=r.size();
vector<vector<pair<int,int> > > e(n);
int m=u.size();
for(int i=0;i<m;i++){
e[u[i]].push_back({v[i],c[i]});
e[v[i]].push_back({u[i],c[i]});
}
vector<int> val(n),ans(n);
for(int i=0;i<n;i++){
queue<int> q;
vector<int> vis(n),vz(n);
vector<queue<int> > to(n);
q.push(i);
vz[i]=1;
while(q.size()){
auto h=q.front();
q.pop();
val[i]++;
for(auto y:e[h]){
if(vz[y.fs]){
continue;
}
if(vis[y.sc]){
q.push(y.fs);
vz[y.fs]=1;
}
else{
to[y.sc].push(y.fs);
}
}
if(!vis[r[h]]){
vis[r[h]]=1;
while(to[r[h]].size()){
auto u=to[r[h]].front();
to[r[h]].pop();
if(vz[u]){
continue;
}
vz[u]=1;
q.push(u);
}
}
}
}
int mn=1e9;
for(int i=0;i<n;i++){
mn=min(mn,val[i]);
}
for(int i=0;i<n;i++){
if(val[i]==mn){
ans[i]=1;
}
}
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... |