#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 ax:g[node])
{
if(ax==par)continue;
dfs(ax,node);
}
}
int findEgg (int n, vector < pair < int, int > > b)
{
for (int i = 1; i <= n; i++) g[i].clear();
a.clear();
for(auto ax:b)
{
g[ax.first].push_back(ax.second);
g[ax.second].push_back(ax.first);
}
dfs(1,-1);
int l=0;
int r=n-1;
while(l<r)
{
int mid=l+(r-l)/2;
vector<int>v;
for(int i=0;i<=mid;i++)
{
v.push_back(a[i]);
}
if(query(v)==1)
{
r=mid;
}
else
{
l=mid+1;
}
}
return a[l];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Number of queries: 4 |
2 |
Correct |
0 ms |
596 KB |
Number of queries: 4 |
3 |
Correct |
0 ms |
344 KB |
Number of queries: 4 |
4 |
Correct |
0 ms |
344 KB |
Number of queries: 4 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
728 KB |
Number of queries: 8 |
2 |
Correct |
7 ms |
728 KB |
Number of queries: 9 |
3 |
Correct |
11 ms |
740 KB |
Number of queries: 9 |
4 |
Correct |
10 ms |
744 KB |
Number of queries: 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
768 KB |
Number of queries: 9 |
2 |
Correct |
10 ms |
1000 KB |
Number of queries: 9 |
3 |
Correct |
10 ms |
984 KB |
Number of queries: 9 |
4 |
Correct |
10 ms |
748 KB |
Number of queries: 9 |