Submission #931336

#TimeUsernameProblemLanguageResultExecution timeMemory
931336Ice_manRace (IOI11_race)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "race.h" #include <vector> using namespace std; vector <pair <int, int>> v[maxn]; int sz[maxn]; int used[maxn]; int find_sz(int node, int parent) { sz[node] = 1; for(pair <int, int> e : v[node]) { if(e.X == parent || used[e.X] == true) continue; sz[node] += find_sz(nb); } return sz[node]; } int find_centroid(int node, int parent, int _sz) { for(pair <int, int> e : v[node]) { if(e.X == parent || used[e.X] == true) continue; if(sz[e.X] * 2 > _sz) return find_centroid(e.X, node, _sz); } return node; } int c = 1e8; int answer = INF; int help[maxn]; void dfs1(int node, int parent, int depth, int weight, int k) { if(weight > 0 && weight <= k) help[weight] = c; if(k > weight) help[k - weight] = c; for(pair <int, int> e : v[node]) { if(e.X == parent || used[e.X] == true) continue; dfs1(e.X, node, depth + 1, weight + e.Y, k); } } void dfs2(int node, int parent, int depth, int weight, int k) { if(weight <= k && parent != -1) ans = min(ans, help[k - weight] + depth); for(pair <int, int> e : v[node]) { if(e.X == parent || used[e.X] == true) continue; dfs2(e.X, node, depth + 1, weight + e.Y, k); } } void dfs3(int node, int parent, int depth, int weight, int k) { if (k >= weight && par != -1) help[weight] = min(help[weight], depth); for (pair <int, int> e : v[node]) { if (e.X == par || used[e.X]) continue; dfs1(e.X, node, depth + 1, weight + e.Y); } } void decompose(int node , int k) { int cur_sz = find_sz(node); int centroid = find_centroid(node , -1 , cur_sz); used[centroid] = true; for(pair <int , int> e : v[centroid]) { if(used[e.X] == true) continue; dfs1(e.X , centroid , 1 , e.Y , k); } for(pair <int , int> e : v[centroid]) { if(used[e.X] == true) continue; dfs2(e.X, centroid , 1 , e.Y , k); dfs3(e.X , centroid , 1 , e.Y , k); } for(pair <int , int> e : v[centroid]) { if(used[e.X] == true) continue; decompose(e.X , k); } } int best_path(int n , int k , int h[][2] , int l[]) { for(int i = 0; i < n - 1; i++) { v[h[i][0]].push_back({h[i][1] , l[i]}); v[h[i][1]].push_back({h[i][0] , l[i]}); } help[0] = 0; decompose(0 , k); if(ans > n) return -1; return ans; }

Compilation message (stderr)

race.cpp:7:28: error: 'maxn' was not declared in this scope
    7 | vector <pair <int, int>> v[maxn];
      |                            ^~~~
race.cpp:8:8: error: 'maxn' was not declared in this scope
    8 | int sz[maxn];
      |        ^~~~
race.cpp:10:10: error: 'maxn' was not declared in this scope
   10 | int used[maxn];
      |          ^~~~
race.cpp: In function 'int find_sz(int, int)':
race.cpp:15:5: error: 'sz' was not declared in this scope
   15 |     sz[node] = 1;
      |     ^~
race.cpp:17:29: error: 'v' was not declared in this scope
   17 |     for(pair <int, int> e : v[node])
      |                             ^
race.cpp:19:14: error: 'struct std::pair<int, int>' has no member named 'X'
   19 |         if(e.X == parent || used[e.X] == true)
      |              ^
race.cpp:19:29: error: 'used' was not declared in this scope
   19 |         if(e.X == parent || used[e.X] == true)
      |                             ^~~~
race.cpp:19:36: error: 'struct std::pair<int, int>' has no member named 'X'
   19 |         if(e.X == parent || used[e.X] == true)
      |                                    ^
race.cpp:22:29: error: 'nb' was not declared in this scope
   22 |         sz[node] += find_sz(nb);
      |                             ^~
race.cpp: In function 'int find_centroid(int, int, int)':
race.cpp:32:29: error: 'v' was not declared in this scope
   32 |     for(pair <int, int> e : v[node])
      |                             ^
race.cpp:34:14: error: 'struct std::pair<int, int>' has no member named 'X'
   34 |         if(e.X == parent || used[e.X] == true)
      |              ^
race.cpp:34:29: error: 'used' was not declared in this scope
   34 |         if(e.X == parent || used[e.X] == true)
      |                             ^~~~
race.cpp:34:36: error: 'struct std::pair<int, int>' has no member named 'X'
   34 |         if(e.X == parent || used[e.X] == true)
      |                                    ^
race.cpp:37:12: error: 'sz' was not declared in this scope; did you mean '_sz'?
   37 |         if(sz[e.X] * 2 > _sz)
      |            ^~
      |            _sz
race.cpp:37:17: error: 'struct std::pair<int, int>' has no member named 'X'
   37 |         if(sz[e.X] * 2 > _sz)
      |                 ^
race.cpp:38:36: error: 'struct std::pair<int, int>' has no member named 'X'
   38 |             return find_centroid(e.X, node, _sz);
      |                                    ^
race.cpp: At global scope:
race.cpp:46:14: error: 'INF' was not declared in this scope
   46 | int answer = INF;
      |              ^~~
race.cpp:48:10: error: 'maxn' was not declared in this scope
   48 | int help[maxn];
      |          ^~~~
race.cpp: In function 'void dfs1(int, int, int, int, int)':
race.cpp:53:9: error: 'help' was not declared in this scope
   53 |         help[weight] = c;
      |         ^~~~
race.cpp:56:9: error: 'help' was not declared in this scope
   56 |         help[k - weight] = c;
      |         ^~~~
race.cpp:58:29: error: 'v' was not declared in this scope
   58 |     for(pair <int, int> e : v[node])
      |                             ^
race.cpp:60:14: error: 'struct std::pair<int, int>' has no member named 'X'
   60 |         if(e.X == parent || used[e.X] == true)
      |              ^
race.cpp:60:29: error: 'used' was not declared in this scope
   60 |         if(e.X == parent || used[e.X] == true)
      |                             ^~~~
race.cpp:60:36: error: 'struct std::pair<int, int>' has no member named 'X'
   60 |         if(e.X == parent || used[e.X] == true)
      |                                    ^
race.cpp:63:16: error: 'struct std::pair<int, int>' has no member named 'X'
   63 |         dfs1(e.X, node, depth + 1, weight + e.Y, k);
      |                ^
race.cpp:63:47: error: 'struct std::pair<int, int>' has no member named 'Y'
   63 |         dfs1(e.X, node, depth + 1, weight + e.Y, k);
      |                                               ^
race.cpp: In function 'void dfs2(int, int, int, int, int)':
race.cpp:71:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   71 |         ans = min(ans, help[k - weight] + depth);
      |         ^~~
      |         abs
race.cpp:71:24: error: 'help' was not declared in this scope
   71 |         ans = min(ans, help[k - weight] + depth);
      |                        ^~~~
race.cpp:73:29: error: 'v' was not declared in this scope
   73 |     for(pair <int, int> e : v[node])
      |                             ^
race.cpp:75:14: error: 'struct std::pair<int, int>' has no member named 'X'
   75 |         if(e.X == parent || used[e.X] == true)
      |              ^
race.cpp:75:29: error: 'used' was not declared in this scope
   75 |         if(e.X == parent || used[e.X] == true)
      |                             ^~~~
race.cpp:75:36: error: 'struct std::pair<int, int>' has no member named 'X'
   75 |         if(e.X == parent || used[e.X] == true)
      |                                    ^
race.cpp:78:16: error: 'struct std::pair<int, int>' has no member named 'X'
   78 |         dfs2(e.X, node, depth + 1, weight + e.Y, k);
      |                ^
race.cpp:78:47: error: 'struct std::pair<int, int>' has no member named 'Y'
   78 |         dfs2(e.X, node, depth + 1, weight + e.Y, k);
      |                                               ^
race.cpp: In function 'void dfs3(int, int, int, int, int)':
race.cpp:86:24: error: 'par' was not declared in this scope
   86 |     if (k >= weight && par != -1)
      |                        ^~~
race.cpp:87:9: error: 'help' was not declared in this scope
   87 |         help[weight] = min(help[weight], depth);
      |         ^~~~
race.cpp:89:30: error: 'v' was not declared in this scope
   89 |     for (pair <int, int> e : v[node])
      |                              ^
race.cpp:91:15: error: 'struct std::pair<int, int>' has no member named 'X'
   91 |         if (e.X == par || used[e.X])
      |               ^
race.cpp:91:20: error: 'par' was not declared in this scope
   91 |         if (e.X == par || used[e.X])
      |                    ^~~
race.cpp:91:27: error: 'used' was not declared in this scope
   91 |         if (e.X == par || used[e.X])
      |                           ^~~~
race.cpp:91:34: error: 'struct std::pair<int, int>' has no member named 'X'
   91 |         if (e.X == par || used[e.X])
      |                                  ^
race.cpp:94:16: error: 'struct std::pair<int, int>' has no member named 'X'
   94 |         dfs1(e.X, node, depth + 1, weight + e.Y);
      |                ^
race.cpp:94:47: error: 'struct std::pair<int, int>' has no member named 'Y'
   94 |         dfs1(e.X, node, depth + 1, weight + e.Y);
      |                                               ^
race.cpp: In function 'void decompose(int, int)':
race.cpp:103:30: error: too few arguments to function 'int find_sz(int, int)'
  103 |     int cur_sz = find_sz(node);
      |                              ^
race.cpp:13:5: note: declared here
   13 | int find_sz(int node, int parent)
      |     ^~~~~~~
race.cpp:107:5: error: 'used' was not declared in this scope
  107 |     used[centroid] = true;
      |     ^~~~
race.cpp:109:30: error: 'v' was not declared in this scope
  109 |     for(pair <int , int> e : v[centroid])
      |                              ^
race.cpp:111:19: error: 'struct std::pair<int, int>' has no member named 'X'
  111 |         if(used[e.X] == true)
      |                   ^
race.cpp:114:16: error: 'struct std::pair<int, int>' has no member named 'X'
  114 |         dfs1(e.X , centroid , 1 , e.Y , k);
      |                ^
race.cpp:114:37: error: 'struct std::pair<int, int>' has no member named 'Y'
  114 |         dfs1(e.X , centroid , 1 , e.Y , k);
      |                                     ^
race.cpp:117:30: error: 'v' was not declared in this scope
  117 |     for(pair <int , int> e : v[centroid])
      |                              ^
race.cpp:119:19: error: 'struct std::pair<int, int>' has no member named 'X'
  119 |         if(used[e.X] == true)
      |                   ^
race.cpp:122:16: error: 'struct std::pair<int, int>' has no member named 'X'
  122 |         dfs2(e.X, centroid , 1 , e.Y , k);
      |                ^
race.cpp:122:36: error: 'struct std::pair<int, int>' has no member named 'Y'
  122 |         dfs2(e.X, centroid , 1 , e.Y , k);
      |                                    ^
race.cpp:123:16: error: 'struct std::pair<int, int>' has no member named 'X'
  123 |         dfs3(e.X , centroid , 1 , e.Y , k);
      |                ^
race.cpp:123:37: error: 'struct std::pair<int, int>' has no member named 'Y'
  123 |         dfs3(e.X , centroid , 1 , e.Y , k);
      |                                     ^
race.cpp:127:30: error: 'v' was not declared in this scope
  127 |     for(pair <int , int> e : v[centroid])
      |                              ^
race.cpp:129:19: error: 'struct std::pair<int, int>' has no member named 'X'
  129 |         if(used[e.X] == true)
      |                   ^
race.cpp:132:21: error: 'struct std::pair<int, int>' has no member named 'X'
  132 |         decompose(e.X , k);
      |                     ^
race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:142:9: error: 'v' was not declared in this scope
  142 |         v[h[i][0]].push_back({h[i][1] , l[i]});
      |         ^
race.cpp:146:5: error: 'help' was not declared in this scope
  146 |     help[0] = 0;
      |     ^~~~
race.cpp:149:8: error: 'ans' was not declared in this scope; did you mean 'abs'?
  149 |     if(ans > n)
      |        ^~~
      |        abs
race.cpp:152:12: error: 'ans' was not declared in this scope; did you mean 'abs'?
  152 |     return ans;
      |            ^~~
      |            abs