#include "aliens.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll solveSubtask1(int n, int m, int k, std::vector<int> r, std::vector<int> c) {
bool grid[m][m];
memset(grid,0, sizeof grid);
for(int i=0; i<n; i++) {
int x = r[i], y = c[i];
if(y < x) swap(x, y);
for(int j=x; j <= y; j++)
for(int k = x; k <= y; k++)
grid[j][k] = 1;
}
int ans = 0;
for(int i=0; i<m; i++)
for(int j=0; j<m; j++)
ans += grid[i][j];
return ans;
}
#define sq(a) ((a) * (a))
ll solveSubtask2(int n, int m, int kk, std::vector<int> r, std::vector<int> c) {
sort(r.begin(), r.end());
r.erase(unique(r.begin(), r.end()), r.end());
ll dp[kk+1][n+1];
memset(dp, 0, sizeof dp);
for(int i=1; i <= n; i++) {
dp[1][i] = sq(r[i-1] - r[0] + 1);
}
for(int k=2; k <= kk; k++) {
for(int i=k; i<=n; i++) {
dp[k][i] = 1e18;
for(int j=0; j < i; j++) {
dp[k][i] = min(dp[k][i], dp[k-1][j] + sq(r[i-1] - r[j] + 1));
}
}
}
ll Min = 1e18;
for(int k = 1; k <= kk; k++)
Min = min(Min, dp[k][n]);
return dp[kk][n];
}
ll take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c) {
if(n <= 50 && m <= 100 && n == k) return solveSubtask1(n, m, k, r, c);
bool f = 0;
for(int i=0; i<n; i++)
if(r[i] != c[i]) { f = 1; break; }
if(!f) return solveSubtask2(n, m, k, r, c);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 4 |
2 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 4 |
3 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 4 |
4 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 12 |
5 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 52 |
6 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 210 |
7 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 88 |
8 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 7696 |
9 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 1 |
10 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 2374 |
11 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 9502 |
12 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 49 |
13 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 151 |
14 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 7550 |
15 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 7220 |
16 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 7550 |
17 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 10000 |
18 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 10000 |
19 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 624 |
20 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 10000 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 1 |
2 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 4 |
3 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 1 |
4 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 5 |
5 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 41 |
6 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 71923 |
7 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 77137 |
8 |
Correct |
96 ms |
2880 KB |
Correct answer: answer = 764 |
9 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 250000 |
10 |
Incorrect |
133 ms |
3856 KB |
Wrong answer: output = 4, expected = 500 |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 4 |
2 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 4 |
3 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 4 |
4 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 12 |
5 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 52 |
6 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 210 |
7 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 88 |
8 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 7696 |
9 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 1 |
10 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 2374 |
11 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 9502 |
12 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 49 |
13 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 151 |
14 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 7550 |
15 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 7220 |
16 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 7550 |
17 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 10000 |
18 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 10000 |
19 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 624 |
20 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 10000 |
21 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 1 |
22 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 4 |
23 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 1 |
24 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 5 |
25 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 41 |
26 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 71923 |
27 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 77137 |
28 |
Correct |
96 ms |
2880 KB |
Correct answer: answer = 764 |
29 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 250000 |
30 |
Incorrect |
133 ms |
3856 KB |
Wrong answer: output = 4, expected = 500 |
31 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 4 |
2 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 4 |
3 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 4 |
4 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 12 |
5 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 52 |
6 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 210 |
7 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 88 |
8 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 7696 |
9 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 1 |
10 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 2374 |
11 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 9502 |
12 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 49 |
13 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 151 |
14 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 7550 |
15 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 7220 |
16 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 7550 |
17 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 10000 |
18 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 10000 |
19 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 624 |
20 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 10000 |
21 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 1 |
22 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 4 |
23 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 1 |
24 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 5 |
25 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 41 |
26 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 71923 |
27 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 77137 |
28 |
Correct |
96 ms |
2880 KB |
Correct answer: answer = 764 |
29 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 250000 |
30 |
Incorrect |
133 ms |
3856 KB |
Wrong answer: output = 4, expected = 500 |
31 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 4 |
2 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 4 |
3 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 4 |
4 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 12 |
5 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 52 |
6 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 210 |
7 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 88 |
8 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 7696 |
9 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 1 |
10 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 2374 |
11 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 9502 |
12 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 49 |
13 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 151 |
14 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 7550 |
15 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 7220 |
16 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 7550 |
17 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 10000 |
18 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 10000 |
19 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 624 |
20 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 10000 |
21 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 1 |
22 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 4 |
23 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 1 |
24 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 5 |
25 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 41 |
26 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 71923 |
27 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 77137 |
28 |
Correct |
96 ms |
2880 KB |
Correct answer: answer = 764 |
29 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 250000 |
30 |
Incorrect |
133 ms |
3856 KB |
Wrong answer: output = 4, expected = 500 |
31 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 4 |
2 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 4 |
3 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 4 |
4 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 12 |
5 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 52 |
6 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 210 |
7 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 88 |
8 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 7696 |
9 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 1 |
10 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 2374 |
11 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 9502 |
12 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 49 |
13 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 151 |
14 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 7550 |
15 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 7220 |
16 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 7550 |
17 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 10000 |
18 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 10000 |
19 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 624 |
20 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 10000 |
21 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 1 |
22 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 4 |
23 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 1 |
24 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 5 |
25 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 41 |
26 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 71923 |
27 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 77137 |
28 |
Correct |
96 ms |
2880 KB |
Correct answer: answer = 764 |
29 |
Correct |
0 ms |
2024 KB |
Correct answer: answer = 250000 |
30 |
Incorrect |
133 ms |
3856 KB |
Wrong answer: output = 4, expected = 500 |
31 |
Halted |
0 ms |
0 KB |
- |