# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
439488 | 2021-06-30T05:59:39 Z | Yazan_Alattar | Easter Eggs (info1cup17_eastereggs) | C++14 | 0 ms | 0 KB |
#include <iostream> #include <fstream> #include <cstring> #include <cmath> #include <queue> #include <map> #include <set> #include <vector> #include <algorithm> #include "grader.h" using namespace std; #define endl "\n" #define F first #define S second #define pb push_back typedef long long ll; const int M = 550; const int mod = 1e9+7; vector <int> adj[M], ord; void dfs(int node, int p) { ord.pb(node); for(auto i : adj[node]){ if(i == p) continue; dfs(i, node); } return; } int findEgg(int N, vector<pair<int, int>> bridges) { for (int i = 1; i <= N; i++) adj[i].clear(); ord.clear(); for (pair<int, int> i : bridges) { adj[i.first].push_back(i.second); adj[i.second].push_back(i.first); } dfs(); int l = 0, r = N - 1; while (l != r) { int mid = (l + r + 1) / 2; if (query(vector<int>(ord.begin(), ord.begin() + mid))) r = mid - 1; else l = mid; } return ord[l]; }