#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<int> tour;
vector<vector<int>> adj;
void dfs(int u,int e){
tour.push_back(u);
for(auto v:adj[u])
if(v!=e) dfs(v,u);
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
tour.clear();
adj.clear();
adj.resize(N+1);
for(auto e:bridges){
adj[e.first].push_back(e.second);
adj[e.second].push_back(e.first);
}
dfs(1,-1);
int r = 0;
for(int i=log2(N);i>=0;i--){
int t = r|(1<<i);
if(t>N) continue;
vector<int> q(tour.begin(),next(tour.begin(),t));
// cout<<t<<endl;
if(!query(q)) r=t;
}
// cout<<tour[r]<<endl;
return tour[r];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
512 KB |
Number of queries: 5 |
2 |
Incorrect |
3 ms |
256 KB |
Number of queries: 5 |
3 |
Incorrect |
3 ms |
256 KB |
Number of queries: 5 |
4 |
Incorrect |
3 ms |
384 KB |
Number of queries: 5 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
384 KB |
Number of queries: 9 |
2 |
Correct |
10 ms |
384 KB |
Number of queries: 9 |
3 |
Correct |
14 ms |
364 KB |
Number of queries: 9 |
4 |
Correct |
18 ms |
384 KB |
Number of queries: 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
31 ms |
256 KB |
Number of queries: 10 |
2 |
Incorrect |
19 ms |
384 KB |
Number of queries: 10 |
3 |
Incorrect |
19 ms |
256 KB |
Number of queries: 10 |
4 |
Incorrect |
20 ms |
384 KB |
Number of queries: 10 |