# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
889713 | Ghulam_Junaid | Aliens (IOI16_aliens) | C++17 | 1 ms | 604 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 "grader.cpp"
using namespace std;
typedef long long ll;
const int N = 4005;
const int inf = 1e9;
bool vis[N][N];
ll dp[N][N];
ll take_photos(int n, int m, int k, vector<int> r, vector<int> c){
if (n == k){
ll ans = 0;
int last = 0;
for (int i = 0; i < m; i++){
// we are at (i, i);
int len = 0;
for (int j = 0; j < n; j++){
if (vis[r[j]][c[j]])
continue;
if (r[j] == i)
len = max(len, c[j] - i + 1);
if (c[j] == i)
len = max(len, r[j] - i + 1);
}
for (int x = i; x < i + len; x++){
for (int y = i; y < i + len; y++){
vis[x][y] = 1;
}
}
}
for (int i=0; i<m; i++)
for (int j=0; j<m; j++)
ans += vis[i][j];
return ans;
}
for (int i=0; i<m; i++)
for (int j=0; j<=k; j++)
dp[i][j] = inf;
for (int i = m - 1; i >= 0; i--){
int mx = -1;
for (int j = 0; j < n; j++)
if (r[j] >= i)
mx = max(mx, r[j]);
for (int j = 0; j <= k; j++){
if (mx < i){
dp[i][j] = 0;
continue;
}
if (j == 0)
continue;
for (int ip = i + 1; ip <= m; ip++){
dp[i][j] = min(dp[i][j], (ip - i) * (ip - i) + dp[ip][j - 1]);
}
}
for (int j = 1; j <= k; j++)
dp[i][j] = min(dp[i][j], dp[i][j - 1]);
}
return (ll)dp[0][k];
}
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... |