#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
void get_preorder(vector<vector<int>> const &g, int u, int p, vector<int> &trav)
{
trav.push_back(u + 1);
for (int const &v : g[u])
if (v != p)
get_preorder(g, v, u, trav);
}
int findEgg(int n, vector<pair<int, int>> edges)
{
vector<vector<int>> g(n);
for (auto const &[u, v] : edges)
{
g[u - 1].push_back(v - 1);
g[v - 1].push_back(u - 1);
}
vector<int> preorder;
get_preorder(g, 0, -1, preorder);
size_t a = 0, b = n;
while (a < b)
{
size_t mid = (a + b) / 2;
if (query(vector<int>(preorder.begin(), preorder.begin() + mid)))
b = mid;
else
a = mid + 1;
}
return preorder[a];
}
# |
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 |
2 ms |
588 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |