제출 #491572

#제출 시각아이디문제언어결과실행 시간메모리
491572vendx_greybackTraffic (IOI10_traffic)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define all(x) (x).begin(),(x).end() typedef pair<int,int> ppi; typedef vector<int> vi; typedef vector<vector<int>> vvi; const int mxn = 1e6; vi adj[mxn]; int sz[mxn]; int mx[mxn]; void dfs(int u, int p){ for(auto v: adj[u]){ if(v == p) continue; dfs(v, u); sz[u] += sz[v]; mx[u] = max(mx[u], sz[v]); } } int LocateCentre(int n, int p[], int s[], int d[]){ for(int i = 0; i < n-1; i++){ adj[s[i]].push_back(d[i]); adj[d[i]].push_back(s[i]); } int total; for(int i = 0; i < n; i++){ sz[i] = p[i]; total += p[i]; } dfs(0, -1); int wt = 1e18; int res = -1; for(int i = 0; i < n; i++){ int temp = max(mx[i], total - sz[i]); if(temp < wt){ wt = temp; 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:15: warning: 'total' may be used uninitialized in this function [-Wmaybe-uninitialized]
   40 |         total += p[i];
      |         ~~~~~~^~~~~~~
/usr/bin/ld: /tmp/cc3WafVm.o: in function `main':
grader.cpp:(.text.startup+0xe1): undefined reference to `LocateCentre(int, int*, int*, int*)'
collect2: error: ld returned 1 exit status