제출 #492540

#제출 시각아이디문제언어결과실행 시간메모리
4925401ne경주 (Race) (IOI11_race)C++14
컴파일 에러
0 ms0 KiB
#include "race.h" vector<vector<pair<int,int>>>adj(1e5); vector<vector<int>>sparce(1e5,vector<int>(20,-1)); vector<int>depth(1e5,0); vector<int64_t>dist(1e5,0); void getsparce(int u,int par){ for (auto x:adj[u]){ if (x.first!=par){ sparce[x.first][0] = u; depth[x.first]=depth[u]+1; dist[x.first] = dist[u] + x.second; getsparce(x.first,u); } } } int lca(int u,int v){ if (depth[u]<depth[v]){ swap(u,v); } for (int i = 19;i>=0;--i){ if (sparce[u][i]!=-1) if (depth[sparce[u][i]]>=depth[v]){ u=sparce[u][i]; } } if (u==v)return u; for (int i = 19;i>=0;--i){ if (sparce[u][i]!=sparce[v][i]){ u=sparce[u][i]; v=sparce[v][i]; } } return sparce[u][0]; } pair<int,int64_t> distt(int u,int v){ int l = lca(u,v); return {depth[u] + depth[v] - 2*depth[l],dist[u] + dist[v] - 2*dist[l]}; } void preprocess(int n){ getsparce(0,-1); for (int i = 1;i<20;++i){ for (int j = 0;j<n;++j){ if (sparce[j][i-1]!=-1){ sparce[j][i] = sparce[sparce[j][i-1]][i-1]; } } } } int best_path(int n, int k, int H[][2], int L[]) { for (int i = 0;i<n-1;++i){ adj[H[i][0]].push_back({H[i][1],L[i]}); adj[H[i][1]].push_back({H[i][0],L[i]}); } preprocess(n); int ans = INT_MAX; for (int i = 0;i<n;++i){ for (int j = i+1;j<n;++j){ auto x = distt(i,j); if (x.second==k){ ans = min(ans,x.first); } } } if (ans==INT_MAX){ ans = -1; } return ans; }

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

race.cpp:2:1: error: 'vector' does not name a type
    2 | vector<vector<pair<int,int>>>adj(1e5);
      | ^~~~~~
race.cpp:3:1: error: 'vector' does not name a type
    3 | vector<vector<int>>sparce(1e5,vector<int>(20,-1));
      | ^~~~~~
race.cpp:4:1: error: 'vector' does not name a type
    4 | vector<int>depth(1e5,0);
      | ^~~~~~
race.cpp:5:1: error: 'vector' does not name a type
    5 | vector<int64_t>dist(1e5,0);
      | ^~~~~~
race.cpp: In function 'void getsparce(int, int)':
race.cpp:8:14: error: 'adj' was not declared in this scope
    8 |  for (auto x:adj[u]){
      |              ^~~
race.cpp:10:4: error: 'sparce' was not declared in this scope; did you mean 'getsparce'?
   10 |    sparce[x.first][0] = u;
      |    ^~~~~~
      |    getsparce
race.cpp:11:4: error: 'depth' was not declared in this scope
   11 |    depth[x.first]=depth[u]+1;
      |    ^~~~~
race.cpp:12:4: error: 'dist' was not declared in this scope
   12 |    dist[x.first] = dist[u] + x.second;
      |    ^~~~
race.cpp: In function 'int lca(int, int)':
race.cpp:18:6: error: 'depth' was not declared in this scope
   18 |  if (depth[u]<depth[v]){
      |      ^~~~~
race.cpp:19:3: error: 'swap' was not declared in this scope
   19 |   swap(u,v);
      |   ^~~~
race.cpp:22:7: error: 'sparce' was not declared in this scope; did you mean 'getsparce'?
   22 |   if (sparce[u][i]!=-1)
      |       ^~~~~~
      |       getsparce
race.cpp:23:7: error: 'depth' was not declared in this scope
   23 |   if (depth[sparce[u][i]]>=depth[v]){
      |       ^~~~~
race.cpp:29:7: error: 'sparce' was not declared in this scope; did you mean 'getsparce'?
   29 |   if (sparce[u][i]!=sparce[v][i]){
      |       ^~~~~~
      |       getsparce
race.cpp:34:9: error: 'sparce' was not declared in this scope; did you mean 'getsparce'?
   34 |  return sparce[u][0];
      |         ^~~~~~
      |         getsparce
race.cpp: At global scope:
race.cpp:36:1: error: 'pair' does not name a type
   36 | pair<int,int64_t> distt(int u,int v){
      | ^~~~
race.cpp: In function 'void preprocess(int)':
race.cpp:44:8: error: 'sparce' was not declared in this scope; did you mean 'getsparce'?
   44 |    if (sparce[j][i-1]!=-1){
      |        ^~~~~~
      |        getsparce
race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:53:5: error: 'adj' was not declared in this scope
   53 |     adj[H[i][0]].push_back({H[i][1],L[i]});
      |     ^~~
race.cpp:57:12: error: 'INT_MAX' was not declared in this scope
   57 |  int ans = INT_MAX;
      |            ^~~~~~~
race.cpp:2:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
    1 | #include "race.h"
  +++ |+#include <climits>
    2 | vector<vector<pair<int,int>>>adj(1e5);
race.cpp:60:13: error: 'distt' was not declared in this scope
   60 |    auto x = distt(i,j);
      |             ^~~~~
race.cpp:62:11: error: 'min' was not declared in this scope
   62 |     ans = min(ans,x.first);
      |           ^~~