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 MAXN=515;
vector<int> adj[MAXN];
int preorder[MAXN],nomor[MAXN],idx;
void dfs(int now,int par){
idx++;
preorder[idx]=now;
for(auto nxt : adj[now]){
if(nxt==par)continue;
dfs(nxt,now);
}
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
idx=0;
for(int i=1;i<=N;i++)adj[i].clear();
for(int i=0;i<N-1;i++){
adj[bridges[i].first].push_back(bridges[i].second);
adj[bridges[i].second].push_back(bridges[i].first);
}
dfs(1,-1);
int ki=1,ka=N;
while(ki<ka){
// cout << ki << " " << ka << endl;
int mid=(ki+ka)/2;
vector<int> v;
for(int i=1;i<=mid;i++)v.push_back(preorder[i]);
if(query(v)){
ka=mid;
}
else ki=mid+1;
}
return preorder[ki];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |