# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
863908 | 2023-10-21T11:51:26 Z | Ariadna | Easter Eggs (info1cup17_eastereggs) | C++14 | 0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; int query(vector < int > islands); vector < vector < int > > adj; void dfs(int u, int p, vector < int >& order) { order.push_back(u); for (int v : adj[u]) { if (v != p) dfs(v, u, order); } } int findEgg(int N, vector < pair < int, int > >& bridges) { adj = vector < vector < int > >(N + 1); for (int i = 0; i < N - 1; ++i) { int u = bridges[i].first, v = bridges[i].second; adj[u].push_back(v); adj[v].push_back(u); } vector < int > order; dfs(1, 1, order); int l = 0, r = N - 1; while (l < r) { vector < int > q; int m = (l + r) / 2; for (int i = 0; i <= m; ++i) { q.push_back(order[i]); } if (query(q)) r = m; else l = m + 1; } return order[l]; }