#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
const int N = 512 + 3;
int n, order[N], t;
vector<int> adj[N];
void dfs(int u, int p = -1){
order[t++] = u;
for(int to: adj[u])
if(to != p)
dfs(to, u);
}
bool check(int mid){
vector<int> v;
for(int i = 0; i <= mid; ++i)
v.push_back(order[i]);
return query(v);
}
int findEgg(int _N, vector<pair<int, int>> _bridges){
n = _N;
for(int i = 1; i <= n; ++i) adj[i].clear();
for(auto [x, y]: _bridges){
adj[x].push_back(y);
adj[y].push_back(x);
}
t = 0;
dfs(1);
int l = 0, r = n - 1;
while(l != r){
int mid = (l + r) >> 1;
if(check(mid)) r = mid;
else l = mid + 1;
}
return order[l];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Number of queries: 4 |
2 |
Correct |
1 ms |
364 KB |
Number of queries: 4 |
3 |
Correct |
1 ms |
364 KB |
Number of queries: 4 |
4 |
Correct |
1 ms |
364 KB |
Number of queries: 4 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
364 KB |
Number of queries: 8 |
2 |
Correct |
16 ms |
652 KB |
Number of queries: 9 |
3 |
Correct |
21 ms |
420 KB |
Number of queries: 9 |
4 |
Correct |
24 ms |
364 KB |
Number of queries: 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
364 KB |
Number of queries: 9 |
2 |
Correct |
18 ms |
364 KB |
Number of queries: 9 |
3 |
Correct |
20 ms |
492 KB |
Number of queries: 9 |
4 |
Correct |
18 ms |
364 KB |
Number of queries: 9 |