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;
vector <int> ord;
vector <int> graf[20005];
void dfs(int v, int par){
ord.push_back(v);
for(auto c : graf[v]){
if(c != par) dfs(c, v);
}
}
int kveri(int x){
vector <int> qq;
for(int i=1; i<=x; i++) qq.push_back(ord[i]);
return query(qq);
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
for(int i=1; i<=N; i++) graf[i].clear();
ord.clear();
ord.push_back(0);
for(auto c : bridges){
graf[c.first].push_back(c.second);
graf[c.second].push_back(c.first);
}
dfs(1, 0);
int res = 0, l = 1, r = N;
while(l <= r){
if(l == r) break;
int mid = (l+r)/2;
if(kveri(mid)){
r = mid-1;
res = mid;
}
else l = mid+1;
}
return ord[res];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |