제출 #373486

#제출 시각아이디문제언어결과실행 시간메모리
373486eulerdesojaTraffic (IOI10_traffic)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #include<fstream> using namespace std; #define int long long #define pb push_back #define sz(x) int(x.size()) typedef pair<int,int>ii; typedef vector<int> vi; const int mxn=1e6+6; //maximum of congestion in a road vi g[mxn]; int ma[mxn],sum[mxn]; void dfs(int i,int p,int a[]){ for(int j:g[i])if(j!=p){ dfs(j,i,a); sum[i]+=sum[j]; ma[i]=max(ma[i],max(ma[j],sum[j])); } sum[i]+=a[i]; } int LocateCentre(int n,int a[],int s[],int d[]){ for(int i=0;i<n-1;i++){ g[s[i]].pb(d[i]); g[d[i]].pb(s[i]); } int ans=1e18,res; for(int i=0;i<n;i++){ memset(sum,0,sizeof(sum)); memset(ma,0,sizeof(ma)); dfs(i,-1,a); if(ma[i]<ans){ ans=ma[i]; res=i; } } return res; }

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

traffic.cpp: In function 'long long int LocateCentre(long long int, long long int*, long long int*, long long int*)':
traffic.cpp:40:9: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
   40 |  return res;
      |         ^~~
/tmp/ccmiGtr0.o: In function `main':
grader.cpp:(.text.startup+0xd9): undefined reference to `LocateCentre(int, int*, int*, int*)'
collect2: error: ld returned 1 exit status