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> h);
int findEgg (int N, vector < pair < int, int > > bridges){
vector<vector<int>> t(N+1);
for(auto [a,b]:bridges){
t[a].push_back(b);
t[b].push_back(a);
}
set<int> s;
for(int i=1;i<=N;i++) s.insert(i);
while(s.size()>1){
vector<bool>vis(N+1);
set<int> e;
function<void(int)> dfs = [&] (int nd){
vis[nd]=1;
if(e.size()<(s.size()/2)) e.insert(nd);
else return;
for(auto u : t[nd])
if(!vis[u] && s.find(u)!=s.end())
dfs(u);
};
dfs(*s.begin());
if(!query(vector(e.begin(), e.end()))){
set<int> m;
for(auto x : s)
if(e.find(x)==e.end())
m.insert(x);
s = m;
}else
s=e;
}
return *s.begin();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |