Submission #864990

# Submission time Handle Problem Language Result Execution time Memory
864990 2023-10-23T21:44:44 Z gutzzy Easter Eggs (info1cup17_eastereggs) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
//#include "grader.h"
using namespace std;

vector<int> islands;
vector<bool> visited;
vector<vector<int>> lst;

void dfs(int nodo){
    visited[nodo] = true;
    islands.push_back(nodo);
    for(int vecino:lst[nodo]){
        if(!visited[vecino]) dfs(vecino);
    }
}

int findEgg(int n, vector<pair<int, int>>bridges){
    // vector 1D de todas las islas
    lst = vector<vector<int>>(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);
    }
    
    visited = vector<bool>(n,false);
    dfs(0);
    
    // 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 findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:35:20: error: 'query' was not declared in this scope
   35 |         bool egg = query({islands.begin(),islands.begin()+m});
      |                    ^~~~~