Submission #605491

#TimeUsernameProblemLanguageResultExecution timeMemory
605491mychecksedadRace (IOI11_race)C++17
Compilation error
0 ms0 KiB
#include "race.h" #include <bits/stdc++.h> typedef long long int ll; const int M = 2e5 + 100; struct Edge{ int next, len; }; int n, k, sub[M], best = M; ll val[M]; vector<int> g[M]; map<int, pair<bool, int>> a[M]; void dfs(int v, int p){ int mx = 0, big = -1; for(Edge e: g[v]){ if(e.next != p && sub[e.next] > mx){ mx = sub[e.next]; big = e.next; } } for(Edge e: g[v]){ if(e.next != p && e.next != big) dfs(e.next, v); } if(big > -1) dfs(big, v), a[v].swap(a[big]); if(a[v][val[v]].first == 0){ a[v][val[v]].first = 1; }else a[v][val[v]].second = 0; for(Edge e: g[v]){ if(e.next != big && e.next != p){ for(auto p: a[e.next]){ if(a[v][k - p.first + 2 * val[v]].first == 1) best = min(best, p.second.second + a[v][k - p.first + 2 * val[v]].second); if(a[v][p.first].first == 0){ a[v][p.first] = {1, p.second.second}; }else a[v][val[v]].second = min(a[v][val[v]].second, p.second.second); } } } } void init(int v, int p, ll d){ sub[v] = 1; val[v] = d; for(Edge e: g[v]){ if(e.next != p){ dfs(e.next, v, d + e.len); sub[v] += sub[e.next]; } } } int best_path(int N, int K, int H[][2], int L[]) { best = N; n = N; k = K; Edge e; for(int i = 0; i < n-1; ++i){ e.next = H[i][1]; e.len = L[i]; g[H[i][0]].pb(e); e.next = H[i][0]; g[H[i][1]].pb(e); } init(1, 0, 0); dfs(1, 0); return best; }

Compilation message (stderr)

race.cpp:13:1: error: 'vector' does not name a type
   13 | vector<int> g[M];
      | ^~~~~~
race.cpp:14:1: error: 'map' does not name a type
   14 | map<int, pair<bool, int>> a[M];
      | ^~~
race.cpp: In function 'void dfs(int, int)':
race.cpp:20:17: error: 'g' was not declared in this scope
   20 |     for(Edge e: g[v]){
      |                 ^
race.cpp:26:17: error: 'g' was not declared in this scope
   26 |     for(Edge e: g[v]){
      |                 ^
race.cpp:31:22: error: 'a' was not declared in this scope
   31 |         dfs(big, v), a[v].swap(a[big]);
      |                      ^
race.cpp:33:8: error: 'a' was not declared in this scope
   33 |     if(a[v][val[v]].first == 0){
      |        ^
race.cpp:37:17: error: 'g' was not declared in this scope
   37 |     for(Edge e: g[v]){
      |                 ^
race.cpp:39:25: error: 'a' was not declared in this scope
   39 |             for(auto p: a[e.next]){
      |                         ^
race.cpp:40:70: error: 'min' was not declared in this scope; did you mean 'std::min'?
   40 |                 if(a[v][k - p.first + 2 * val[v]].first == 1) best = min(best, p.second.second + a[v][k - p.first + 2 * val[v]].second);
      |                                                                      ^~~
      |                                                                      std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from race.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
race.cpp:43:45: error: 'min' was not declared in this scope; did you mean 'std::min'?
   43 |                 }else a[v][val[v]].second = min(a[v][val[v]].second, p.second.second);
      |                                             ^~~
      |                                             std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from race.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
race.cpp: In function 'void init(int, int, ll)':
race.cpp:53:17: error: 'g' was not declared in this scope
   53 |     for(Edge e: g[v]){
      |                 ^
race.cpp:55:37: error: too many arguments to function 'void dfs(int, int)'
   55 |             dfs(e.next, v, d + e.len);
      |                                     ^
race.cpp:18:6: note: declared here
   18 | void dfs(int v, int p){
      |      ^~~
race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:71:9: error: 'g' was not declared in this scope
   71 |         g[H[i][0]].pb(e);
      |         ^