# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
957079 | mariaclara | Aliens (IOI16_aliens) | C++17 | 2035 ms | 94548 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 "aliens.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef tuple<int,int,int> trio;
typedef pair<ll,ll> pii;
const int MAXN = 2e5+5;
const int MOD = 1e9+7;
#define sz(x) x.size()
#define all(x) x.begin(), x.end()
#define mk make_pair
#define pb push_back
#define f first
#define s second
ll take_photos(int n, int m, int k, vector<int> r, vector<int> c) {
vector<pii> p;
for(int i = 0; i < n; i++)
p.pb({min(r[i],c[i]), max(r[i],c[i])+1});
sort(all(p), [](pii a, pii b){
if(a.f != b.f) return a.f < b.f;
return a.s > b.s;
});
vector<pii> square;
square.pb({0,0});
for(int i = 0; i < n; i++)
if(square.back().s < p[i].s) square.pb(p[i]);
ll dp[n+1][k+1];
for(int j = 0; j <= k; j++) dp[0][j] = 0;
for(int i = 1; i < sz(square); i++) {
dp[i][0] = 1e12;
for(int j = 1; j <= k; j++) {
dp[i][j] = dp[i][j-1];
for(int l = 1; l <= i; l++) {
ll area = dp[l-1][j-1];
area += (square[i].s - square[l].f)*(square[i].s - square[l].f);
area -= max(0LL, square[l-1].s - square[l].f)*max(0LL, square[l-1].s - square[l].f);
dp[i][j] = min(dp[i][j], area);
}
}
}
// intercessao = max(0LL, square[i-1].s - square[i].f)*max(0LL, square[i-1].s - square[i].f);
return dp[sz(square)-1][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... |