// author: erray
#include<bits/stdc++.h>
using namespace std;
int query(vector<int> v);
int findEgg(int n, vector<pair<int, int>> edges) {
vector<vector<int>> g(n);
for (auto e : edges) {
g[e.first - 1].push_back(e.second - 1);
g[e.second - 1].push_back(e.first - 1);
}
vector<int> ask;
function<void(int, int)> dfs = [&](int v, int pr) {
ask.push_back(v);
for (auto u : g[v]) {
if (u == pr) continue;
dfs(u, v);
}
};
int s = 0, e = n - 1;
while (s != e) {
int mid = (s + e) >> 1;
vector<int> q;
for (int i = 0; i <= mid; ++i) q.push_back(ask[i] + 1);
if (query(q)) e = mid;
else s = mid + 1;
}
return ask[s];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
384 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |