Submission #521890

#TimeUsernameProblemLanguageResultExecution timeMemory
521890boykutEaster Eggs (info1cup17_eastereggs)C++14
26.40 / 100
808 ms1608 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; int findEgg (int N, vector < pair < int, int > > bridges){ vector<int> par(1 + N); vector<vector<int>> g(1 + N); for (auto it : bridges) { int a, b; tie(a, b) = it; g[a].push_back(b); g[b].push_back(a); } set<int> st; for (int i = 1; i <= N; i++) st.insert(i); while (true) { vector<int> comp; function<void(int, int)> dfs = [&](int v, int p) { comp.push_back(v); for (auto to : g[v]) { if (to == p) continue; if (!st.count(to)) continue; dfs(to, v); } }; vector<vector<int>> v; for (auto it : st) { while (!comp.empty()) comp.pop_back(); dfs(it, -1); v.push_back(comp); } sort(v.begin(), v.end(), [&](vector<int> a, vector<int> b) { return a.size() > b.size(); }); vector<int> Q; for (int i = 0; i < max(1,min((int)v[0].size(), (int)st.size()/2)); i++) { Q.push_back(v[0][i]); } if (query(Q) == 1) { if (Q.size() == 1) return Q[0]; set<int> h; for (auto it : Q) h.insert(it); for (int i = 1; i <= N; i++) if (st.count(i) && !h.count(i)) st.erase(i); } else { for (auto it : Q) st.erase(it); } } return -1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...