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;
const int mx=550;
vector<int> g[mx],order;
void dfs(int u,int p) {
order.push_back(u);
for(int v:g[u]) {
if(v!=p) dfs(v,u);
}
}
int findEgg (int N,vector<pair<int,int>> bridges){
order.clear();
for(int i=0;i<mx;++i) g[i].clear();
for(int i=0;i<N-1;++i) {
int u=bridges[i].first,v=bridges[i].second;
g[u].push_back(v);
g[v].push_back(u);
}
dfs(1,0);
int l=0,r=N-1;
while(l<r) {
int mid=(l+r)/2;
vector<int> temp;
for(int i=0;i<=mid;++i) {
temp.push_back(order[i]);
}
if(query(temp)) {
r=mid;
} else {
l=mid+1;
}
}
return order[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... |