제출 #527516

#제출 시각아이디문제언어결과실행 시간메모리
527516KindaNameless경주 (Race) (IOI11_race)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;

const int lim = 200;
vector<pair<int, int>> adj[lim + 5];
map<int, int> paths[lim + 5];
int sz[lim + 5];
int n, k, answer = 1e9;

void dfs(int cur = 1, int par = -1){
    for(pair<int, int> ch : adj[cur]){
        if(ch.first == par)continue;

        dfs(ch.first, cur);

//        if((int)paths[ch.first].size() > (int)paths[cur].size()){
//            paths[cur].swap(paths[ch.first]);
//        }
        paths[cur][ch.second] = 1;
        for(pair<int, int> elem : paths[ch.first]){
            if(elem.first + ch.second > k)continue;
            if(paths[cur].count(k - elem.first - ch.second)){
                answer = min(answer, elem.second + 1 + paths[cur][k - elem.first - ch.second]);
            }
            paths[cur][elem.first + ch.second] = elem.second + 1;
        }
        paths[ch.first].clear();
    }
}

int best_path(int N, int K, int H[][2], L[]){
    n = N; k = K;
    for(int i = 0; i < N-1; ++i){
        int u = H[i].first + 1, v = H[i].second + 1;
        adj[u].push_back({v, L[i]});
        adj[v].push_back({u, L[i]});
    }
    for(int i = 1; i <= N; ++i){
        paths[i][0] = 0;
    }

    dfs();

    return (answer == 1e9 ? -1 : answer);
}

컴파일 시 표준 에러 (stderr) 메시지

race.cpp:31:41: error: 'L' has not been declared
   31 | int best_path(int N, int K, int H[][2], L[]){
      |                                         ^
race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:34:22: error: request for member 'first' in '*(H + ((sizetype)(((long unsigned int)i) * 8)))', which is of non-class type 'int [2]'
   34 |         int u = H[i].first + 1, v = H[i].second + 1;
      |                      ^~~~~
race.cpp:35:27: error: 'v' was not declared in this scope
   35 |         adj[u].push_back({v, L[i]});
      |                           ^
race.cpp:35:30: error: 'L' was not declared in this scope
   35 |         adj[u].push_back({v, L[i]});
      |                              ^
race.cpp:35:35: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
   35 |         adj[u].push_back({v, L[i]});
      |                                   ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from race.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~