답안 #676690

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
676690 2022-12-31T17:51:51 Z LucaLucaM Easter Eggs (info1cup17_eastereggs) C++17
컴파일 오류
0 ms 0 KB
vector<int>v[513];
vector<int>order;
void dfs (int x, int par)
{
    order.push_back(x);
    for (int i : v[x])
    {
        if (i == par)
            continue;
        dfs(i, x);
    }
}

int findEgg(int N, vector < pair < int, int > > bridges)
{
    for (pair<int, int>p : bridges)
    {
        v[p.first].push_back(p.second);
        v[p.second].push_back(p.first);
    }

    dfs(1, -1);

    int l=1, r=N;
    while (l < r)
    {
        int mid = (l + r) / 2;

        vector<int>curr;
        for (int i=0; i<mid; i++)
            curr.push_back(order[i]);

        if (query(curr))
            r = mid;
        else
            l = mid + 1;
    }

    return order[r-1];
}

Compilation message

eastereggs.cpp:1:1: error: 'vector' does not name a type
    1 | vector<int>v[513];
      | ^~~~~~
eastereggs.cpp:2:1: error: 'vector' does not name a type
    2 | vector<int>order;
      | ^~~~~~
eastereggs.cpp: In function 'void dfs(int, int)':
eastereggs.cpp:5:5: error: 'order' was not declared in this scope
    5 |     order.push_back(x);
      |     ^~~~~
eastereggs.cpp:6:18: error: 'v' was not declared in this scope
    6 |     for (int i : v[x])
      |                  ^
eastereggs.cpp: At global scope:
eastereggs.cpp:14:20: error: 'vector' has not been declared
   14 | int findEgg(int N, vector < pair < int, int > > bridges)
      |                    ^~~~~~
eastereggs.cpp:14:27: error: expected ',' or '...' before '<' token
   14 | int findEgg(int N, vector < pair < int, int > > bridges)
      |                           ^
eastereggs.cpp: In function 'int findEgg(int, int)':
eastereggs.cpp:16:10: error: 'pair' was not declared in this scope
   16 |     for (pair<int, int>p : bridges)
      |          ^~~~
eastereggs.cpp:16:15: error: expected primary-expression before 'int'
   16 |     for (pair<int, int>p : bridges)
      |               ^~~
eastereggs.cpp:22:8: error: could not convert 'dfs(1, -1)' from 'void' to 'bool'
   22 |     dfs(1, -1);
      |     ~~~^~~~~~~
      |        |
      |        void
eastereggs.cpp:24:5: error: expected primary-expression before 'int'
   24 |     int l=1, r=N;
      |     ^~~
eastereggs.cpp:22:16: error: expected ')' before 'int'
   22 |     dfs(1, -1);
      |                ^
      |                )
   23 | 
   24 |     int l=1, r=N;
      |     ~~~         
eastereggs.cpp:16:9: note: to match this '('
   16 |     for (pair<int, int>p : bridges)
      |         ^
eastereggs.cpp:24:9: warning: unused variable 'l' [-Wunused-variable]
   24 |     int l=1, r=N;
      |         ^
eastereggs.cpp:24:14: warning: unused variable 'r' [-Wunused-variable]
   24 |     int l=1, r=N;
      |              ^
eastereggs.cpp:25:12: error: 'l' was not declared in this scope
   25 |     while (l < r)
      |            ^
eastereggs.cpp:25:16: error: 'r' was not declared in this scope
   25 |     while (l < r)
      |                ^
eastereggs.cpp:29:9: error: 'vector' was not declared in this scope
   29 |         vector<int>curr;
      |         ^~~~~~
eastereggs.cpp:29:16: error: expected primary-expression before 'int'
   29 |         vector<int>curr;
      |                ^~~
eastereggs.cpp:31:13: error: 'curr' was not declared in this scope
   31 |             curr.push_back(order[i]);
      |             ^~~~
eastereggs.cpp:31:28: error: 'order' was not declared in this scope
   31 |             curr.push_back(order[i]);
      |                            ^~~~~
eastereggs.cpp:33:19: error: 'curr' was not declared in this scope
   33 |         if (query(curr))
      |                   ^~~~
eastereggs.cpp:33:13: error: 'query' was not declared in this scope
   33 |         if (query(curr))
      |             ^~~~~
eastereggs.cpp:39:12: error: 'order' was not declared in this scope
   39 |     return order[r-1];
      |            ^~~~~
eastereggs.cpp:39:18: error: 'r' was not declared in this scope
   39 |     return order[r-1];
      |                  ^