#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<int> g[55000];
int p[55000],nrr;
void dfs(int nod=1, int t=0)
{
p[++nrr]=nod;
for(auto i:g[nod])if(i!=t)dfs(i,nod);
}
bool qq(int poz)
{
vector<int> qqq;
for(int i=1;i<=poz;i++)qqq.push_back(p[i]);
return query(qqq);
}
int findEgg(int N, vector<pair<int,int> > bridges)
{
for(int i=1;i<=N;i++)g[i].clear();
int st=1,dr=N-1,m,poz=N;
for(auto i:bridges)
{
g[i.first].push_back(i.second);
g[i.second].push_back(i.first);
}
dfs();
while(st<=dr)
{
m=st+(dr-st)/2;
if(qq(m))
{
poz=m;
dr=m-1;
}
else st=m+1;
}
//cout<<poz<<'\n';
return p[poz];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1480 KB |
Number of queries: 4 |
2 |
Correct |
2 ms |
1480 KB |
Number of queries: 4 |
3 |
Correct |
1 ms |
1480 KB |
Number of queries: 4 |
4 |
Correct |
1 ms |
1480 KB |
Number of queries: 4 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1608 KB |
Number of queries: 8 |
2 |
Correct |
10 ms |
1672 KB |
Number of queries: 9 |
3 |
Correct |
17 ms |
1684 KB |
Number of queries: 9 |
4 |
Correct |
20 ms |
1776 KB |
Number of queries: 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
1728 KB |
Number of queries: 9 |
2 |
Correct |
17 ms |
1756 KB |
Number of queries: 9 |
3 |
Correct |
18 ms |
1692 KB |
Number of queries: 9 |
4 |
Correct |
16 ms |
1608 KB |
Number of queries: 9 |