답안 #645111

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
645111 2022-09-26T09:37:20 Z a_aguilo Easter Eggs (info1cup17_eastereggs) C++14
컴파일 오류
0 ms 0 KB
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:1:1: error: 'vector' does not name a type
    1 | vector<int> order;
      | ^~~~~~
eastereggs.cpp:2:1: error: 'vector' does not name a type
    2 | vector<vector<int>> listaAdy;
      | ^~~~~~
eastereggs.cpp: In function 'void dfs(int, int)':
eastereggs.cpp:5:5: error: 'order' was not declared in this scope
    5 |     order.push_back(nodo);
      |     ^~~~~
eastereggs.cpp:6:21: error: 'listaAdy' was not declared in this scope
    6 |     for(int vecino: listaAdy[nodo]){
      |                     ^~~~~~~~
eastereggs.cpp: At global scope:
eastereggs.cpp:12:21: error: 'vector' has not been declared
   12 | int findEgg (int N, vector < pair < int, int > > bridges)
      |                     ^~~~~~
eastereggs.cpp:12:28: error: expected ',' or '...' before '<' token
   12 | int findEgg (int N, vector < pair < int, int > > bridges)
      |                            ^
eastereggs.cpp: In function 'int findEgg(int, int)':
eastereggs.cpp:14:5: error: 'listaAdy' was not declared in this scope
   14 |     listaAdy = vector<vector<int>>(N+1);
      |     ^~~~~~~~
eastereggs.cpp:14:16: error: 'vector' was not declared in this scope
   14 |     listaAdy = vector<vector<int>>(N+1);
      |                ^~~~~~
eastereggs.cpp:14:30: error: expected primary-expression before 'int'
   14 |     listaAdy = vector<vector<int>>(N+1);
      |                              ^~~
eastereggs.cpp:15:9: error: 'pair' was not declared in this scope
   15 |     for(pair<int, int> bridge: bridges){
      |         ^~~~
eastereggs.cpp:15:14: error: expected primary-expression before 'int'
   15 |     for(pair<int, int> bridge: bridges){
      |              ^~~
eastereggs.cpp:19:8: error: could not convert 'dfs(0, -1)' from 'void' to 'bool'
   19 |     dfs(0, -1);
      |     ~~~^~~~~~~
      |        |
      |        void
eastereggs.cpp:20:5: error: expected primary-expression before 'int'
   20 |     int ans = 0;
      |     ^~~
eastereggs.cpp:19:16: error: expected ')' before 'int'
   19 |     dfs(0, -1);
      |                ^
      |                )
   20 |     int ans = 0;
      |     ~~~         
eastereggs.cpp:15:8: note: to match this '('
   15 |     for(pair<int, int> bridge: bridges){
      |        ^
eastereggs.cpp:20:9: warning: unused variable 'ans' [-Wunused-variable]
   20 |     int ans = 0;
      |         ^~~
eastereggs.cpp:21:17: error: 'hi' was not declared in this scope
   21 |     int lo = 0; hi = N-1;
      |                 ^~
eastereggs.cpp:24:16: error: expected primary-expression before 'int'
   24 |         vector<int> ask(mid);
      |                ^~~
eastereggs.cpp:25:38: error: 'ask' was not declared in this scope
   25 |         for(int i = 0; i < mid; ++i) ask[i] = order[i];
      |                                      ^~~
eastereggs.cpp:25:47: error: 'order' was not declared in this scope
   25 |         for(int i = 0; i < mid; ++i) ask[i] = order[i];
      |                                               ^~~~~
eastereggs.cpp:26:18: error: 'ask' was not declared in this scope
   26 |         if(query(ask)){
      |                  ^~~
eastereggs.cpp:26:12: error: 'query' was not declared in this scope
   26 |         if(query(ask)){
      |            ^~~~~
eastereggs.cpp:30:13: error: 'ans' was not declared in this scope
   30 |             ans = mid;
      |             ^~~
eastereggs.cpp:34:12: error: 'ans' was not declared in this scope
   34 |     return ans+1;
      |            ^~~