Submission #425240

# Submission time Handle Problem Language Result Execution time Memory
425240 2021-06-12T17:17:34 Z vanic Aliens (IOI16_aliens) C++14
12 / 100
186 ms 7236 KB
#include "aliens.h"
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;

const int maxn=4005;

bool cmp(pair < int, int > a, pair < int, int > b){
	return max(a.first, a.second)<max(b.first, b.second);
}

int n, m, k;
ll dp[maxn][maxn];
pair < int, int > p[maxn];
ll pov[maxn][maxn];

void precompute(){
	int maxx, maxy;
	int minx, miny;
	int raz;
	for(int i=0; i<n; i++){
		maxx=0;
		maxy=0;
		minx=1e9;
		miny=1e9;
		for(int j=i; j<n; j++){
			maxx=max(maxx, p[j].first);
			minx=min(minx, p[j].first);
			maxy=max(maxy, p[j].second);
			miny=min(miny, p[j].second);
			raz=abs(max(maxx, maxy)-min(minx, miny))+1;
			pov[i][j]=(ll)raz*raz;
		}
	}
}


ll take_photos(int nn, int mm, int kk, vector < int > r, vector < int > c){
	n=nn;
	m=mm;
	k=kk;
	for(int i=0; i<n; i++){
		if(r[i]>c[i]){
			swap(r[i], c[i]);
		}
		p[i]={r[i], c[i]};
	}
	sort(p, p+n, cmp);
/*	for(int i=0; i<n; i++){
		cout << p[i].first << ' ' << p[i].second << endl;
	}*/
	precompute();
/*	for(int i=0; i<n; i++){
		for(int j=i; j<n; j++){
			cout << pov[i][j] << ' ';
		}
		cout << endl;
	}*/
	for(int i=0; i<n; i++){
		dp[i][1]=pov[0][i];
		for(int j=2; j<=k; j++){
			dp[i][j]=1e18;
			for(int l=0; l<i; l++){
				dp[i][j]=min(dp[i][j], dp[l][j-1]+pov[l+1][i]);
			}
		}
	}
	ll sol=1e18;
	for(int i=1; i<=k; i++){
		sol=min(sol, dp[n-1][i]);
	}
	return sol;
}
# 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 Incorrect 1 ms 300 KB Wrong answer: output = 13, expected = 12
5 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 332 KB Correct answer: answer = 1
4 Correct 0 ms 332 KB Correct answer: answer = 5
5 Correct 1 ms 332 KB Correct answer: answer = 41
6 Correct 1 ms 460 KB Correct answer: answer = 71923
7 Correct 2 ms 1996 KB Correct answer: answer = 77137
8 Correct 64 ms 6224 KB Correct answer: answer = 764
9 Correct 3 ms 5324 KB Correct answer: answer = 250000
10 Correct 136 ms 7236 KB Correct answer: answer = 500
11 Correct 1 ms 204 KB Correct answer: answer = 32
12 Correct 4 ms 5228 KB Correct answer: answer = 130050
13 Correct 15 ms 5452 KB Correct answer: answer = 5110
14 Correct 3 ms 2636 KB Correct answer: answer = 2626
15 Correct 9 ms 2764 KB Correct answer: answer = 796
16 Correct 13 ms 5408 KB Correct answer: answer = 7580
17 Correct 35 ms 5792 KB Correct answer: answer = 1904
18 Correct 3 ms 5324 KB Correct answer: answer = 996004
19 Correct 8 ms 5412 KB Correct answer: answer = 38817
20 Correct 27 ms 5608 KB Correct answer: answer = 4096
21 Correct 3 ms 5324 KB Correct answer: answer = 1
22 Correct 186 ms 7232 KB Correct answer: answer = 1
23 Correct 32 ms 5700 KB Correct answer: answer = 2040
24 Correct 134 ms 7164 KB Correct answer: answer = 2
# 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 Incorrect 1 ms 300 KB Wrong answer: output = 13, expected = 12
5 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 Incorrect 1 ms 300 KB Wrong answer: output = 13, expected = 12
5 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 Incorrect 1 ms 300 KB Wrong answer: output = 13, expected = 12
5 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 Incorrect 1 ms 300 KB Wrong answer: output = 13, expected = 12
5 Halted 0 ms 0 KB -