답안 #645114

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
645114 2022-09-26T09:37:57 Z a_aguilo Easter Eggs (info1cup17_eastereggs) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.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);
    for(pair<int, int> bridge: bridges){
        listaAdy[bridges.second].push_back(bridges.first);
        listaAdy[bridges.first].push_back(bridges.second);
    }
    dfs(0, -1);
    int ans = 0;
    int lo = 0; hi = N-1;
    while(hi >= lo){
        int mid = lo + (hi - lo);
        vector<int> ask(mid);
        for(int i = 0; i < mid; ++i) ask[i] = order[i];
        if(query(ask)){
            hi = mid-1;
        }
        else{
            ans = mid;
            lo = mid+1;
        }
    }
    return ans+1;
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:21:26: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
   21 |         listaAdy[bridges.second].push_back(bridges.first);
      |                          ^~~~~~
eastereggs.cpp:21:52: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
   21 |         listaAdy[bridges.second].push_back(bridges.first);
      |                                                    ^~~~~
eastereggs.cpp:22:26: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
   22 |         listaAdy[bridges.first].push_back(bridges.second);
      |                          ^~~~~
eastereggs.cpp:22:51: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
   22 |         listaAdy[bridges.first].push_back(bridges.second);
      |                                                   ^~~~~~
eastereggs.cpp:26:17: error: 'hi' was not declared in this scope
   26 |     int lo = 0; hi = N-1;
      |                 ^~