#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
typedef int64_t ll;
typedef string str;
int findEgg(int n, vector <pair <int, int>> edges) {
vector <int> g[n + 1];
vector <int> path;
for (auto [a, b] : edges) {
g[a].push_back(b);
g[b].push_back(a);
}
function <void(int, int)> dfs = [&](int v, int p) {
path.push_back(v);
for (int to : g[v]) {
if (to == p) {
continue;
}
dfs(to, v);
}
};
dfs(1, -1);
int l = 0, r = n - 1;
while (l < r) {
int mid = (l + r) >> 1;
if (query(vector <int>(path.begin() + l, path.begin() + mid))) {
r = mid;
} else {
l = mid;
}
}
return path[l];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
464 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
464 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
560 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |