# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
635772 | 2022-08-26T21:45:36 Z | Dec0Dedd | Easter Eggs (info1cup17_eastereggs) | C++11 | 0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; #define pii pair<int, int> const int N = 513; vector<int> G[N], pre; int n; void dfs(int v, int p) { pre.push_back(v); for (auto u : G[v]) { if (u == p) continue; dfs(u, v); } } vector<int> genIsl(int m) { vector<int> res; for (int i=0; i<=m; ++i) res.push_back(pre[i]); return res; } int findEgg(int sz, vector<pii> x) { n=sz; for (auto u : x) { int a=u.first, b=u.second; G[a].push_back(b); G[b].push_back(a); } dfs(1, 1); int l=0, r=n-1, res=n-1; while (l <= r) { int m=(l+r)/2; if (query(genIsl(m))) r=m-1, res=m; else l=m+1; } return pre[res]; }