Submission #1057170

#TimeUsernameProblemLanguageResultExecution timeMemory
1057170Drifter24Easter Eggs (info1cup17_eastereggs)C++14
87 / 100
11 ms752 KiB
#include <bits/stdc++.h> using namespace std; int query(vector < int > islands); void dfs(int v, int p, vector<vector<int>>& adj, vector<int>& ans){ ans.push_back(v); for(int u:adj[v]){ if(u==p)continue; dfs(u, v, adj, ans); } } int findEgg(int N, vector < pair < int, int > > bridges){ vector<int> ans; vector<vector<int>> adj(N+1, vector<int>()); for(auto x:bridges){ adj[x.first].push_back(x.second); adj[x.second].push_back(x.first); } dfs(1, 0, adj, ans); int l=-1,r=N; while(r-l>1){ int m=(r+l)/2; vector<int> q; for(int i=0;i<=m;++i)q.push_back(ans[i]); if(query(q))r=m; else l=m; } return ans[r]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...