Submission #528253

#TimeUsernameProblemLanguageResultExecution timeMemory
528253meperdonas203Traffic (IOI10_traffic)C++17
Compilation error
0 ms0 KiB
#include "traffic.h" #include <bits/stdc++.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; }

Compilation message (stderr)

traffic.cpp:4:1: error: 'vector' does not name a type
    4 | vector<int>grafo[1000005];
      | ^~~~~~
traffic.cpp: In function 'int dfs(int, int, int*)':
traffic.cpp:7:8: error: 'i' was not declared in this scope
    7 |    sub[i]+=arre[nodo];
      |        ^
traffic.cpp:9:15: error: 'grafo' was not declared in this scope
    9 |    for(auto x:grafo[nodo]){
      |               ^~~~~
traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:19:7: error: 'grafo' was not declared in this scope
   19 |       grafo[S[i]].push_back(D[i]);
      |       ^~~~~
traffic.cpp:26:17: error: 'grafo' was not declared in this scope
   26 |       for(int x:grafo[i]){
      |                 ^~~~~
traffic.cpp:27:30: error: 'max' was not declared in this scope; did you mean 'std::max'?
   27 |          if(x!=padres[i])res=max(res,sub[x]);
      |                              ^~~
      |                              std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from traffic.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~