Submission #864276

# Submission time Handle Problem Language Result Execution time Memory
864276 2023-10-22T09:56:48 Z gutzzy Easter Eggs (info1cup17_eastereggs) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

int fingEgg(int n, vector<pair<int, int>>bridges){
    // vector 1D de todas las islas
    vector<vector<int>> lst(n,vector<int>());
    
    for(auto b:bridges){
        lst[b.first-1].push_back(b.second-1);
        lst[b.second-1].push_back(b.first-1);
    }
    
    vector<int> islands;
    
    int isl=0;
    while((int) lst[isl].size()!=1) isl++;          // busco un extremo
    
    
    islands.push_back(isl);
    int l_isl = isl;
    isl = lst[l_isl][0];
    islands.push_back(isl);
    
    while((int) islands.size() != n){
        int t = isl;
        if(lst[isl][0]==l_isl) isl = lst[isl][1];
        else isl = lst[isl][1];
        l_isl = t;
        islands.push_back(isl);
    }
    
    // binary search
    
    int l = 0;
    int r = n-1;
    while(l<=r){
        int m = (l+r)/2;
        bool egg = query({islands.begin(),islands.begin()+m});
        if(egg) r = m-1;
        else l = m+1;
    }
    return l;
}

Compilation message

eastereggs.cpp: In function 'int fingEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:38:20: error: 'query' was not declared in this scope
   38 |         bool egg = query({islands.begin(),islands.begin()+m});
      |                    ^~~~~