제출 #495539

#제출 시각아이디문제언어결과실행 시간메모리
495539PiejanVDCTraffic (IOI10_traffic)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #include "traffic.h" vector<vector<int>>adj; int n; vector<int>v; vector<int>mx,total; int root_dfs(int u, int e = -1) { int w = v[u]; int m = v[u]; for(auto z : adj[u]) { if(z == e) continue; int curr = root_dfs(z,u); w+=curr; mx[u] = max(mx[u],curr); } return total[u] = w; } int best, mn = INT_MAX; void dfs(int u, int sum, int e = -1) { if(max(mx[u],sum) < mn) { mn = max(mx[u],sum); best = u+1; } for(auto z : adj[u]) { if(z == e) continue; int nw = total[u] - total[z]; dfs(z,nw,u); } } int LocateCentre(int nn, vector<int>p, vector<int>s, vector<int>d) { n=nn; adj.resize(n); v = p; mx.resize(n,0); total.resize(n,0); for(int i = 0 ; i < n-1 ; i++) { adj[s[i]-1].push_back(d[i]-1); adj[d[i]-1].push_back(s[i]-1); } root_dfs(0); dfs(0,0); return best; }

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

traffic.cpp: In function 'int root_dfs(int, int)':
traffic.cpp:13:9: warning: unused variable 'm' [-Wunused-variable]
   13 |     int m = v[u];
      |         ^
/usr/bin/ld: /tmp/ccMjZrVT.o: in function `main':
grader.cpp:(.text.startup+0xe1): undefined reference to `LocateCentre(int, int*, int*, int*)'
collect2: error: ld returned 1 exit status