제출 #786226

#제출 시각아이디문제언어결과실행 시간메모리
786226That_SalamanderAliens (IOI16_aliens)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define int long long #define FOR(var,bound) for(int var = 0; var < bound; var++) #define FORB(var,lb,ub) for (int var = lb; var < ub; var++) #define FORR(var,bound) for(int var = bound-1; var >= 0; var--) using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef pair<int, int> pii; vector<pii> ranges; int rangeEnds[100000]; int N; int dp[4005][4005]; int solve(int idx, int photosRemaining) { if (idx == N) return 0; if (photosRemaining == 0) return 1e15; if (dp[idx][photosRemaining] != -1) return dp[idx][photosRemaining]; if (rangeEnds[idx] >= ranges[idx].second) return dp[idx][photosRemaining] = solve(idx+1, photosRemaining); int penalty = rangeEnds[idx] < ranges[idx].first ? 0 : (rangeEnds[idx] - ranges[idx].first+1)*(rangeEnds[idx] - ranges[idx].first+1); int res = 1e15; int e = 0; for (int i = idx; i < N; i++) { e = max(e, ranges[i].second); int s = (e - ranges[idx].first+1)*(e - ranges[idx].first+1) - penalty; res = min(res, solve(i + 1, photosRemaining - 1) + s); } return dp[idx][photosRemaining] = res; } int64_t take_photos(int32_t n, int32_t m, int32_t k, int32_t r[], int32_t c[]) { N = n; memset(dp, -1, sizeof(dp)); ranges.resize(n); FOR(i, n) { ranges[i] = { min(r[i], c[i]), max(r[i], c[i]) }; } sort(ranges.begin(), ranges.end()); int e = -1; FOR(i, n) { rangeEnds[i] = e; e = max(e, ranges[i].second); } return solve(0, k); } #ifdef LOCAL_TEST signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m, k; cin >> n >> m >> k; vector<int32_t> r(n), c(n); FOR(i, n) { cin >> r[i] >> c[i]; } cout << take_photos(n, m, k, r.data(), c.data()) << endl; } #endif

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

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