Submission #529692

#TimeUsernameProblemLanguageResultExecution timeMemory
529692ohohorzEaster Eggs (info1cup17_eastereggs)C++14
87 / 100
26 ms500 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; const int MAXN = 520; set<int> g[MAXN]; int n; vector<int> ord; void dfs(int u,int p){ ord.push_back(u); for(auto v:g[u]) if(v != p){ dfs(v, u); } } int findEgg (int N, vector < pair < int, int > > bridges){ /* set<int> g[MAXN]; int n, sub[MAXN]; vector<int> cenTree[MAXN], what[MAXN]; */ for(int i = 0;i <MAXN;i++){ g[i].clear(); } ord.clear(); n = N; for(int i = 0;i < N-1;i++){ int u = bridges[i].first; int v = bridges[i].second; g[u].insert(v); g[v].insert(u); } dfs(1, 0); int l = 0, r = n -1; int mx = 1e9; while(l <= r){ int m = (l + r) >> 1LL; vector<int> to; for(int i = 0;i <= m;i++) to.push_back(ord[i]); int q = query(to); if(q == 1){ mx = min(mx, m); r = m -1; } else l = m + 1; } return ord[mx]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...