제출 #528263

#제출 시각아이디문제언어결과실행 시간메모리
528263meperdonas203Traffic (IOI10_traffic)C++17
컴파일 에러
0 ms0 KiB
#include "traffic.h" #include<vector> #include<math.h> int sub[1000005]; vector<int>grafo[1000005]; int padres[1000005]; int dfs(int nodo,int padre,int arre[]){ sub[i]+=arre[nodo]; padres[nodo]=padre; for(auto x:grafo[nodo]){ if(x!=padre){ sub[i]+=dfs(x,nodo,arre); } } return sub[i]; } int LocateCentre(int N, int pp[], int S[], int D[]) { dfs(0,-1,pp); for(int i=0;i<N-1;i++){ grafo[S[i]].push_back(D[i]); grafo[D[i]].push_back(S[i]); } int ans=-1; int ans_res=INT_MAX; for(int i=0;i<N;i++){ int res=sub[0]-sub[i]; for(int x:grafo[i]){ if(x!=padres[i])res=max(res,sub[x]); } if(res<=ans_res){ ans=i; ans_res=res; } } return ans; }

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

traffic.cpp:5:1: error: 'vector' does not name a type
    5 | vector<int>grafo[1000005];
      | ^~~~~~
traffic.cpp: In function 'int dfs(int, int, int*)':
traffic.cpp:8:8: error: 'i' was not declared in this scope
    8 |    sub[i]+=arre[nodo];
      |        ^
traffic.cpp:10:15: error: 'grafo' was not declared in this scope
   10 |    for(auto x:grafo[nodo]){
      |               ^~~~~
traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:20:7: error: 'grafo' was not declared in this scope
   20 |       grafo[S[i]].push_back(D[i]);
      |       ^~~~~
traffic.cpp:24:16: error: 'INT_MAX' was not declared in this scope
   24 |    int ans_res=INT_MAX;
      |                ^~~~~~~
traffic.cpp:4:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
    3 | #include<math.h>
  +++ |+#include <climits>
    4 | int sub[1000005];
traffic.cpp:27:17: error: 'grafo' was not declared in this scope
   27 |       for(int x:grafo[i]){
      |                 ^~~~~
traffic.cpp:28:30: error: 'max' was not declared in this scope; did you mean 'std::max'?
   28 |          if(x!=padres[i])res=max(res,sub[x]);
      |                              ^~~
      |                              std::max
In file included from /usr/include/c++/10/vector:60,
                 from traffic.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: 'std::max' declared here
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~