# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
30511 |
2017-07-24T08:54:24 Z |
zoomswk |
Aliens (IOI16_aliens) |
C++14 |
|
0 ms |
4368 KB |
#include "aliens.h"
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> p;
int L[100005], R[100005];
long long dp[100005][2];
void run(int l, int r, int opt_l, int opt_r, int lv){
if(l > r) return;
int mid = (l+r)>>1;
int new_opt = -1;
int now = lv&1, prev = !now;
for(int x=opt_l; x<=min(opt_r, mid); x++){
long long cst = dp[x-1][prev]+1LL*(R[mid]-L[x]+1)*(R[mid]-L[x]+1)-(R[x-1]-L[x]+1 > 0 ? 1LL*(R[x-1]-L[x]+1)*(R[x-1]-L[x]+1): 0LL);
if(cst < dp[mid][now]){
dp[mid][now] = cst;
new_opt = x;
}
}
run(l, mid-1, opt_l, new_opt, lv);
run(mid+1, r, new_opt, opt_r, lv);
return;
}
long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c){
for(int i=0; i<n; i++) p.push_back({min(r[i], c[i]), -max(r[i], c[i])});
sort(p.begin(), p.end());
int N=1, tmp_mx=-1;
for(int i=0; i<n; i++){
if(-p[i].second > tmp_mx){
L[N] = p[i].first, R[N] = -p[i].second;
tmp_mx = -p[i].second;
N++;
}
}
N--;
R[0] = -1e9;
for(int i=1; i<=min(N, k); i++){
int now = i&1, prev = !now;
for(int j=1; j<=N; j++) dp[j][now] = 1e18;
run(1, N, 1, N, i);
}
return dp[N][min(N, k)&1];
}
Compilation message
aliens.cpp: In function 'long long int take_photos(int, int, int, std::vector<int>, std::vector<int>)':
aliens.cpp:40:24: warning: unused variable 'prev' [-Wunused-variable]
int now = i&1, prev = !now;
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 4 |
2 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 4 |
3 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 4 |
4 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 12 |
5 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 52 |
6 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 210 |
7 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 88 |
8 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 7696 |
9 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 1 |
10 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 2374 |
11 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 9502 |
12 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 49 |
13 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 151 |
14 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 7550 |
15 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 7220 |
16 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 7550 |
17 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 10000 |
18 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 10000 |
19 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 624 |
20 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 10000 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 1 |
2 |
Incorrect |
0 ms |
4368 KB |
Wrong answer: output = 1, expected = 4 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 4 |
2 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 4 |
3 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 4 |
4 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 12 |
5 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 52 |
6 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 210 |
7 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 88 |
8 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 7696 |
9 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 1 |
10 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 2374 |
11 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 9502 |
12 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 49 |
13 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 151 |
14 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 7550 |
15 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 7220 |
16 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 7550 |
17 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 10000 |
18 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 10000 |
19 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 624 |
20 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 10000 |
21 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 1 |
22 |
Incorrect |
0 ms |
4368 KB |
Wrong answer: output = 1, expected = 4 |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 4 |
2 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 4 |
3 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 4 |
4 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 12 |
5 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 52 |
6 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 210 |
7 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 88 |
8 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 7696 |
9 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 1 |
10 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 2374 |
11 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 9502 |
12 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 49 |
13 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 151 |
14 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 7550 |
15 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 7220 |
16 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 7550 |
17 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 10000 |
18 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 10000 |
19 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 624 |
20 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 10000 |
21 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 1 |
22 |
Incorrect |
0 ms |
4368 KB |
Wrong answer: output = 1, expected = 4 |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 4 |
2 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 4 |
3 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 4 |
4 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 12 |
5 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 52 |
6 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 210 |
7 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 88 |
8 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 7696 |
9 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 1 |
10 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 2374 |
11 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 9502 |
12 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 49 |
13 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 151 |
14 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 7550 |
15 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 7220 |
16 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 7550 |
17 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 10000 |
18 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 10000 |
19 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 624 |
20 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 10000 |
21 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 1 |
22 |
Incorrect |
0 ms |
4368 KB |
Wrong answer: output = 1, expected = 4 |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 4 |
2 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 4 |
3 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 4 |
4 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 12 |
5 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 52 |
6 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 210 |
7 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 88 |
8 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 7696 |
9 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 1 |
10 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 2374 |
11 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 9502 |
12 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 49 |
13 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 151 |
14 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 7550 |
15 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 7220 |
16 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 7550 |
17 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 10000 |
18 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 10000 |
19 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 624 |
20 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 10000 |
21 |
Correct |
0 ms |
4368 KB |
Correct answer: answer = 1 |
22 |
Incorrect |
0 ms |
4368 KB |
Wrong answer: output = 1, expected = 4 |
23 |
Halted |
0 ms |
0 KB |
- |