Submission #969510

#TimeUsernameProblemLanguageResultExecution timeMemory
969510tamir1Easter Eggs (info1cup17_eastereggs)C++17
81 / 100
14 ms1028 KiB
#include <bits/stdc++.h> #include "grader.h" #define ff first #define ss second using namespace std; vector<int> v[1009],u,m; void dfs(int x,int p){ u.push_back(x); for(int i:v[x]){ if(i!=p) dfs(i,x); } } int findEgg (int N, vector < pair < int, int > > bridges) { u={0}; int i; for(i=1;i<=N;i++) v[i].clear(); for(i=0;i<N-1;i++){ int x=bridges[i].ff; int y=bridges[i].ss; v[x].push_back(y); v[y].push_back(x); } dfs(1,-1); int mid,l=1,r=N; while(r-l>1){ mid=(r+l+1)/2; m.clear(); for(i=1;i<=mid;i++) m.push_back(u[i]); if(query(m)) r=mid; else l=mid; } if(query({u[r]})) return u[r]; else return u[l]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...