제출 #1304552

#제출 시각아이디문제언어결과실행 시간메모리
1304552h1drogen경주 (Race) (IOI11_race)C++20
컴파일 에러
0 ms0 KiB
int best_path(int N, int K, int H[][2], int L[]) { vector<vector<pair<int,int>>> g(N); for(int i=0;i<N-1;i++){ g[H[i][0]].push_back({H[i][1], L[i]}); g[H[i][1]].push_back({H[i][0], L[i]}); } int answer = INT_MAX; function<void(int,int,int,int)> dfs = [&](int v,int p,int length,int edges){ if(length == K){ answer = min(answer, edges); return; } if(length > K) return; for(auto [u,w]: g[v]){ if(u != p){ dfs(u, v, length+w, edges+1); } } }; for(int i=0;i<N;i++){ dfs(i,-1,0,0); } return answer == INT_MAX ? -1 : answer; }

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

race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:2:19: error: 'pair' was not declared in this scope
    2 |     vector<vector<pair<int,int>>> g(N);
      |                   ^~~~
race.cpp:2:12: error: 'vector' was not declared in this scope
    2 |     vector<vector<pair<int,int>>> g(N);
      |            ^~~~~~
race.cpp:2:24: error: expected primary-expression before 'int'
    2 |     vector<vector<pair<int,int>>> g(N);
      |                        ^~~
race.cpp:4:9: error: 'g' was not declared in this scope
    4 |         g[H[i][0]].push_back({H[i][1], L[i]});
      |         ^
race.cpp:8:18: error: 'INT_MAX' was not declared in this scope
    8 |     int answer = INT_MAX;
      |                  ^~~~~~~
race.cpp:1:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
  +++ |+#include <climits>
    1 | int best_path(int N, int K, int H[][2], int L[]) {
race.cpp:10:5: error: 'function' was not declared in this scope; did you mean 'union'?
   10 |     function<void(int,int,int,int)> dfs = [&](int v,int p,int length,int edges){
      |     ^~~~~~~~
      |     union
race.cpp:10:34: error: expression list treated as compound expression in functional cast [-fpermissive]
   10 |     function<void(int,int,int,int)> dfs = [&](int v,int p,int length,int edges){
      |                                  ^
race.cpp:10:14: error: expected primary-expression before 'void'
   10 |     function<void(int,int,int,int)> dfs = [&](int v,int p,int length,int edges){
      |              ^~~~
race.cpp:24:9: error: 'dfs' was not declared in this scope
   24 |         dfs(i,-1,0,0);
      |         ^~~