# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
894375 | Trisanu_Das | Keys (IOI21_keys) | C++17 | 3040 ms | 23260 KiB |
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;
vector<int> find_reachable(vector<int> r, vector<int> U, vector<int> V, vector<int> C) {
int n = r.size();
vector<pair<int, int>> adj[n];
for (int i = 0; i < U.size(); i++) {
adj[U[i]].push_back({V[i], C[i]});
adj[V[i]].push_back({U[i], C[i]});
}
vector<int> cnt(n);
for (int i = 0; i < n; i++) {
vector<bool> has(n), vis(n);
queue<int> q;
q.push(i);
vis[i] = true;
vector<int> nodes[n];
while (!q.empty()) {
int u = q.front();
q.pop();
for (int v : nodes[r[u]]) {
if (!vis[v]) {
vis[v] = true;
q.push(v);
}
}
has[r[u]] = true;
for (auto [v, c] : adj[u]) {
if (vis[v]) continue;
if (has[c]) {
vis[v] = true;
q.push(v);
} else nodes[c].push_back(v);
}
}
for (int j : vis) cnt[i] += j;
}
vector<int> ans(n);
int mn = *min_element(cnt.begin(), cnt.end());
for (int i = 0; i < n; i++) ans[i] = (cnt[i] == mn);
return ans;
}
Compilation message (stderr)
# | 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... |