제출 #289677

#제출 시각아이디문제언어결과실행 시간메모리
289677FarriusTraffic (IOI10_traffic)C++11
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int MX = 1e6; const int INF = 2e9 + 1; int fans = 0; vector<int> g[MX], nodes(MX), people(MX), children(MX); int dfs (int v, int parent) { for (auto x: g[v]) { if (x == parent) continue; int k = dfs(x, v); children[v] += children[x]; people[v] = max(people[v], k); } people[v] = max(people[v], fans - children[v] - nodes[v]); children[v] += nodes[v]; } int LocateCentre (int n, vector<int>& p, vector<int>& s, vector<int>& d) { for (int i = 0; i < n; i++) { fans += p[i]; nodes[i] = p[i]; } for (int i = 0; i < n - 1; i++) { g[s[i]].push_back(d[i]); g[d[i]].push_back(s[i]); } dfs(0, -1); int sol = INF, res = -1; for (int i = 0; i < n; i++) { if (people[i] < sol) { res = i; sol = people[i]; } } return res; }

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

traffic.cpp: In function 'int dfs(int, int)':
traffic.cpp:23:1: warning: no return statement in function returning non-void [-Wreturn-type]
   23 | }
      | ^
/tmp/ccGntPj9.o: In function `main':
grader.cpp:(.text.startup+0xad): undefined reference to `LocateCentre(int, int*, int*, int*)'
collect2: error: ld returned 1 exit status