# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
895625 | maxFedorchuk | Easter Eggs (info1cup17_eastereggs) | C++14 | 17 ms | 488 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;
const long long MX=600;
vector < int > mas[MX];
int pos1[MX];
int pos2[MX];
/*
int query(vector < int > islands)
{
for(auto u:islands)
{
cout<<u<<" ";
}
cout<<"\n";
int ans;
cin>>ans;
return ans;
}
*/
vector < int > chk(int k1,int n)
{
for(int i=1;i<=n;i++)
{
pos2[i]=0;
}
queue < int > q;
q.push(1);
int zlk1=k1;
while(zlk1!=0)
{
if(q.empty())
{
while(true)
{
zlk1=1;
}
}
int zar=q.front();
q.pop();
pos2[zar]=1;
zlk1-=pos1[zar];
for(auto vr:mas[zar])
{
if(!pos2[vr])
{
q.push(vr);
}
}
}
vector < int > zap;
for(int i=1;i<=n;i++)
{
if(pos2[i])
{
zap.push_back(i);
}
}
return zap;
}
int findEgg(int n, vector < pair < int, int > > bridges)
{
for(int i=1;i<=n;i++)
{
pos1[i]=1;
mas[i].clear();
}
for(auto [a,b]:bridges)
{
mas[a].push_back(b);
mas[b].push_back(a);
}
int k1=n;
while(k1!=1)
{
int nwk1=k1/2;
if(query(chk(nwk1,n)))
{
for(int i=1;i<=n;i++)
{
if(pos1[i] && pos2[i])
{
pos1[i]=1;
}
else
{
pos1[i]=0;
}
}
k1=nwk1;
}
else
{
for(int i=1;i<=n;i++)
{
if(pos1[i] && !pos2[i])
{
pos1[i]=1;
}
else
{
pos1[i]=0;
}
}
k1-=nwk1;
}
}
for(int i=1;i<=n;i++)
{
if(pos1[i]==1)
{
return i;
}
}
while(true)
{
k1=0;
}
return 0;
}
/*
int main()
{
//cin.tie(0);
//ios_base::sync_with_stdio(0);
int n=5;
vector < pair < int , int > > bridges(n-1);
bridges[0]=make_pair(1,2);
bridges[1]=make_pair(1,3);
bridges[2]=make_pair(2,4);
bridges[3]=make_pair(4,5);
cout<<findEgg(n,bridges)<<"\n";
return 0;
}
*/
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... |