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 "grader.h"
#include <bits/stdc++.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) {
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(1);
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |