Submission #1099238

#TimeUsernameProblemLanguageResultExecution timeMemory
1099238huyngoKeys (IOI21_keys)C++17
0 / 100
1 ms348 KiB
#include<bits/stdc++.h> using namespace std; 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(); int m = u.size(); vector<vector<array<int, 2>>> adj(n); vector<vector<int>> pend(n); for (int i = 0; i < m; ++i) { adj[u[i]].push_back({ v[i], c[i] }); adj[v[i]].push_back({ u[i], c[i] }); } vector<int> reachable(n); for (int st = 0; st < n; ++st) { queue<int> qu; qu.push(st); vector<bool> unlock(n, false), vis(n, false); while (qu.size()) { int u = qu.front(); qu.pop(); if (vis[u]) continue; vis[u] = true; ++reachable[st]; unlock[r[u]] = 1; for (int v : pend[r[u]]) if (!vis[v]) qu.push(v); pend[r[u]].clear(); for (auto [v, w] : adj[u]) if (!vis[v]) { if (unlock[w]) qu.push(v); else pend[w].push_back(v); } } } int _min = *min_element(reachable.begin(), reachable.end()); for (int i = 0; i < n; ++i) ans[i] = (reachable[i] == _min); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...