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>
using namespace std;
int query(vector < int > islands);
void dfs(int v, int p, vector<vector<int>>& adj, vector<int>& ans){
ans.push_back(v);
for(int u:adj[v]){
if(u==p)continue;
dfs(u, v, adj, ans);
}
}
int findEgg(int N, vector < pair < int, int > > bridges){
vector<int> ans;
vector<vector<int>> adj(N+1, vector<int>());
for(auto x:bridges){
adj[x.first].push_back(x.second);
adj[x.second].push_back(x.first);
}
dfs(1, 0, adj, ans);
int l=0,r=N-1;
while(r!=l){
int m=(r+l+1)/2;
if(query(vector<int>(ans.begin(), ans.begin() + m)))r=m-1;
else l=m;
}
return ans[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... |