#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
int cnt = 0;
int n;
vector<int> G[1005];
int p[1005],fr[1005];
/*int ou = 0;
bool query(vector<int> v)
{
for(auto it : v)
{
if(it==ou)
{
return true;
}
}
return false;
}
*/
void dfs(int nod, int dad = 0)
{
p[++cnt] = nod;
for(auto it : G[nod])
{
if(it==dad)
{
continue;
}
dfs(it,nod);
p[++cnt] = nod;
}
}
vector<int> get_query(int st, int dr)
{
vector<int> rez;
for(int i=st;i<=dr;i++)
{
if(!fr[p[i]])
{
rez.push_back(p[i]);
}
++fr[p[i]];
}
for(int i=st;i<=dr;i++)
{
fr[p[i]] = 0;
}
return rez;
}
int findEgg(int N, vector<pair<int,int>> e)
{
n = N;
for(auto it : e)
{
int x = it.first;
int y = it.second;
G[x].push_back(y);
G[y].push_back(x);
}
dfs(1);
int st = 1;
int dr = 2 * n - 1;
while(st<dr)
{
int mij = (st+dr)>>1;
vector<int> q = get_query(st,mij);
if(query(q))
{
dr = mij;
}
else
{
st = mij+1;
}
}
return p[st];
}
/*int main()
{
int n;
cin>>n>>ou;
vector<pair<int,int>> e;
for(int i=1;i<n;i++)
{
int x,y;
cin>>x>>y;
e.push_back({x,y});
}
cout<<findEgg(n,e);
return 0;
}
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
456 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
456 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
500 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |