제출 #735928

#제출 시각아이디문제언어결과실행 시간메모리
735928hoainiem도로 폐쇄 (APIO21_roads)C++14
컴파일 에러
0 ms0 KiB
#include "roads.h" #include <bits/stdc++.h> #define fi first #define se second #define nmax 100008 using namespace std; typedef pair<long long, long long> pii; long long n; long long dp[2008][2008]; vector<long long>vt[2008][2008]; vector<pii> l[nmax]; void dfs(long long id, long long x, long long pre){ dp[id][x] = 0; for (pii it : l[x]) if (it.fi != pre){ dfs(id, it.fi, x); if (!id) dp[id][x] += dp[id][it.fi] + it.se; else{ dp[id][x] += dp[id - 1][it.fi]; vt[id][x].push_back(dp[id][it.fi] + it.se - dp[id - 1][it.fi]); } } sort(vt[id][x].begin(), vt[id][x].end(), greater<long long>()); while (!vt[id][x].empty() && ((long long)vt[id][x].size() > id || vt[id][x].back() < 0)){ dp[id][x] += vt[id][x].back(); vt[id][x].pop_back(); } } std::vector<long long> minimum_closure_costs(long long N, std::vector<long long> U, std::vector<long long> V, std::vector<long long> W) { assert((n = N) <= 2000); for (long long i = 0; i < n - 1; i++){ l[U[i]].push_back({V[i], W[i]}); l[V[i]].push_back({U[i], W[i]}); } vector<long long>res; for (long long k = 0; k < n; k++){ dfs(k, 0, 0); res.push_back(dp[k][0]); } return res; }

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

/usr/bin/ld: /tmp/cckuAGhY.o: in function `main':
grader.cpp:(.text.startup+0x26f): undefined reference to `minimum_closure_costs(int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status