# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
425786 |
2021-06-13T11:28:32 Z |
ngrace |
Aliens (IOI16_aliens) |
C++14 |
|
2000 ms |
311052 KB |
#include "aliens.h"
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <set>
using namespace std;
#define v vector
#define pii pair<int,int>
#define fi first
#define se second
int N,K;
v<pii> pos;
v<v<v<long long>>> memo;
long long diagSolve(int l, int r, int k){
long long curArea=(pos[r].se-pos[l].fi+1) * (pos[r].se-pos[l].fi+1);
//check for intersection with prev:
if(l!=0){
long long length = max(0, pos[l-1].se-pos[l].fi+1);
curArea-=length*length;
}
if(r==N-1){
return memo[l][r][k] = curArea;
}
if(k==K-1){
return memo[l][r][k] = diagSolve(l,N-1,k);
}
if(memo[l][r][k]!=-1) return memo[l][r][k];
long long takePhoto = curArea+diagSolve(r+1,r+1,k+1);
long long dont = diagSolve(l,r+1,k);
return memo[l][r][k] = min(takePhoto, dont);
}
long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c) {
if(k==n){//sub 1
v<v<bool>> squares(m,v<bool>(m,false));
for(int i=0;i<n;i++){
int low=min(r[i],c[i]);
int high=max(r[i],c[i]);
for(int a=low;a<=high;a++){
for(int b=low;b<=high;b++){
squares[a][b]=true;
}
}
}
long long out=0;
for(int i=0;i<m;i++){
for(int j=0;j<m;j++){
out+=squares[i][j];
}
}
return out;
}
else{
K=k;
set<pii> tmp;
for(int i=0;i<n;i++){
tmp.insert({r[i],-c[i]});
}
for(pii it:tmp){
if(pos.size()==0) {
pos.push_back({it.fi,-it.se});
continue;
}
if(it.fi<=pos.back().se && -it.se<=pos.back().se) continue;
pos.push_back({it.fi,-it.se});
}
N=pos.size();
memo=v<v<v<long long>>>(N+1,v<v<long long>>(N+1,v<long long>(k+1,-1)));
return diagSolve(0,0,0);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
2 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 4 |
3 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 4 |
4 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 12 |
5 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 52 |
6 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 210 |
7 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 88 |
8 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7696 |
9 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 1 |
10 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 2374 |
11 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 9502 |
12 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 49 |
13 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 151 |
14 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7550 |
15 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7220 |
16 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7550 |
17 |
Correct |
2 ms |
204 KB |
Correct answer: answer = 10000 |
18 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 10000 |
19 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 624 |
20 |
Correct |
2 ms |
204 KB |
Correct answer: answer = 10000 |
# |
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 |
204 KB |
Correct answer: answer = 1 |
4 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 5 |
5 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 41 |
6 |
Correct |
1 ms |
332 KB |
Correct answer: answer = 71923 |
7 |
Correct |
10 ms |
4172 KB |
Correct answer: answer = 77137 |
8 |
Correct |
1102 ms |
311052 KB |
Correct answer: answer = 764 |
9 |
Correct |
17 ms |
14112 KB |
Correct answer: answer = 250000 |
10 |
Correct |
1 ms |
332 KB |
Correct answer: answer = 500 |
11 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 32 |
12 |
Correct |
18 ms |
14116 KB |
Correct answer: answer = 130050 |
13 |
Correct |
684 ms |
108636 KB |
Correct answer: answer = 5110 |
14 |
Correct |
55 ms |
16416 KB |
Correct answer: answer = 2626 |
15 |
Correct |
157 ms |
46504 KB |
Correct answer: answer = 796 |
16 |
Correct |
539 ms |
77136 KB |
Correct answer: answer = 7580 |
17 |
Execution timed out |
2104 ms |
273896 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
2 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 4 |
3 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 4 |
4 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 12 |
5 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 52 |
6 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 210 |
7 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 88 |
8 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7696 |
9 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 1 |
10 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 2374 |
11 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 9502 |
12 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 49 |
13 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 151 |
14 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7550 |
15 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7220 |
16 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7550 |
17 |
Correct |
2 ms |
204 KB |
Correct answer: answer = 10000 |
18 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 10000 |
19 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 624 |
20 |
Correct |
2 ms |
204 KB |
Correct answer: answer = 10000 |
21 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 1 |
22 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
23 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 1 |
24 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 5 |
25 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 41 |
26 |
Correct |
1 ms |
332 KB |
Correct answer: answer = 71923 |
27 |
Correct |
10 ms |
4172 KB |
Correct answer: answer = 77137 |
28 |
Correct |
1102 ms |
311052 KB |
Correct answer: answer = 764 |
29 |
Correct |
17 ms |
14112 KB |
Correct answer: answer = 250000 |
30 |
Correct |
1 ms |
332 KB |
Correct answer: answer = 500 |
31 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 32 |
32 |
Correct |
18 ms |
14116 KB |
Correct answer: answer = 130050 |
33 |
Correct |
684 ms |
108636 KB |
Correct answer: answer = 5110 |
34 |
Correct |
55 ms |
16416 KB |
Correct answer: answer = 2626 |
35 |
Correct |
157 ms |
46504 KB |
Correct answer: answer = 796 |
36 |
Correct |
539 ms |
77136 KB |
Correct answer: answer = 7580 |
37 |
Execution timed out |
2104 ms |
273896 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
2 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 4 |
3 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 4 |
4 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 12 |
5 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 52 |
6 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 210 |
7 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 88 |
8 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7696 |
9 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 1 |
10 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 2374 |
11 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 9502 |
12 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 49 |
13 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 151 |
14 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7550 |
15 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7220 |
16 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7550 |
17 |
Correct |
2 ms |
204 KB |
Correct answer: answer = 10000 |
18 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 10000 |
19 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 624 |
20 |
Correct |
2 ms |
204 KB |
Correct answer: answer = 10000 |
21 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 1 |
22 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
23 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 1 |
24 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 5 |
25 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 41 |
26 |
Correct |
1 ms |
332 KB |
Correct answer: answer = 71923 |
27 |
Correct |
10 ms |
4172 KB |
Correct answer: answer = 77137 |
28 |
Correct |
1102 ms |
311052 KB |
Correct answer: answer = 764 |
29 |
Correct |
17 ms |
14112 KB |
Correct answer: answer = 250000 |
30 |
Correct |
1 ms |
332 KB |
Correct answer: answer = 500 |
31 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 32 |
32 |
Correct |
18 ms |
14116 KB |
Correct answer: answer = 130050 |
33 |
Correct |
684 ms |
108636 KB |
Correct answer: answer = 5110 |
34 |
Correct |
55 ms |
16416 KB |
Correct answer: answer = 2626 |
35 |
Correct |
157 ms |
46504 KB |
Correct answer: answer = 796 |
36 |
Correct |
539 ms |
77136 KB |
Correct answer: answer = 7580 |
37 |
Execution timed out |
2104 ms |
273896 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
2 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 4 |
3 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 4 |
4 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 12 |
5 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 52 |
6 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 210 |
7 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 88 |
8 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7696 |
9 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 1 |
10 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 2374 |
11 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 9502 |
12 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 49 |
13 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 151 |
14 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7550 |
15 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7220 |
16 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7550 |
17 |
Correct |
2 ms |
204 KB |
Correct answer: answer = 10000 |
18 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 10000 |
19 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 624 |
20 |
Correct |
2 ms |
204 KB |
Correct answer: answer = 10000 |
21 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 1 |
22 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
23 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 1 |
24 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 5 |
25 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 41 |
26 |
Correct |
1 ms |
332 KB |
Correct answer: answer = 71923 |
27 |
Correct |
10 ms |
4172 KB |
Correct answer: answer = 77137 |
28 |
Correct |
1102 ms |
311052 KB |
Correct answer: answer = 764 |
29 |
Correct |
17 ms |
14112 KB |
Correct answer: answer = 250000 |
30 |
Correct |
1 ms |
332 KB |
Correct answer: answer = 500 |
31 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 32 |
32 |
Correct |
18 ms |
14116 KB |
Correct answer: answer = 130050 |
33 |
Correct |
684 ms |
108636 KB |
Correct answer: answer = 5110 |
34 |
Correct |
55 ms |
16416 KB |
Correct answer: answer = 2626 |
35 |
Correct |
157 ms |
46504 KB |
Correct answer: answer = 796 |
36 |
Correct |
539 ms |
77136 KB |
Correct answer: answer = 7580 |
37 |
Execution timed out |
2104 ms |
273896 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
2 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 4 |
3 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 4 |
4 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 12 |
5 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 52 |
6 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 210 |
7 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 88 |
8 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7696 |
9 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 1 |
10 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 2374 |
11 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 9502 |
12 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 49 |
13 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 151 |
14 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7550 |
15 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7220 |
16 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7550 |
17 |
Correct |
2 ms |
204 KB |
Correct answer: answer = 10000 |
18 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 10000 |
19 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 624 |
20 |
Correct |
2 ms |
204 KB |
Correct answer: answer = 10000 |
21 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 1 |
22 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
23 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 1 |
24 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 5 |
25 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 41 |
26 |
Correct |
1 ms |
332 KB |
Correct answer: answer = 71923 |
27 |
Correct |
10 ms |
4172 KB |
Correct answer: answer = 77137 |
28 |
Correct |
1102 ms |
311052 KB |
Correct answer: answer = 764 |
29 |
Correct |
17 ms |
14112 KB |
Correct answer: answer = 250000 |
30 |
Correct |
1 ms |
332 KB |
Correct answer: answer = 500 |
31 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 32 |
32 |
Correct |
18 ms |
14116 KB |
Correct answer: answer = 130050 |
33 |
Correct |
684 ms |
108636 KB |
Correct answer: answer = 5110 |
34 |
Correct |
55 ms |
16416 KB |
Correct answer: answer = 2626 |
35 |
Correct |
157 ms |
46504 KB |
Correct answer: answer = 796 |
36 |
Correct |
539 ms |
77136 KB |
Correct answer: answer = 7580 |
37 |
Execution timed out |
2104 ms |
273896 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |