This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#include"grader.h"
#define N 1000
int id[N],sz;
vector<int> g[N];
void dfs(int s,int f){
id[++sz]=s;
for(auto x:g[s]){
if(x==f)continue;
dfs(x,s);
}
}
int findEgg(int n, vector<pair<int,int>> edge){
int i,l,r,mid,flag;
for(i=1;i<=n;i++)g[i].clear();
for(auto [a,b]:edge){
g[a].push_back(b);
g[b].push_back(a);
}
sz=0;
dfs(1,0);
vector<int> v;
l=1,r=n;
while(l<r){
mid=(l+r)/2;
for(i=1;i<=mid;i++)v.push_back(id[i]);
flag=query(v);
if(flag){
for(i=1;i<=mid;i++)v.pop_back();
r=mid;
}
else{
l=mid+1;
}
}
return id[r];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |