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;
const int maxn = 3e5 + 20;
vector<pair<int, int>> adj[maxn];
vector<pair<int, int>> edges[maxn];
bool flag[maxn];
bool found[maxn];
int cnt[maxn];
vector<int> find_reachable(vector<int> type, vector<int> u, vector<int> v, vector<int> c) {
int n = type.size();
int m = u.size();
for (int i = 0; i < m; i++) {
adj[u[i]].emplace_back(v[i], c[i]);
adj[v[i]].emplace_back(u[i], c[i]);
edges[c[i]].emplace_back(u[i], v[i]);
}
int mi = n + 1;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
flag[j] = false;
found[j] = false;
}
flag[i] = true;
deque<int> q = {i};
while (!q.empty()) {
int u = q.front();
cnt[i]++;
q.pop_front();
found[type[u]] = true;
for (auto e: edges[type[u]]) {
if (flag[e.first] && !flag[e.second]) {
flag[e.second] = true;
q.push_back(e.second);
}
if (flag[e.second] && !flag[e.first]) {
flag[e.first] = true;
q.push_back(e.first);
}
}
for (auto e: adj[u]) {
if (found[e.second] && !flag[e.first]) {
flag[e.first] = true;
q.push_back(e.first);
}
}
}
mi = min(mi, cnt[i]);
}
vector<int> res(n);
for (int i = 0; i < n; i++) {
res[i] = (cnt[i] == mi);
}
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... |