# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
579120 | Jarif_Rahman | Easter Eggs (info1cup17_eastereggs) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "grader.cpp"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int findEgg(int n, vector<pair<int, int>> bridges){
vector<vector<int>> v(n);
for(auto [a, b]: bridges) a--, b--, v[a].pb(b), v[b-1].pb(a);
vector<int> dfs_array;
function<void(int, int)> dfs = [&](int nd, int ss){
dfs_array.pb(nd+1);
for(int x: v[nd]) if(x != ss) dfs(x, nd);
};
dfs(0, -1);
int a = 0, b = n-1;
while(a < b){
int md = (a+b)/2;
if(query(vector<int>(dfs_array.begin(), dfs_array.begin()+md+1))) b = md;
else a = md+1;
}
return dfs_array[a];
}