# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
599363 | gromperen | Aliens (IOI16_aliens) | C++14 | 117 ms | 1300 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "aliens.h"
const int INF = 1e9+7;
using namespace std;
long long take_photos(int n, int m, int k, vector<int> r, vector<int> c) {
/*
vector<vector<int>> vis(m+1, vector<int>(m+1));
int ans = 0;
for (int i = 0; i < n; ++i) {
for (int x = r[i]; x <= c[i]; ++x) {
for (int y = r[i]; y <= c[i]; ++y) {
if (vis[x][y]) continue;
ans++;
vis[x][y] = 1;
}
}
}
*/
vector<pair<int,int>> tmpcords;
vector<pair<int,int>> cords;
for (int i = 0; i < n; ++i) {
tmpcords.push_back({r[i], c[i]});
}
sort(tmpcords.begin(), tmpcords.end());
for (int i = 0; i < n; ++i) {
if (i > 0 && tmpcords[i].first == cords[i-1].first && tmpcords[i].second == cords[i-1].second) continue;
cords.push_back(tmpcords[i]);
}
vector<vector<int>> dp(n+1, vector<int>(k+1, INF));
n = cords.size();
dp[0][0] = 0;
//for (int i = 0; i < cords.size(); ++i) {
//dp[0][i] = 0;
//}
for (int i = 1; i <= cords.size(); ++i) {
for (int j =1; j <= k; ++j) {
for (int p = 0; p < i; ++p) {
dp[i][j] = min(dp[i][j],
dp[p][j-1] +
(cords[i-1].first - cords[p].first + 1) * (cords[i-1].second - cords[p].first + 1));
}
}
}
int ans = 1e9+7;
for (int i = 0; i <= k; ++i) {
ans = min(ans, dp[cords.size()][i]);
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |