# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
565922 | groshi | 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<iostream>
#include<vector>
#include<utility>
#include "grader.h"
using namespace std;
struct wi{
vector<int> Q;
int odw=0;
int dol=0;
}*w;
vector<int> lista;
/*bool query(vector<int> Q)
{
cout<<"pytam sie\n";
for(int i=0;i<Q.size();i++)
cout<<Q[i]<<" ";
int k;
cin>>k;
return k;
}*/
void dfs(int x,int ojc)
{
lista.push_back(x);
w[x].odw=1;
for(int i=0;i<w[x].Q.size();i++)
{
int pom=w[x].Q[i];
if(w[pom].odw==1)
continue;
dfs(pom,x);
}
}
int findEgg(int n,vector<pair<int,int> > bridges)
{
lista.clear();
w=new wi[n+3];
for(int i=0;i<bridges.size();i++)
{
int x=bridges[i].first;
int y=bridges[i].second;
w[x].Q.push_back(y);
w[y].Q.push_back(x);
}
dfs(1,0);
int pocz=0,kon=lista.size()-1,sre,lista.size()-1;
while(pocz<kon)
{
sre=(pocz+kon)/2;
vector<int> zapytaj;
for(int i=0;i<=sre;i++)
zapytaj.push_back(lista[i]);
int k=query(zapytaj);
if(k==1)
{
ostd=sre;
kon=sre;
}
else pocz=sre+1;
}
return lista[ostd];
}