Submission #1091806

#TimeUsernameProblemLanguageResultExecution timeMemory
1091806Luca1234Race (IOI11_race)C++17
Compilation error
0 ms0 KiB
#include <iostream> using namespace std; const int nmax=2e5+3; vector <pair <int, int> > v[nmax]; map <int, int> m[nmax]; int k, ans=nmax; void dfs(int nod, int parent, int d, int h) { m[nod][d]=h; for(auto [i, cost]:v[nod]) { if(i!=parent) { dfs(i, nod, d+cost, h+1); if(m[i].size()>m[nod].size) swap(m[i], m[nod]); for(auto [dist, he]:m[i]) { int caut=k-(dist+2*d); if(m[nod].count(caut)) { ans=min(ans, he+m[nod][caut]-2*h); } } for(auto [dist, he]:m[i]) { if(m[nod].count(dist)) { m[nod][dist]=min(m[nod][dist], he); } else m[nod][dist]=he; } } } } long long best_path(int n, int k, int h[][2], int l[]) { ::k=k; for(int i=0; i<n-1; i++) { int a=h[i][0], b=h[i][1]; v[a].push_back({b l[i]}); v[b].push_back({a, l[i]}); } dfs(0, -1, 0, 1); if(ans==nmax) return -1; return ans; }

Compilation message (stderr)

race.cpp:6:1: error: 'vector' does not name a type
    6 | vector <pair <int, int> > v[nmax];
      | ^~~~~~
race.cpp:7:1: error: 'map' does not name a type
    7 | map <int, int> m[nmax];
      | ^~~
race.cpp: In function 'void dfs(int, int, int, int)':
race.cpp:12:5: error: 'm' was not declared in this scope
   12 |     m[nod][d]=h;
      |     ^
race.cpp:13:24: error: 'v' was not declared in this scope
   13 |     for(auto [i, cost]:v[nod])
      |                        ^
race.cpp: In function 'long long int best_path(int, int, int (*)[2], int*)':
race.cpp:45:9: error: 'v' was not declared in this scope
   45 |         v[a].push_back({b l[i]});
      |         ^
race.cpp:45:27: error: expected '}' before 'l'
   45 |         v[a].push_back({b l[i]});
      |                        ~  ^
race.cpp:45:26: error: expected ')' before 'l'
   45 |         v[a].push_back({b l[i]});
      |                       ~  ^~
      |                          )
race.cpp:45:32: error: expected primary-expression before ')' token
   45 |         v[a].push_back({b l[i]});
      |                                ^
race.cpp:46:9: error: 'v' was not declared in this scope
   46 |         v[b].push_back({a, l[i]});
      |         ^
race.cpp:46:11: error: 'b' was not declared in this scope
   46 |         v[b].push_back({a, l[i]});
      |           ^
race.cpp:46:25: error: 'a' was not declared in this scope
   46 |         v[b].push_back({a, l[i]});
      |                         ^
race.cpp:46:30: error: 'i' was not declared in this scope
   46 |         v[b].push_back({a, l[i]});
      |                              ^
race.cpp:47:5: warning: no return statement in function returning non-void [-Wreturn-type]
   47 |     }
      |     ^
race.cpp: At global scope:
race.cpp:48:8: error: expected constructor, destructor, or type conversion before '(' token
   48 |     dfs(0, -1, 0, 1);
      |        ^
race.cpp:49:5: error: expected unqualified-id before 'if'
   49 |     if(ans==nmax) return -1;
      |     ^~
race.cpp:50:5: error: expected unqualified-id before 'return'
   50 |     return ans;
      |     ^~~~~~
race.cpp:51:1: error: expected declaration before '}' token
   51 | }
      | ^