제출 #347929

#제출 시각아이디문제언어결과실행 시간메모리
347929training4usacoTraffic (IOI10_traffic)C++11
컴파일 에러
0 ms0 KiB
#include "traffic.h" #include <climits> #include <iostream> #include <vector> using namespace std; int n; vector<int> p; vector<int> s; vector<int> d; vector<vector<int>> adj; vector<int> traffic; vector<int> children; int numFans = 0; void dfs (int idx, int par) { for (int i = 0; i < adj[idx].size(); ++i) { if (adj[idx][i] == par) { continue; } dfs(adj[idx][i], idx); children[idx] += children[adj[idx][i]]; traffic[idx] = max(traffic[idx], children[adj[idx][i]]); } traffic[idx] = max(traffic[idx], numFans - children[idx] - p[idx]); children[idx] += p[idx]; } int LocateCentre (int ni, vector<int> pi, vector<int> di, vector<int> si) { n = ni; p = pi; s = si; d = di; adj = vector<vector<int>>(n); traffic = vector<int>(n); children = vector<int>(n); for (int i = 0; i < n; i++) { numFans += p[i]; } for (int i = 0; i < n - 1; i++) { adj[s[i]].push_back(d[i]); adj[d[i]].push_back(s[i]); } dfs(0, -1); int best = INT_MAX; int ans = -1; for (int i = 0; i < n; i++) { if (traffic[i] < best) { ans = i; best = traffic[i]; } } return ans; }

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

traffic.cpp: In function 'void dfs(int, int)':
traffic.cpp:19:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for (int i = 0; i < adj[idx].size(); ++i) {
      |                     ~~^~~~~~~~~~~~~~~~~
/tmp/ccnlvUeL.o: In function `main':
grader.cpp:(.text.startup+0xd9): undefined reference to `LocateCentre(int, int*, int*, int*)'
collect2: error: ld returned 1 exit status