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>
#include "grader.h"
using namespace std;
vector<vector<int>> v;
vector<int> a;
void dfs(int i, int last = -1) {
a.emplace_back(i);
for (auto node : v[i]) {
if (last == node) continue;
dfs(node, i);
}
}
int findEgg (int n, vector<pair<int, int>> bridges) {
v = vector<vector<int>>(n + 10);
for (auto node : bridges) {
v[node.first].emplace_back(node.second);
v[node.second].emplace_back(node.first);
}
dfs(1);
int l = 0, r = n - 1;
while (l <= r) {
int m = (l + r) / 2;
if (query(vector<int>(a.begin(), a.begin() + m))) r = m;
else l = m;
}
return a[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... |