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 = 520;
vector<int> adj[MAXN], v;
void dfs(int s, int p){
v.push_back(s);
for(int viz : adj[s])
if(viz != p)dfs(viz,s);
}
int findEgg (int n, vector < pair < int, int > > bridges)
{
for(int i = 1; i <= n; i++)adj[i].clear();
v.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,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(v[i]);
if(query(temp) == 1)r = mid;
else l = mid+1;
}
return v[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... |