Submission #951873

#TimeUsernameProblemLanguageResultExecution timeMemory
951873__Davit__Easter Eggs (info1cup17_eastereggs)C++17
32 / 100
1 ms600 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; namespace { vector<int> order; vector<vector<int>> gp; void dfs(int u, int p = -1) { order.push_back(u); for (auto x: gp[u]) { if (x == p)continue; dfs(x, u); } } } int findEgg(int N, vector<pair<int, int> > bridges) { order.clear(); gp.clear(); gp.resize(N + 1); for (int i = 0; i < N; i++) { gp[bridges[i].first].push_back(bridges[i].second); gp[bridges[i].second].push_back(bridges[i].first); } dfs(1); int ina = 1, inb = N, ans = order[N - 1]; while (ina <= inb) { int mid = (ina + inb) >> 1; vector<int> tmp; for (int i = 0; i < mid; i++)tmp.push_back(order[i]); bool ok = query(tmp); if (ok) { ans = tmp.back(); inb = mid - 1; } else { ina = mid + 1; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...