#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
vector<int> ord;
vector<vector<int> > graph;
void dfs(int node, int par){
ord.pb(node);
for (auto num:graph[node])if (num!=par)dfs(num, node);
}
int findEgg (int n, vector<pii> edges){
graph.clear();
ord.clear();
graph.resize(n+1);
for (auto c:edges){
graph[c.fi].pb(c.se);
graph[c.se].pb(c.fi);
}
dfs(1, -1);
int low=0, high=n;
while (low+1<high){
int mid=(low+high)/2;
vector<int> temp;
for (int i=0; i<mid; ++i)temp.pb(ord[i]);
if (query(temp))high=mid;
else low=mid;
}
return ord[high-1];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |