# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
565917 | groshi | Easter Eggs (info1cup17_eastereggs) | C++17 | 3 ms | 720 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;
int egg=-1;
int ile=0;
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)
{
w=new wi[n+3];
egg=-1;
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);
//for(int i=0;i<lista.size();i++)
//cout<<lista[i]<<" ";
int pocz=0,kon=lista.size()+1,sre,ostd;
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-1;
kon=sre;
}
else pocz=sre+1;
}
return lista[ostd];
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |