Submission #895612

# Submission time Handle Problem Language Result Execution time Memory
895612 2023-12-30T11:36:01 Z maxFedorchuk Easter Eggs (info1cup17_eastereggs) C++17
0 / 100
1 ms 784 KB
#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)
    {
        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(auto [a,b]:bridges)
    {
        mas[a].push_back(b);
        mas[b].push_back(a);
    }

    for(int i=1;i<=n;i++)
    {
        pos1[i]=1;
    }

    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;
        }
    }
}
/*
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

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:127:1: warning: control reaches end of non-void function [-Wreturn-type]
  127 | }
      | ^
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 784 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 504 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -