#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
using namespace std;
vector<int>vv;
vector<int>v[512];
void dfs (int x,int p)
{
vv.push_back(x);
for(auto it:v[x])
{
if (it==p)continue;
dfs(it,x);
}
}
vector<int>o;
int query(vector < int > islands);
int q (int m)
{
o.clear();
for(int i=0;i<=m;i++)o.push_back(vv[i]);
return query(o);
}
int findEgg(int n, vector < pair < int, int > > bridges)
{
for(int i=0;i<n-1;i++)
{
int x=bridges[i].first,y=bridges[i].second;
v[x].push_back(y);
v[y].push_back(x);
}
dfs(1,0);
int st=0,end=vv.size()-1;
while (st<end)
{
// cout<<st<<" "<<end<<endl;
int m=(st+end)/2;
if (q(m))
{
end=m;continue;
}
st=m+1;
}
return vv[st];
}
/*
vector<pair<int,int>>o;
int main()
{
int n;cin>>n;
for(int i=0;i<n-1;i++)
{
int x,y;cin>>x>>y;
o.push_back({x,y});
}
cout<<findEgg(n,o);
}
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
309 ms |
131076 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5 ms |
2932 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |