Submission #723842

#TimeUsernameProblemLanguageResultExecution timeMemory
723842PetyAliens (IOI16_aliens)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; long long dp[502][502], cost[502][502]; long long take_photos(int n, int m, int k, vector<int>r, vector<int> c) { vector<pair<int, int>>p; p.push_back({-1, -1}); for (int i = 0; i < n; i++) { if (r[i] > c[i]) swap(r[i], c[i]); p.push_back({r[i], c[i]}); } sort(p.begin(), p.end()); for (int i = 0; i <= n; i++) for (int j = 0; j <= k; j++) dp[i][j] = INF; for (int j = 0; j <= k; j++) dp[0][j] = 0; for (int i = 1; i <= n; i++) for (int j = i, mx = 0; j <= n; j++) { mx = max(mx, p[j].second); cost[i][j] = 1ll * (1ll * mx - p[i].first + 1) * (mx - p[i].first + 1); } for (int i = 1; i <= n; i++) { for (int j = 1; j <= k; j++) { for (int t = 0; t < i; t++) dp[i][j] = min(dp[t][j - 1] + cost[t + 1][i], dp[i][j]); dp[i][j] = min(dp[i][j - 1], dp[i][j]); } } return dp[n][k]; } int main() { int n, m, k; assert(3 == scanf("%d %d %d", &n, &m, &k)); std::vector<int> r(n), c(n); for (int i = 0; i < n; i++) { assert(2 == scanf("%d %d", &r[i], &c[i])); } long long ans = take_photos(n, m, k, r, c); printf("%lld\n", ans); return 0; } /** 5 7 2 0 3 4 4 4 6 4 5 4 6 */

Compilation message (stderr)

/usr/bin/ld: /tmp/ccV9ahys.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cck3nPvv.o:aliens.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status