#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=l;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 |
0 ms |
344 KB |
Number of queries: 4 |
2 |
Runtime error |
0 ms |
444 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
752 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |