제출 #528273

#제출 시각아이디문제언어결과실행 시간메모리
528273meperdonas203Traffic (IOI10_traffic)C++17
컴파일 에러
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[nodo]+=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: In function 'int dfs(int, int, int*)':
traffic.cpp:12:14: error: 'i' was not declared in this scope
   12 |          sub[i]+=dfs(x,nodo,arre);
      |              ^
traffic.cpp:15:15: error: 'i' was not declared in this scope
   15 |    return sub[i];
      |               ^