Submission #1020947

#TimeUsernameProblemLanguageResultExecution timeMemory
1020947mdn2002Keys (IOI21_keys)C++17
9 / 100
3054 ms33684 KiB
/* Mayoeba Yabureru */ #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(), m = u.size(), st; vector<int> vis(n), did(n), p(n); vector<vector<pair<int, int>>> gr(n); vector<vector<int>> vv(n); for (int i = 0; i < m; i ++) { gr[u[i]].push_back({v[i], c[i]}); gr[v[i]].push_back({u[i], c[i]}); } function<void(int)> dfs = [&] (int x) { vis[x] = 1, did[r[x]] = 1; p[st] ++; while (vv[r[x]].size()) { int u = vv[r[x]].back(); vv[r[x]].clear(); dfs(u); } for (auto [u, c] : gr[x]) { if (vis[u]) continue; if (did[c]) dfs(u); else vv[c].push_back(u); } }; int mn = 1e9; for (int i = 0; i < n; i ++) { vis.assign(n, 0); did.assign(n, 0); st = i; dfs(i); for (int j = 0; j < n; j ++) vv[j].clear(); mn = min(mn, p[i]); } vector ans(n, 0); for (int i = 0; i < n; i ++) { if (mn == p[i]) 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...