# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
385707 | Iwanttobreakfree | Easter Eggs (info1cup17_eastereggs) | C++17 | 0 ms | 0 KiB |
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;
vector<int> c;
void conexa(vector<int>& v,vector<vector<int> >& cone,int raiz,int cont,vector<bool>& visto){
visto[raiz]=true;
for(int x: cone[raiz]){
if(v.size()==cont){
c=v;
return;
}
if(!visto[x]){
v.push_back(x+1);
c=v;
conexa(v,cone,x,cont,visto);
}
}
}
int findEgg (int N, vector < pair < int, int > > bridges){
vector<vector<int> > cone(N,vector<int>());
for(int i=0;i<N-1;i++){
cone[bridges[i].first-1].push_back(bridges[i].second-1);
cone[bridges[i].second-1].push_back(bridges[i].first-1);
}
int raiz,sol;
vector<int> v;
vector<bool> posi(N,true);
int cont=N/2;
while(cont>1){
v.clear();
for(int i=0;i<N;i++){
if(posi[i]){
raiz=i;
break;
}
}
vector<bool> visto(N,false);
conexa(v,cone,raiz,cont,visto);
v=c;
if(query(v)){
set<int> s
for(int i=0;i<v.size();i++)s.insert(v[i]-1);
for(int i=0;i<N;i++){
if(s.find(i)==s.end())posi[i]=false;
}
sol=v[0]-1;
cone[v[0]-1].clear();
posi[v[0]-1]=false;
cont/=2;
}
else {
for(int i=0;i<v.size();i++)posi[v[i]-1]=false;
}
}
return sol;
}