// trans rights
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<int> adj[1069];
vector<int> H;
void dfs(int i, int p)
{
H.push_back(i);
for (int j : adj[i])
{
if (j == p) continue;
dfs(j, i);
}
}
bool within(int x)
{
vector<int> q;
for (int i = 0; i <= x; i++)
q.push_back(H[i]);
return query(q);
}
int findEgg(int N, vector<pair<int, int>> bridges)
{
for (auto &a : adj)
a.clear();
H.clear();
for (int i = 0; i < N - 1; i++)
{
int a = bridges[i].first;
int b = bridges[i].second;
adj[a].push_back(b);
adj[b].push_back(a);
}
dfs(1, 1);
int a = 0;
int b = N;
while (b - a > 1)
{
int m = (a + b) / 2;
if (within(m - 1)) b = m;
else a = m;
}
return H[a];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
208 KB |
Number of queries: 4 |
2 |
Correct |
1 ms |
208 KB |
Number of queries: 4 |
3 |
Correct |
2 ms |
208 KB |
Number of queries: 4 |
4 |
Correct |
2 ms |
208 KB |
Number of queries: 4 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
356 KB |
Number of queries: 8 |
2 |
Correct |
11 ms |
364 KB |
Number of queries: 9 |
3 |
Correct |
25 ms |
352 KB |
Number of queries: 9 |
4 |
Correct |
14 ms |
336 KB |
Number of queries: 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
336 KB |
Number of queries: 9 |
2 |
Correct |
12 ms |
336 KB |
Number of queries: 9 |
3 |
Correct |
20 ms |
348 KB |
Number of queries: 9 |
4 |
Correct |
17 ms |
336 KB |
Number of queries: 9 |