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"
#define sz(x) ((int)x.size())
#define pii pair<int, int>
#define MP make_pair
#define PB push_back
#define ft first
#define sd second
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
const int N = 50100;
const int K = 110;
const ll OO = 1e18;
vector<pii> vc, seg;
int n, m, k;
ll f[N][K];
bool mrk[K][K];
ll sqr(ll x) { return x * x; }
long long take_photos(int N, int M, int K, std::vector<int> r, std::vector<int> c) {
n = N; m = M; k = K;
for (int i = 0; i < n; i++){
int mn = min(r[i], c[i]);
int mx = max(r[i], c[i]);
for (int i = mn; i <= mx; i++)
for (int j = mn; j <= mx; j++)
mrk[i][j] = 1;
}
int ans = 0;
for (int i = 0; i < m; i++)
for (int j = 0; j < m; j++)
ans += mrk[i][j];
return ans;
//
// for (int i = 0; i < n; i++)
// vc.PB(MP(min(r[i], c[i]), -max(r[i], c[i])));
//
// sort(all(vc));
//
// int lst = -vc[0].sd;
//
// seg.PB(vc[0]);
// seg.back().sd *= -1;
// seg.back().ft--;
//
// for (int i = 1; i < sz(vc); i++){
// pii cr = vc[i];
//
// if (-cr.sd <= lst) continue;
//
// lst = -cr.sd;
//
// seg.PB(cr);
// seg.back().sd *= -1;
// seg.back().ft--;
// }
//
// n = sz(seg);
// k = min(n, k);
//
// ll ans = 0;
//
// for (int i = 0; i < n; i++){
// ans += sqr(seg[i].sd - seg[i].ft);
// if (i > 0)
// ans -= max(0ll, sqr(seg[i - 1].sd - seg[i].ft));
// }
//
// return ans;
// // check if only k is correct
//
// for (int i = 1; i <= n; i++)
// for (int j = 0; j <= k; j++)
// f[i][j] = OO;
//
// for (int kl = 1; kl <= k; kl++)
// for (int i = 1; i <= n; i++){
// for (int j = kl - 1; j < i; j++)
// if (f[j][kl - 1] != OO) {
// ll nw = f[j][kl - 1] + sqr(seg[i - 1].sd - seg[j].ft);
//
// // check if max(0, smth) is need
//
// if (j > 0)
// nw -= max(0ll, sqr(seg[j - 1].sd - seg[j].ft));
//
// f[i][kl] = min(f[i][kl], nw);
// }
// }
//
// return f[n][k];
}
# | 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... |