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 ll = long long;
const int MAX_N = 512;
std::vector<int> g[MAX_N + 1], v;
void dfs(int u, int p = -1) {
v.push_back(u);
for (int v : g[u]) {
if (v != p) {
dfs(v, u);
}
}
}
int bsearch() {
int l = 0, r = v.size() - 1;
while (r - l > 0) {
int mid = (l + r) / 2;
std::vector<int> tmp;
for (int i = 0; i <= mid; i++) {
tmp.push_back(v[i]);
}
if (query(tmp)) {
r = mid;
} else {
l = mid;
}
}
return v[r];
}
int findEgg(int n, std::vector<std::pair<int, int>> bridges) {
for (int i = 1; i <= n; i++) {
g[i].clear();
}
for (auto it : bridges) {
g[it.first].push_back(it.second);
g[it.second].push_back(it.first);
}
v.clear();
dfs(1);
int answer = bsearch();
return answer;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |