Submission #931333

#TimeUsernameProblemLanguageResultExecution timeMemory
931333Ice_man경주 (Race) (IOI11_race)C++14
Compilation error
0 ms0 KiB
#include "bits/stdc++.h" #include "race.h" 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:4:1: error: 'vector' does not name a type
    4 | vector <pair <int, int>> v[maxn];
      | ^~~~~~
race.cpp:5:8: error: 'maxn' was not declared in this scope
    5 | int sz[maxn];
      |        ^~~~
race.cpp:7:10: error: 'maxn' was not declared in this scope
    7 | int used[maxn];
      |          ^~~~
race.cpp: In function 'int find_sz(int, int)':
race.cpp:12:5: error: 'sz' was not declared in this scope
   12 |     sz[node] = 1;
      |     ^~
race.cpp:14:9: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   14 |     for(pair <int, int> e : v[node])
      |         ^~~~
      |         std::pair
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from race.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: 'std::pair' declared here
  211 |     struct pair
      |            ^~~~
race.cpp:14:15: error: expected primary-expression before 'int'
   14 |     for(pair <int, int> e : v[node])
      |               ^~~
race.cpp:22:5: error: expected primary-expression before 'return'
   22 |     return sz[node];
      |     ^~~~~~
race.cpp:20:6: error: expected ';' before 'return'
   20 |     }
      |      ^
      |      ;
   21 | 
   22 |     return sz[node];
      |     ~~~~~~
race.cpp:22:5: error: expected primary-expression before 'return'
   22 |     return sz[node];
      |     ^~~~~~
race.cpp:20:6: error: expected ')' before 'return'
   20 |     }
      |      ^
      |      )
   21 | 
   22 |     return sz[node];
      |     ~~~~~~
race.cpp:14:8: note: to match this '('
   14 |     for(pair <int, int> e : v[node])
      |        ^
race.cpp: In function 'int find_centroid(int, int, int)':
race.cpp:29:9: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   29 |     for(pair <int, int> e : v[node])
      |         ^~~~
      |         std::pair
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from race.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: 'std::pair' declared here
  211 |     struct pair
      |            ^~~~
race.cpp:29:15: error: expected primary-expression before 'int'
   29 |     for(pair <int, int> e : v[node])
      |               ^~~
race.cpp:39:5: error: expected primary-expression before 'return'
   39 |     return node;
      |     ^~~~~~
race.cpp:37:6: error: expected ';' before 'return'
   37 |     }
      |      ^
      |      ;
   38 | 
   39 |     return node;
      |     ~~~~~~
race.cpp:39:5: error: expected primary-expression before 'return'
   39 |     return node;
      |     ^~~~~~
race.cpp:37:6: error: expected ')' before 'return'
   37 |     }
      |      ^
      |      )
   38 | 
   39 |     return node;
      |     ~~~~~~
race.cpp:29:8: note: to match this '('
   29 |     for(pair <int, int> e : v[node])
      |        ^
race.cpp: At global scope:
race.cpp:43:14: error: 'INF' was not declared in this scope
   43 | int answer = INF;
      |              ^~~
race.cpp:45:10: error: 'maxn' was not declared in this scope
   45 | int help[maxn];
      |          ^~~~
race.cpp: In function 'void dfs1(int, int, int, int, int)':
race.cpp:50:9: error: 'help' was not declared in this scope
   50 |         help[weight] = c;
      |         ^~~~
race.cpp:53:9: error: 'help' was not declared in this scope
   53 |         help[k - weight] = c;
      |         ^~~~
race.cpp:55:9: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   55 |     for(pair <int, int> e : v[node])
      |         ^~~~
      |         std::pair
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from race.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: 'std::pair' declared here
  211 |     struct pair
      |            ^~~~
race.cpp:55:15: error: expected primary-expression before 'int'
   55 |     for(pair <int, int> e : v[node])
      |               ^~~
race.cpp:63:1: error: expected primary-expression before '}' token
   63 | }
      | ^
race.cpp:61:6: error: expected ';' before '}' token
   61 |     }
      |      ^
      |      ;
   62 | 
   63 | }
      | ~     
race.cpp:63:1: error: expected primary-expression before '}' token
   63 | }
      | ^
race.cpp:61:6: error: expected ')' before '}' token
   61 |     }
      |      ^
      |      )
   62 | 
   63 | }
      | ~     
race.cpp:55:8: note: to match this '('
   55 |     for(pair <int, int> e : v[node])
      |        ^
race.cpp:63:1: error: expected primary-expression before '}' token
   63 | }
      | ^
race.cpp: In function 'void dfs2(int, int, int, int, int)':
race.cpp:68:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   68 |         ans = min(ans, help[k - weight] + depth);
      |         ^~~
      |         abs
race.cpp:68:24: error: 'help' was not declared in this scope
   68 |         ans = min(ans, help[k - weight] + depth);
      |                        ^~~~
race.cpp:68:15: error: 'min' was not declared in this scope; did you mean 'std::min'?
   68 |         ans = min(ans, help[k - weight] + depth);
      |               ^~~
      |               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:1:
/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:70:9: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   70 |     for(pair <int, int> e : v[node])
      |         ^~~~
      |         std::pair
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from race.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: 'std::pair' declared here
  211 |     struct pair
      |            ^~~~
race.cpp:70:15: error: expected primary-expression before 'int'
   70 |     for(pair <int, int> e : v[node])
      |               ^~~
race.cpp:78:1: error: expected primary-expression before '}' token
   78 | }
      | ^
race.cpp:76:6: error: expected ';' before '}' token
   76 |     }
      |      ^
      |      ;
   77 | 
   78 | }
      | ~     
race.cpp:78:1: error: expected primary-expression before '}' token
   78 | }
      | ^
race.cpp:76:6: error: expected ')' before '}' token
   76 |     }
      |      ^
      |      )
   77 | 
   78 | }
      | ~     
race.cpp:70:8: note: to match this '('
   70 |     for(pair <int, int> e : v[node])
      |        ^
race.cpp:78:1: error: expected primary-expression before '}' token
   78 | }
      | ^
race.cpp: In function 'void dfs3(int, int, int, int, int)':
race.cpp:83:24: error: 'par' was not declared in this scope
   83 |     if (k >= weight && par != -1)
      |                        ^~~
race.cpp:84:9: error: 'help' was not declared in this scope
   84 |         help[weight] = min(help[weight], depth);
      |         ^~~~
race.cpp:84:24: error: 'min' was not declared in this scope; did you mean 'std::min'?
   84 |         help[weight] = min(help[weight], depth);
      |                        ^~~
      |                        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:1:
/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:86:10: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   86 |     for (pair <int, int> e : v[node])
      |          ^~~~
      |          std::pair
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from race.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: 'std::pair' declared here
  211 |     struct pair
      |            ^~~~
race.cpp:86:16: error: expected primary-expression before 'int'
   86 |     for (pair <int, int> e : v[node])
      |                ^~~
race.cpp:93:1: error: expected primary-expression before '}' token
   93 | }
      | ^
race.cpp:92:6: error: expected ';' before '}' token
   92 |     }
      |      ^
      |      ;
   93 | }
      | ~     
race.cpp:93:1: error: expected primary-expression before '}' token
   93 | }
      | ^
race.cpp:92:6: error: expected ')' before '}' token
   92 |     }
      |      ^
      |      )
   93 | }
      | ~     
race.cpp:86:9: note: to match this '('
   86 |     for (pair <int, int> e : v[node])
      |         ^
race.cpp:93:1: error: expected primary-expression before '}' token
   93 | }
      | ^
race.cpp: In function 'void decompose(int, int)':
race.cpp:100:30: error: too few arguments to function 'int find_sz(int, int)'
  100 |     int cur_sz = find_sz(node);
      |                              ^
race.cpp:10:5: note: declared here
   10 | int find_sz(int node, int parent)
      |     ^~~~~~~
race.cpp:104:5: error: 'used' was not declared in this scope
  104 |     used[centroid] = true;
      |     ^~~~
race.cpp:106:9: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
  106 |     for(pair <int , int> e : v[centroid])
      |         ^~~~
      |         std::pair
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from race.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: 'std::pair' declared here
  211 |     struct pair
      |            ^~~~
race.cpp:106:15: error: expected primary-expression before 'int'
  106 |     for(pair <int , int> e : v[centroid])
      |               ^~~
race.cpp:114:5: error: expected primary-expression before 'for'
  114 |     for(pair <int , int> e : v[centroid])
      |     ^~~
race.cpp:112:6: error: expected ';' before 'for'
  112 |     }
      |      ^
      |      ;
  113 | 
  114 |     for(pair <int , int> e : v[centroid])
      |     ~~~
race.cpp:114:5: error: expected primary-expression before 'for'
  114 |     for(pair <int , int> e : v[centroid])
      |     ^~~
race.cpp:112:6: error: expected ')' before 'for'
  112 |     }
      |      ^
      |      )
  113 | 
  114 |     for(pair <int , int> e : v[centroid])
      |     ~~~
race.cpp:106:8: note: to match this '('
  106 |     for(pair <int , int> e : v[centroid])
      |        ^
race.cpp:114:15: error: expected primary-expression before 'int'
  114 |     for(pair <int , int> e : v[centroid])
      |               ^~~
race.cpp:124:5: error: expected primary-expression before 'for'
  124 |     for(pair <int , int> e : v[centroid])
      |     ^~~
race.cpp:122:6: error: expected ';' before 'for'
  122 |     }
      |      ^
      |      ;
  123 | 
  124 |     for(pair <int , int> e : v[centroid])
      |     ~~~
race.cpp:124:5: error: expected primary-expression before 'for'
  124 |     for(pair <int , int> e : v[centroid])
      |     ^~~
race.cpp:122:6: error: expected ')' before 'for'
  122 |     }
      |      ^
      |      )
  123 | 
  124 |     for(pair <int , int> e : v[centroid])
      |     ~~~
race.cpp:114:8: note: to match this '('
  114 |     for(pair <int , int> e : v[centroid])
      |        ^
race.cpp:124:15: error: expected primary-expression before 'int'
  124 |     for(pair <int , int> e : v[centroid])
      |               ^~~
race.cpp:131:1: error: expected primary-expression before '}' token
  131 | }
      | ^
race.cpp:130:6: error: expected ';' before '}' token
  130 |     }
      |      ^
      |      ;
  131 | }
      | ~     
race.cpp:131:1: error: expected primary-expression before '}' token
  131 | }
      | ^
race.cpp:130:6: error: expected ')' before '}' token
  130 |     }
      |      ^
      |      )
  131 | }
      | ~     
race.cpp:124:8: note: to match this '('
  124 |     for(pair <int , int> e : v[centroid])
      |        ^
race.cpp:131:1: error: expected primary-expression before '}' token
  131 | }
      | ^
race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:139:9: error: 'v' was not declared in this scope
  139 |         v[h[i][0]].push_back({h[i][1] , l[i]});
      |         ^
race.cpp:143:5: error: 'help' was not declared in this scope
  143 |     help[0] = 0;
      |     ^~~~
race.cpp:146:8: error: 'ans' was not declared in this scope; did you mean 'abs'?
  146 |     if(ans > n)
      |        ^~~
      |        abs
race.cpp:149:12: error: 'ans' was not declared in this scope; did you mean 'abs'?
  149 |     return ans;
      |            ^~~
      |            abs