# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
427421 |
2021-06-14T15:05:39 Z |
2qbingxuan |
Aliens (IOI16_aliens) |
C++14 |
|
2000 ms |
498388 KB |
#include "aliens.h"
#include <bits/stdc++.h>
#ifdef local
#define debug(x...) qqbx(#x, x)
#define pary(x...) danb(#x, x)
#define safe std::cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n"
template <typename ...T> void qqbx(const char *s, T ...a) {
int cnt = sizeof...(T);
((std::cerr << "\e[1;32m(" << s << ") = ("), ..., (std::cerr << a << (--cnt ? ", " : ")\e[0m\n")));
}
template <typename T> void danb(const char *s, T L, T R) {
std::cerr << "\e[1;32m[ " << s << " ] = [ ";
for (int f = 0; L != R; ++L)
std::cerr << (f++ ? ", " : "") << *L;
std::cerr << " ]\e[0m\n";
}
#else
#define debug(...) ((void)0)
#define pary(...) ((void)0)
#define safe ((void)0)
#endif // local
#define all(v) begin(v),end(v)
using namespace std;
using ll = long long;
const ll INF = 1e18;
void chmin(ll &x, ll v) {
if (x > v)
x = v;
}
ll sq(ll x) {
return x * x;
}
long long take_photos(int n, int m, int k, std::vector<int> row, std::vector<int> col) {
vector<pair<int,int>> seg;
for (int i = 0; i < n; i++) {
int l = row[i], r = col[i];
if (l > r) swap(l, r);
seg.emplace_back(l, r);
}
sort(all(seg));
vector<vector<vector<ll>>> dp(n+1, vector<vector<ll>>(k+1, vector<ll>(n+1, INF)));
dp[0][0][0] = 0;
for (int i = 0; i < n; i++) {
int l = seg[i].first;
int r = seg[i].second;
int mxpos = i;
for (int j = i+1; j <= n; j++) {
for (int c = 0; c < k; c++) {
for (int a = 0; a <= n; a++) {
int lastr = (a ? seg[a-1].second : -1);
if (dp[i][c][a] == INF) continue;
ll cost = (lastr < l ? sq(r - l + 1) : lastr >= r ? 0 : sq(r - l + 1) - sq(lastr - l + 1));
chmin(dp[j][c+1][mxpos+1], dp[i][c][a] + cost);
}
}
if (j < n) {
if (r < seg[j].second) {
r = seg[j].second;
mxpos = j;
}
}
}
}
ll mn = INF;
for (int a = 0; a <= n; a++)
mn = min(mn, dp[n][k][a]);
return mn;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
2 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
3 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
4 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 12 |
5 |
Incorrect |
1 ms |
204 KB |
Wrong answer: output = 57, expected = 52 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 1 |
2 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
3 |
Correct |
1 ms |
292 KB |
Correct answer: answer = 1 |
4 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 5 |
5 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 41 |
6 |
Correct |
1 ms |
296 KB |
Correct answer: answer = 71923 |
7 |
Correct |
52 ms |
3788 KB |
Correct answer: answer = 77137 |
8 |
Execution timed out |
2112 ms |
498388 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
2 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
3 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
4 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 12 |
5 |
Incorrect |
1 ms |
204 KB |
Wrong answer: output = 57, expected = 52 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
2 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
3 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
4 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 12 |
5 |
Incorrect |
1 ms |
204 KB |
Wrong answer: output = 57, expected = 52 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
2 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
3 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
4 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 12 |
5 |
Incorrect |
1 ms |
204 KB |
Wrong answer: output = 57, expected = 52 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
2 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
3 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
4 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 12 |
5 |
Incorrect |
1 ms |
204 KB |
Wrong answer: output = 57, expected = 52 |
6 |
Halted |
0 ms |
0 KB |
- |