# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
98256 | 2019-02-21T17:22:59 Z | Vasiljko | Easter Eggs (info1cup17_eastereggs) | C++14 | 0 ms | 0 KB |
#include <bits/stdc++.h> #include "grader.h" using namespace std; typedef long long ll; const ll MOD = 1e9+7; int n,cnt,ans; vector<int>v[550],seq; void dfs(int s,int p){ seq.push_back(s); for(auto e:v[s])if(e!=p)dfs(e,s); } int findEgg(int N,vector<pair<int,int> >b){ n=N; for(int i=0;i<n;i++)v[i].clear(); for(auto e:b){ v[e.first].push_back(e.second); v[e.second].push_back(e.first); } seq.clear(); dfs(1,0); int l=0; int r=n-1; while(l<=r){ int mid=(l+r)>>1; q.clear(); for(int i=0;i<=mid;i++)q.push_back(seq[i]); if(query(q)){ r=mid-1; ans=mid; }else{ l=mid+1; } } return seq[ans]; }