#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();
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 |
Partially correct |
2 ms |
200 KB |
Number of queries: 5 |
2 |
Partially correct |
2 ms |
200 KB |
Number of queries: 5 |
3 |
Partially correct |
2 ms |
200 KB |
Number of queries: 5 |
4 |
Partially correct |
2 ms |
200 KB |
Number of queries: 5 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
388 KB |
Number of queries: 8 |
2 |
Correct |
20 ms |
328 KB |
Number of queries: 9 |
3 |
Correct |
29 ms |
384 KB |
Number of queries: 9 |
4 |
Correct |
21 ms |
448 KB |
Number of queries: 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
22 ms |
364 KB |
Number of queries: 10 |
2 |
Correct |
23 ms |
332 KB |
Number of queries: 9 |
3 |
Partially correct |
20 ms |
332 KB |
Number of queries: 10 |
4 |
Partially correct |
28 ms |
340 KB |
Number of queries: 10 |