# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
43012 |
2018-03-08T05:33:16 Z |
nonocut |
Aliens (IOI16_aliens) |
C++14 |
|
9 ms |
8604 KB |
#include "aliens.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll,int>
#define X first
#define Y second
const int maxn = 1e3 + 5;
const ll inf = 1e12;
int n,m,k,sz;
pair<int,int> p[maxn];
vector<pair<int,int>> a;
ll mem[maxn][maxn];
ll getpow(ll x) {
return x*x;
}
ll f(int x, int k) {
if(x==sz) return 0;
if(mem[x][k]==-1) {
mem[x][k] = inf;
for(int y=x;y<n;y++) {
if(k) {
mem[x][k] = min(mem[x][k], getpow(p[y].Y-p[x].X+1) + f(y+1,k-1));
}
}
}
return mem[x][k];
}
bool cmp(pii x, pii y) {
if(x.X!=y.X) return x.X<y.X;
return x.Y>y.Y;
}
long long take_photos(int N, int M, int K, std::vector<int> R, std::vector<int> C) {
n = N; m = M; k = K;
//prep
for(int i=0;i<n;i++) {
p[i] = {R[i],C[i]};
if(p[i].X>p[i].Y) swap(p[i].X,p[i].Y);
}
sort(p,p+n,cmp);
ll cur = -inf;
for(int i=0;i<n;i++) {
if(p[i].Y<=cur) continue;
a.push_back(p[i]);
cur = p[i].Y;
}
sz = a.size();
// for(auto t : a) printf("[%d, %d]\n",t.X,t.Y);
memset(mem,-1,sizeof(mem));
return f(0,k);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
8184 KB |
Correct answer: answer = 4 |
2 |
Correct |
7 ms |
8292 KB |
Correct answer: answer = 4 |
3 |
Correct |
9 ms |
8400 KB |
Correct answer: answer = 4 |
4 |
Incorrect |
8 ms |
8452 KB |
Wrong answer: output = 13, expected = 12 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
8452 KB |
Correct answer: answer = 1 |
2 |
Correct |
7 ms |
8452 KB |
Correct answer: answer = 4 |
3 |
Correct |
9 ms |
8604 KB |
Correct answer: answer = 1 |
4 |
Incorrect |
7 ms |
8604 KB |
Wrong answer: output = 2, expected = 5 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
8184 KB |
Correct answer: answer = 4 |
2 |
Correct |
7 ms |
8292 KB |
Correct answer: answer = 4 |
3 |
Correct |
9 ms |
8400 KB |
Correct answer: answer = 4 |
4 |
Incorrect |
8 ms |
8452 KB |
Wrong answer: output = 13, expected = 12 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
8184 KB |
Correct answer: answer = 4 |
2 |
Correct |
7 ms |
8292 KB |
Correct answer: answer = 4 |
3 |
Correct |
9 ms |
8400 KB |
Correct answer: answer = 4 |
4 |
Incorrect |
8 ms |
8452 KB |
Wrong answer: output = 13, expected = 12 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
8184 KB |
Correct answer: answer = 4 |
2 |
Correct |
7 ms |
8292 KB |
Correct answer: answer = 4 |
3 |
Correct |
9 ms |
8400 KB |
Correct answer: answer = 4 |
4 |
Incorrect |
8 ms |
8452 KB |
Wrong answer: output = 13, expected = 12 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
8184 KB |
Correct answer: answer = 4 |
2 |
Correct |
7 ms |
8292 KB |
Correct answer: answer = 4 |
3 |
Correct |
9 ms |
8400 KB |
Correct answer: answer = 4 |
4 |
Incorrect |
8 ms |
8452 KB |
Wrong answer: output = 13, expected = 12 |
5 |
Halted |
0 ms |
0 KB |
- |