Submission #334565

#TimeUsernameProblemLanguageResultExecution timeMemory
334565nandonathanielEaster Eggs (info1cup17_eastereggs)C++14
100 / 100
21 ms492 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; const int MAXN=515; vector<int> adj[MAXN]; int preorder[MAXN],nomor[MAXN],idx; void dfs(int now,int par){ idx++; preorder[idx]=now; for(auto nxt : adj[now]){ if(nxt==par)continue; dfs(nxt,now); } } int findEgg (int N, vector < pair < int, int > > bridges) { idx=0; for(int i=1;i<=N;i++)adj[i].clear(); for(int i=0;i<N-1;i++){ adj[bridges[i].first].push_back(bridges[i].second); adj[bridges[i].second].push_back(bridges[i].first); } dfs(1,-1); int ki=1,ka=N; while(ki<ka){ // cout << ki << " " << ka << endl; int mid=(ki+ka)/2; vector<int> v; for(int i=1;i<=mid;i++)v.push_back(preorder[i]); if(query(v)){ ka=mid; } else ki=mid+1; } return preorder[ki]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...