#include <vector>
#include <utility>
#include "grader.h"
#define MAX_N 513
#define MAX_M (2*MAX_N)
int head[MAX_N], vv[MAX_M], nxt[MAX_M], eo,timer,tin[MAX_N],aux[MAX_N];
void link(int u,int v)
{
int i=++eo;
nxt[i]=head[u],vv[i]=v;
head[u]=i;
}
void dfs(int u,int p)
{
aux[tin[u]=timer++]=u;
for(int j=head[u];j;j=nxt[j])if(p-vv[j])dfs(vv[j],u);
}
int findEgg(int n,std::vector<std::pair<int, int> >bridges)
{
for(int i=1;i<=n;++i)head[i]=eo=timer=0;
for(auto[u,v]:bridges)link(u,v),link(v,u);
dfs(1,1);
int lower=-1,upper=n;
while(upper-lower>1)
{
int mid=lower+(upper-lower)/2;
std::vector<int>q;
for(int i=0;i<=mid;++i)q.push_back(aux[i]);
if(query(q))upper=mid;
else lower=mid;
}
return aux[upper];
}
/* int query(std::vector<int> islands) */
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
352 KB |
Number of queries: 5 |
2 |
Partially correct |
1 ms |
344 KB |
Number of queries: 5 |
3 |
Partially correct |
1 ms |
600 KB |
Number of queries: 5 |
4 |
Partially correct |
1 ms |
344 KB |
Number of queries: 5 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
720 KB |
Number of queries: 9 |
2 |
Correct |
6 ms |
980 KB |
Number of queries: 9 |
3 |
Correct |
9 ms |
980 KB |
Number of queries: 9 |
4 |
Correct |
10 ms |
1236 KB |
Number of queries: 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
11 ms |
1004 KB |
Number of queries: 10 |
2 |
Correct |
13 ms |
1488 KB |
Number of queries: 9 |
3 |
Correct |
9 ms |
976 KB |
Number of queries: 9 |
4 |
Correct |
13 ms |
724 KB |
Number of queries: 9 |