This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#include "grader.h"
int findEgg(int n, vector<pair<int, int>> bridges) {
vector<vector<int>> g(n + 1);
for (auto [a, b] : bridges) {
g[a].push_back(b);
g[b].push_back(a);
}
vector<int> ord;
function<void(int, int)> dfs = [&](int v, int p) {
ord.push_back(v);
for (int u : g[v]) {
if (u == p) continue;
dfs(u, v);
}
};
dfs(1, -1);
int l = 0, r = (int) ord.size() - 1;
while (l < r) {
int m = (l + r) / 2;
if (query({ord.begin(), ord.begin() + m + 1})) r = m;
else l = m + 1;
}
return ord[l];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |