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 <bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n';
#define ll long long int
const int N = 3e5+10;
vector<pair<int, int>> g[N];
vector<int> K[N];
std::vector<int> find_reachable(std::vector<int> r, std::vector<int> u, std::vector<int> v, std::vector<int> c) {
std::vector<int> ans(r.size(), 1);
int n = r.size(), m = u.size();
vector<int> p(n);
for(int i = 0; i < m; ++i){
g[u[i]].pb({v[i], c[i]});
g[v[i]].pb({u[i], c[i]});
}
for(int i = 0; i < n; ++i){
for(int j = 0; j < n; ++j) K[i].clear();
vector<bool> vis(n), has(n);
vis[i] = 1;
queue<int> q; q.push(i);
while(!q.empty()){
int v = q.front();
q.pop();
if(has[r[v]] == 0){
for(auto u: K[r[v]]){
if(vis[u]) continue;
vis[u] = 1;
q.push(u);
}
K[r[v]].clear();
}
has[r[v]] = 1;
for(auto U: g[v]){
int u = U.first, key = U.second;
if(!vis[u]){
if(has[key]){
vis[u] = 1;
q.push(u);
}else{
K[key].pb(u);
}
}
}
}
for(int j = 0; j < n; ++j) if(vis[j]) ++p[i];
}
int mn = *min_element(all(p));
for(int i = 0; i < n; ++i) ans[i] = p[i] == mn;
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... |