#include <bits/stdc++.h>
#include "grader.h"
// #include "grader.cpp"
using namespace std;
vector<int> adj[513];
vector<int> v;
void dfs(int u, int p){
v.push_back(u);
for(auto x : adj[u]){
if(x != p)
dfs(x, u);
}
}
int findEgg(int N, vector<pair<int, int>> bridges){
ios_base::sync_with_stdio(0);
for(int i=0; i<N-1; i++){
int u = bridges[i].first;
int v = bridges[i].second;
adj[u].push_back(v);
adj[v].push_back(u);
}
dfs(1, 0);
int sz = v.size();
int ans = 0;
int l = 0, r = sz - 2;
while(l <= r){
vector<int> islands;
int mid = (l + r) / 2;
for(int i=0; i<=mid; i++)
islands.push_back(v[i]);
if(query(islands) == 1){
ans = mid;
r = mid - 1;
}
else
l = mid + 1;
}
if(ans == 0)
ans = sz - 1;
v.clear();
for(int i=0; i<512; i++)
adj[i].clear();
return v[ans];
}
# |
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 |
Correct |
6 ms |
336 KB |
Number of queries: 8 |
2 |
Correct |
11 ms |
376 KB |
Number of queries: 9 |
3 |
Correct |
20 ms |
364 KB |
Number of queries: 9 |
4 |
Correct |
14 ms |
376 KB |
Number of queries: 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
592 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |