#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<int>g[513];
vector<int>a;
void dfs(int node,int par)
{
a.push_back(node);
for(auto idx:g[node])
{
if(idx!=par)
dfs(idx,node);
}
}
int findEgg (int n, vector < pair < int, int > > b)
{
for (int i = 1; i <= n; i++) g[i].clear();
a.clear();
for(auto idx:b)
{
g[idx.first].push_back(idx.second);
g[idx.second].push_back(idx.first);
}
dfs(1,-1);
int l=0;
int r=n-1;
while(l<r)
{
int mid=l+(r-l+1)/2;
if(query(vector<int>(a.begin(),a.begin()+mid)))r=mid-1;
else
{
l=mid;
}
}
return a[l];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Number of queries: 4 |
2 |
Correct |
1 ms |
208 KB |
Number of queries: 4 |
3 |
Correct |
1 ms |
208 KB |
Number of queries: 4 |
4 |
Correct |
1 ms |
208 KB |
Number of queries: 4 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
464 KB |
Number of queries: 8 |
2 |
Correct |
12 ms |
336 KB |
Number of queries: 9 |
3 |
Correct |
25 ms |
352 KB |
Number of queries: 9 |
4 |
Correct |
19 ms |
336 KB |
Number of queries: 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
364 KB |
Number of queries: 9 |
2 |
Correct |
12 ms |
336 KB |
Number of queries: 9 |
3 |
Correct |
19 ms |
344 KB |
Number of queries: 9 |
4 |
Correct |
17 ms |
352 KB |
Number of queries: 9 |