제출 #931334

#제출 시각아이디문제언어결과실행 시간메모리
931334Ice_man경주 (Race) (IOI11_race)C++14
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h" #include "race.h" #include <vector> 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; }

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

race.cpp:5:1: error: 'vector' does not name a type
    5 | vector <pair <int, int>> v[maxn];
      | ^~~~~~
race.cpp:6:8: error: 'maxn' was not declared in this scope
    6 | int sz[maxn];
      |        ^~~~
race.cpp:8:10: error: 'maxn' was not declared in this scope
    8 | int used[maxn];
      |          ^~~~
race.cpp: In function 'int find_sz(int, int)':
race.cpp:13:5: error: 'sz' was not declared in this scope
   13 |     sz[node] = 1;
      |     ^~
race.cpp:15:9: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   15 |     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:15:15: error: expected primary-expression before 'int'
   15 |     for(pair <int, int> e : v[node])
      |               ^~~
race.cpp:23:5: error: expected primary-expression before 'return'
   23 |     return sz[node];
      |     ^~~~~~
race.cpp:21:6: error: expected ';' before 'return'
   21 |     }
      |      ^
      |      ;
   22 | 
   23 |     return sz[node];
      |     ~~~~~~
race.cpp:23:5: error: expected primary-expression before 'return'
   23 |     return sz[node];
      |     ^~~~~~
race.cpp:21:6: error: expected ')' before 'return'
   21 |     }
      |      ^
      |      )
   22 | 
   23 |     return sz[node];
      |     ~~~~~~
race.cpp:15:8: note: to match this '('
   15 |     for(pair <int, int> e : v[node])
      |        ^
race.cpp: In function 'int find_centroid(int, int, int)':
race.cpp:30:9: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   30 |     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:30:15: error: expected primary-expression before 'int'
   30 |     for(pair <int, int> e : v[node])
      |               ^~~
race.cpp:40:5: error: expected primary-expression before 'return'
   40 |     return node;
      |     ^~~~~~
race.cpp:38:6: error: expected ';' before 'return'
   38 |     }
      |      ^
      |      ;
   39 | 
   40 |     return node;
      |     ~~~~~~
race.cpp:40:5: error: expected primary-expression before 'return'
   40 |     return node;
      |     ^~~~~~
race.cpp:38:6: error: expected ')' before 'return'
   38 |     }
      |      ^
      |      )
   39 | 
   40 |     return node;
      |     ~~~~~~
race.cpp:30:8: note: to match this '('
   30 |     for(pair <int, int> e : v[node])
      |        ^
race.cpp: At global scope:
race.cpp:44:14: error: 'INF' was not declared in this scope
   44 | int answer = INF;
      |              ^~~
race.cpp:46:10: error: 'maxn' was not declared in this scope
   46 | int help[maxn];
      |          ^~~~
race.cpp: In function 'void dfs1(int, int, int, int, int)':
race.cpp:51:9: error: 'help' was not declared in this scope
   51 |         help[weight] = c;
      |         ^~~~
race.cpp:54:9: error: 'help' was not declared in this scope
   54 |         help[k - weight] = c;
      |         ^~~~
race.cpp:56:9: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   56 |     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:56:15: error: expected primary-expression before 'int'
   56 |     for(pair <int, int> e : v[node])
      |               ^~~
race.cpp:64:1: error: expected primary-expression before '}' token
   64 | }
      | ^
race.cpp:62:6: error: expected ';' before '}' token
   62 |     }
      |      ^
      |      ;
   63 | 
   64 | }
      | ~     
race.cpp:64:1: error: expected primary-expression before '}' token
   64 | }
      | ^
race.cpp:62:6: error: expected ')' before '}' token
   62 |     }
      |      ^
      |      )
   63 | 
   64 | }
      | ~     
race.cpp:56:8: note: to match this '('
   56 |     for(pair <int, int> e : v[node])
      |        ^
race.cpp:64:1: error: expected primary-expression before '}' token
   64 | }
      | ^
race.cpp: In function 'void dfs2(int, int, int, int, int)':
race.cpp:69:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   69 |         ans = min(ans, help[k - weight] + depth);
      |         ^~~
      |         abs
race.cpp:69:24: error: 'help' was not declared in this scope
   69 |         ans = min(ans, help[k - weight] + depth);
      |                        ^~~~
race.cpp:69:15: error: 'min' was not declared in this scope; did you mean 'std::min'?
   69 |         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:71:9: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   71 |     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:71:15: error: expected primary-expression before 'int'
   71 |     for(pair <int, int> e : v[node])
      |               ^~~
race.cpp:79:1: error: expected primary-expression before '}' token
   79 | }
      | ^
race.cpp:77:6: error: expected ';' before '}' token
   77 |     }
      |      ^
      |      ;
   78 | 
   79 | }
      | ~     
race.cpp:79:1: error: expected primary-expression before '}' token
   79 | }
      | ^
race.cpp:77:6: error: expected ')' before '}' token
   77 |     }
      |      ^
      |      )
   78 | 
   79 | }
      | ~     
race.cpp:71:8: note: to match this '('
   71 |     for(pair <int, int> e : v[node])
      |        ^
race.cpp:79:1: error: expected primary-expression before '}' token
   79 | }
      | ^
race.cpp: In function 'void dfs3(int, int, int, int, int)':
race.cpp:84:24: error: 'par' was not declared in this scope
   84 |     if (k >= weight && par != -1)
      |                        ^~~
race.cpp:85:9: error: 'help' was not declared in this scope
   85 |         help[weight] = min(help[weight], depth);
      |         ^~~~
race.cpp:85:24: error: 'min' was not declared in this scope; did you mean 'std::min'?
   85 |         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:87:10: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   87 |     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:87:16: error: expected primary-expression before 'int'
   87 |     for (pair <int, int> e : v[node])
      |                ^~~
race.cpp:94:1: error: expected primary-expression before '}' token
   94 | }
      | ^
race.cpp:93:6: error: expected ';' before '}' token
   93 |     }
      |      ^
      |      ;
   94 | }
      | ~     
race.cpp:94:1: error: expected primary-expression before '}' token
   94 | }
      | ^
race.cpp:93:6: error: expected ')' before '}' token
   93 |     }
      |      ^
      |      )
   94 | }
      | ~     
race.cpp:87:9: note: to match this '('
   87 |     for (pair <int, int> e : v[node])
      |         ^
race.cpp:94:1: error: expected primary-expression before '}' token
   94 | }
      | ^
race.cpp: In function 'void decompose(int, int)':
race.cpp:101:30: error: too few arguments to function 'int find_sz(int, int)'
  101 |     int cur_sz = find_sz(node);
      |                              ^
race.cpp:11:5: note: declared here
   11 | int find_sz(int node, int parent)
      |     ^~~~~~~
race.cpp:105:5: error: 'used' was not declared in this scope
  105 |     used[centroid] = true;
      |     ^~~~
race.cpp:107:9: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
  107 |     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:107:15: error: expected primary-expression before 'int'
  107 |     for(pair <int , int> e : v[centroid])
      |               ^~~
race.cpp:115:5: error: expected primary-expression before 'for'
  115 |     for(pair <int , int> e : v[centroid])
      |     ^~~
race.cpp:113:6: error: expected ';' before 'for'
  113 |     }
      |      ^
      |      ;
  114 | 
  115 |     for(pair <int , int> e : v[centroid])
      |     ~~~
race.cpp:115:5: error: expected primary-expression before 'for'
  115 |     for(pair <int , int> e : v[centroid])
      |     ^~~
race.cpp:113:6: error: expected ')' before 'for'
  113 |     }
      |      ^
      |      )
  114 | 
  115 |     for(pair <int , int> e : v[centroid])
      |     ~~~
race.cpp:107:8: note: to match this '('
  107 |     for(pair <int , int> e : v[centroid])
      |        ^
race.cpp:115:15: error: expected primary-expression before 'int'
  115 |     for(pair <int , int> e : v[centroid])
      |               ^~~
race.cpp:125:5: error: expected primary-expression before 'for'
  125 |     for(pair <int , int> e : v[centroid])
      |     ^~~
race.cpp:123:6: error: expected ';' before 'for'
  123 |     }
      |      ^
      |      ;
  124 | 
  125 |     for(pair <int , int> e : v[centroid])
      |     ~~~
race.cpp:125:5: error: expected primary-expression before 'for'
  125 |     for(pair <int , int> e : v[centroid])
      |     ^~~
race.cpp:123:6: error: expected ')' before 'for'
  123 |     }
      |      ^
      |      )
  124 | 
  125 |     for(pair <int , int> e : v[centroid])
      |     ~~~
race.cpp:115:8: note: to match this '('
  115 |     for(pair <int , int> e : v[centroid])
      |        ^
race.cpp:125:15: error: expected primary-expression before 'int'
  125 |     for(pair <int , int> e : v[centroid])
      |               ^~~
race.cpp:132:1: error: expected primary-expression before '}' token
  132 | }
      | ^
race.cpp:131:6: error: expected ';' before '}' token
  131 |     }
      |      ^
      |      ;
  132 | }
      | ~     
race.cpp:132:1: error: expected primary-expression before '}' token
  132 | }
      | ^
race.cpp:131:6: error: expected ')' before '}' token
  131 |     }
      |      ^
      |      )
  132 | }
      | ~     
race.cpp:125:8: note: to match this '('
  125 |     for(pair <int , int> e : v[centroid])
      |        ^
race.cpp:132:1: error: expected primary-expression before '}' token
  132 | }
      | ^
race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:140:9: error: 'v' was not declared in this scope
  140 |         v[h[i][0]].push_back({h[i][1] , l[i]});
      |         ^
race.cpp:144:5: error: 'help' was not declared in this scope
  144 |     help[0] = 0;
      |     ^~~~
race.cpp:147:8: error: 'ans' was not declared in this scope; did you mean 'abs'?
  147 |     if(ans > n)
      |        ^~~
      |        abs
race.cpp:150:12: error: 'ans' was not declared in this scope; did you mean 'abs'?
  150 |     return ans;
      |            ^~~
      |            abs