#include <bits/stdc++.h>
using namespace std;
#include "grader.h"
int findEgg(int n, vector<pair<int, int>> bridges) {
vector<vector<int>> g(n + 1);
for (auto [a, b] : bridges) {
g[a].push_back(b);
g[b].push_back(a);
}
vector<int> ord;
function<void(int, int)> dfs = [&](int v, int p) {
ord.push_back(v);
for (int u : g[v]) {
if (u == p) continue;
dfs(u, v);
}
};
dfs(1, -1);
int l = 0, r = (int) ord.size() - 1;
while (l < r) {
int m = (l + r) / 2;
if (query({ord.begin(), ord.begin() + m + 1})) r = m;
else l = m + 1;
}
return ord[l];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Number of queries: 4 |
2 |
Correct |
2 ms |
200 KB |
Number of queries: 4 |
3 |
Correct |
1 ms |
200 KB |
Number of queries: 4 |
4 |
Correct |
2 ms |
200 KB |
Number of queries: 4 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
328 KB |
Number of queries: 8 |
2 |
Correct |
15 ms |
328 KB |
Number of queries: 9 |
3 |
Correct |
22 ms |
328 KB |
Number of queries: 9 |
4 |
Correct |
20 ms |
468 KB |
Number of queries: 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
380 KB |
Number of queries: 9 |
2 |
Correct |
24 ms |
344 KB |
Number of queries: 9 |
3 |
Correct |
21 ms |
328 KB |
Number of queries: 9 |
4 |
Correct |
19 ms |
328 KB |
Number of queries: 9 |