Submission #666662

# Submission time Handle Problem Language Result Execution time Memory
666662 2022-11-29T09:08:08 Z divad Easter Eggs (info1cup17_eastereggs) C++14
Compilation error
0 ms 0 KB
#include <cstring>
#include <vector>
#include <deque>
#define MAX 522
using namespace std;
int vf[MAX];
vector<int> v[MAX];
vector<int> bfs(vector< pair<int, int> > bridges){
    memset(vf, 0, sizeof(vf));
    for(int i = 0; i < MAX; i++){
        v[i].clear();
    }
    for(auto [x, y]: bridges){
        v[x].push_back(y);
        v[y].push_back(x);
    }
    deque<int> coada;
    vf[1] = 1;
    coada.push_back(1);
    while(!coada.empty()){
        int nod = coada.back();
        for(auto vecin: v[nod]){
            if(vf[vecin] == 0){
                vf[vecin] = 1+vf[nod];
                coada.push_front(vecin);
            }
        }
        coada.pop_back();
    }
}

int findEgg(int N, vector< pair<int, int> > bridges){
    vector<int> parcurgere = bfs(bridges);
    /// 0 0 0 0 1 1 1 1
    ///         ^
    int st = 0, dr = parcurgere.size()-1;
    int ans = 0;
    while(st <= dr){
        int mid = (st+dr)/2;
        vector<int> partit;
        for(int i = 0; i <= mid; i++){
            partit.push_back(parcurgere[i]);
        }
        if(query(partit)){
            ans = mid;
            dr = mid-1;
        }else{
            st = mid+1;
        }
    }
    return ans;
}

Compilation message

eastereggs.cpp: In function 'std::vector<int> bfs(std::vector<std::pair<int, int> >)':
eastereggs.cpp:13:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   13 |     for(auto [x, y]: bridges){
      |              ^
eastereggs.cpp:30:1: warning: no return statement in function returning non-void [-Wreturn-type]
   30 | }
      | ^
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:44:12: error: 'query' was not declared in this scope
   44 |         if(query(partit)){
      |            ^~~~~