Submission #1116590

#TimeUsernameProblemLanguageResultExecution timeMemory
1116590vladiliusEaster Eggs (info1cup17_eastereggs)C++17
0 / 100
2 ms592 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; #define pb push_back #define ff first #define ss second int query(vector<int> f); int findEgg(int n, vector<pii> ed){ vector<int> g[n]; for (auto [x, y]: ed){ x--; y--; g[x].pb(y); g[y].pb(x); } vector<int> a(n); int timer = 0; function<void(int, int)> dfs = [&](int v, int pr){ a[timer++] = v; for (int i: g[v]){ if (i == pr) continue; dfs(i, v); } }; dfs(0, 0); auto check = [&](int x){ vector<int> f; for (int i = 0; i <= x; i++){ f.pb(a[i]); } return query(f); }; int l = 0, r = n - 1; while (l + 1 < r){ int m = (l + r) / 2; if (check(m)){ r = m; } else { l = m + 1; } } if (check(l)) r = l; return a[r]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...