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>
#include "grader.h"
using namespace std;
#define ff first
#define ss second
vector<int> o;
vector<vector<int> > v;
void dfs(int a, int p){
o.push_back(a);
for(auto node: v[a]){
if(node!=p){
dfs(node,a);
}
}
}
int findEgg(int N, vector<pair<int,int> > bridges){
o.clear();
v.clear(),v.resize(N+1);
for(auto p: bridges){
v[p.ff].push_back(p.ss);
v[p.ss].push_back(p.ff);
}
dfs(1,1);
int l=0,r=N-1;
while(l<=r){
int m=l+(r-l)/2;
vector<int> c(m+1);
for(int i=0; i<=m; i++) c[i]=o[i];
if(query(c)) r=m-1;
else l=m+1;
}
return o[l];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |