Submission #441789

#TimeUsernameProblemLanguageResultExecution timeMemory
441789baluteshihKeys (IOI21_keys)C++17
9 / 100
214 ms28972 KiB
#include <vector> #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define X first #define Y second #define pb push_back #define ALL(v) v.begin(), v.end() #define SZ(a) ((int)a.size()) vector<pii> G[300005]; int vis[300005]; vector<int> stk; void dfs(int u) { stk.pb(u); vis[u] = 1; for (pii i : G[u]) if (!vis[i.X]) dfs(i.X); } vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) { int n = SZ(r), m = SZ(u); vector<int> ans(n, 0); vector<int> arr(n, 0); for (int i = 0; i < m; ++i) { G[u[i]].pb(pii(v[i], c[i])); G[v[i]].pb(pii(u[i], c[i])); } for (int i = 0; i < n; ++i) if (!vis[i]) { stk.clear(); dfs(i); for (int j : stk) if (r[j] == 0) arr[j] = SZ(stk); else arr[j] = 1; } int mi = *min_element(ALL(arr)); for (int i = 0; i < n; ++i) if (arr[i] == mi) ans[i] = 1; 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...