# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
483637 | 2021-10-31T12:25:05 Z | alexdumitru | Easter Eggs (info1cup17_eastereggs) | C++14 | 0 ms | 0 KB |
#include <iostream> #include <vector> #include <grader.h> using namespace std; vector<int> v[550]; vector<int> parcurgere; int viz[550]; int query(vector<int> islands); void dfs(int nod=1, int p=-1) { parcurgere.push_back(nod); for(auto i:a[nod])if(i!=p)dfs(i,nod); } int findEgg(int N, vector<pair<int,int> > bridges) { int st,r=N-1,poz=N,mi,dr,i,m=bridges.size(); for(i=1;i<=N;i++)viz[i]=0; for(i=0;i<m;i++) { a[bridges[i].first].push_back(bridges[i].second); a[bridges[i].second].push_back(bridges[i].first); } dfs(); st=0; dr=N-1; while(st<=dr) { mi=st+(dr-st)/2; if(query(vector<int>(parcurgere.begin(),parcurgere.begin()+mi+1))) { dr=mi-1; r=mi; } else st=mi+1; } return parcurgere[r]; }