답안 #666660

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
666660 2022-11-29T09:07:46 Z divad Easter Eggs (info1cup17_eastereggs) C++14
컴파일 오류
0 ms 0 KB
#include <cstring>
#include <vector>
#include <deque>
#define MAX 522
int vf[MAX];
vector<int> v[MAX];
vector<int> bfs(vector< pair<int, int> > bridges){
    memset(vf, 0, sizeof(vf));
    for(int i = 0; i < MAX; i++){
        v[i].clear();
    }
    for(auto [x, y]: bridges){
        v[x].push_back(y);
        v[y].push_back(x);
    }
    deque<int> coada;
    vf[1] = 1;
    coada.push_back(1);
    while(!coada.empty()){
        int nod = coada.back();
        for(auto vecin: v[nod]){
            if(vf[vecin] == 0){
                vf[vecin] = 1+vf[nod];
                coada.push_front(vecin);
            }
        }
        coada.pop_back();
    }
}

int findEgg(int N, vector< pair<int, int> > bridges){
    vector<int> parcurgere = bfs(bridges);
    /// 0 0 0 0 1 1 1 1
    ///         ^
    int st = 0, dr = parcurgere.size()-1;
    int ans = 0;
    while(st <= dr){
        int mid = (st+dr)/2;
        vector<int> partit;
        for(int i = 0; i <= mid; i++){
            partit.push_back(parcurgere[i]);
        }
        if(query(partit)){
            ans = mid;
            dr = mid-1;
        }else{
            st = mid+1;
        }
    }
    return ans;
}

Compilation message

eastereggs.cpp:6:1: error: 'vector' does not name a type
    6 | vector<int> v[MAX];
      | ^~~~~~
eastereggs.cpp:7:1: error: 'vector' does not name a type
    7 | vector<int> bfs(vector< pair<int, int> > bridges){
      | ^~~~~~
eastereggs.cpp:31:20: error: 'vector' has not been declared
   31 | int findEgg(int N, vector< pair<int, int> > bridges){
      |                    ^~~~~~
eastereggs.cpp:31:26: error: expected ',' or '...' before '<' token
   31 | int findEgg(int N, vector< pair<int, int> > bridges){
      |                          ^
eastereggs.cpp: In function 'int findEgg(int, int)':
eastereggs.cpp:32:5: error: 'vector' was not declared in this scope; did you mean 'std::vector'?
   32 |     vector<int> parcurgere = bfs(bridges);
      |     ^~~~~~
      |     std::vector
In file included from /usr/include/c++/10/vector:67,
                 from eastereggs.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:389:11: note: 'std::vector' declared here
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
eastereggs.cpp:32:12: error: expected primary-expression before 'int'
   32 |     vector<int> parcurgere = bfs(bridges);
      |            ^~~
eastereggs.cpp:35:22: error: 'parcurgere' was not declared in this scope
   35 |     int st = 0, dr = parcurgere.size()-1;
      |                      ^~~~~~~~~~
eastereggs.cpp:39:16: error: expected primary-expression before 'int'
   39 |         vector<int> partit;
      |                ^~~
eastereggs.cpp:41:13: error: 'partit' was not declared in this scope
   41 |             partit.push_back(parcurgere[i]);
      |             ^~~~~~
eastereggs.cpp:43:18: error: 'partit' was not declared in this scope
   43 |         if(query(partit)){
      |                  ^~~~~~
eastereggs.cpp:43:12: error: 'query' was not declared in this scope
   43 |         if(query(partit)){
      |            ^~~~~