답안 #659624

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
659624 2022-11-18T19:07:13 Z a_aguilo Easter Eggs (info1cup17_eastereggs) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

vector<int> order;
vector<vector<int>> listaAdy;

void dfs(int nodo, int padre){
    order.push_back(nodo);
    for(int vecino: listaAdy[nodo]){
        if(vecino == padre) continue;
        dfs(vecino, nodo);
    }
}

int findEgg (int N, vector < pair < int, int > > bridges)
{
    listaAdy = vector<vector<int>>(N+1);
    order = vector<int>();
    for(pair<int, int> bridge: bridges){
        listaAdy[bridge.second].push_back(bridge.first);
        listaAdy[bridge.first].push_back(bridge.second);
    }
    dfs(1, -1);
    int ans = 0;
    int lo = 0; int hi = N-1;
    vector<int> ask((N-1)/2);
    while(hi >= lo){
        int mid = lo + (hi - lo);
        while(ask.size() < mid){
            ask.push_back(order[ask.size()]);
        }
        while(ask.size() > mid) ask.pop_back();
        if(query(ask)){
            hi = mid-1;
        }
        else{
            ans = mid;
            lo = mid+1;
        }
    }
    return order[ans];
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:30:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |         while(ask.size() < mid){
      |               ~~~~~~~~~~~^~~~~
eastereggs.cpp:33:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   33 |         while(ask.size() > mid) ask.pop_back();
      |               ~~~~~~~~~~~^~~~~
eastereggs.cpp:34:12: error: 'query' was not declared in this scope
   34 |         if(query(ask)){
      |            ^~~~~