Submission #966314

#TimeUsernameProblemLanguageResultExecution timeMemory
966314studyEaster Eggs (info1cup17_eastereggs)C++17
100 / 100
13 ms752 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; const int N = 512; vector<int> adj[N]; vector<int> order; void dfs(int node, int p = -1){ order.emplace_back(node); for (int i:adj[node]){ if (i != p){ dfs(i,node); } } } int findEgg (int N, vector < pair < int, int > > bridges){ for (int i=0; i<N; ++i){ adj[i].clear(); } order.clear(); for (auto [a,b]:bridges){ a--; b--; adj[a].emplace_back(b); adj[b].emplace_back(a); } dfs(0); int deb = 0, fin = N-1; while (deb < fin){ int mid = (deb+fin)/2; vector<int> q; for (int i=0; i<=mid; ++i){ q.emplace_back(order[i]+1); } if (query(q)){ fin = mid; } else{ deb = mid+1; } } return order[deb]+1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...