Submission #951887

#TimeUsernameProblemLanguageResultExecution timeMemory
951887__Davit__Easter Eggs (info1cup17_eastereggs)C++17
87 / 100
12 ms1004 KiB
#include "grader.h" #include <bits/stdc++.h> using namespace std; namespace { vector<vector<int>> gp; vector<int> order; void dfs(int node = 1, int parent = 0) { order.push_back(node); for (int i: gp[node])if (i != parent) dfs(i, node); } } int findEgg(int N, vector<pair<int, int>> bridges) { gp.clear(); gp.resize(N + 11); order.clear(); for (pair<int, int> i: bridges) { gp[i.first].push_back(i.second); gp[i.second].push_back(i.first); } dfs(); int ina = 1, inb = N, ans = order.back(); while (ina <= inb) { int mid = (ina + inb) >> 1; vector<int> tmp; for (int i = 0; i < mid; i++) tmp.push_back(order[i]); if (query(tmp)) { inb = mid - 1; ans = tmp.back(); } else ina = mid + 1; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...