Submission #528272

#TimeUsernameProblemLanguageResultExecution timeMemory
528272meperdonas203Traffic (IOI10_traffic)C++17
Compilation error
0 ms0 KiB
#include "traffic.h" #include<bits/stdc++.h> using namespace std; 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: In function 'int dfs(int, int, int*)':
traffic.cpp:8:8: error: 'i' was not declared in this scope
    8 |    sub[i]+=arre[nodo];
      |        ^