Submission #389061

# Submission time Handle Problem Language Result Execution time Memory
389061 2021-04-13T14:59:26 Z alishahali1382 Aliens (IOI16_aliens) C++14
4 / 100
2 ms 2256 KB
#include "aliens.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define debug(x) {cerr<<#x<<"="<<x<<"\n";}
#define debug2(x, y) {cerr<<#x<<", "<<#y<<" = "<<x<<", "<<y<<"\n";}
#define debugp(p) {cerr<<#p<<"={"<<p.first<<", "<<p.second<<"}\n";}
#define pb push_back
#define all(x) x.begin(), x.end()

const int inf=1000001000;
const int MAXN=100010, K=103;

int n, m, k;
pii A[MAXN];
ll dp[505][505];

inline ll _sq(ll x){ return x*x;}

ll take_photos(int _n, int _m, int _k, vector<int> r, vector<int> c) {
	k=_k;
	m=_m;
	vector<pii> vec;
	for (int i=0; i<_n; i++) vec.pb({min(r[i], c[i]), max(r[i], c[i])});
	sort(all(vec), [](pii i, pii j){
		if (i.second!=j.second) return i.second<j.second;
		return i.first>j.first;
	});
	for (pii p:vec){
		while (n && p.first<=A[n].first) n--;
		A[++n]=p;
	}
	for (int i=1; i<=n; i++) debugp(A[i])
	k=min(k, n);
	memset(dp, 63, sizeof(dp));
	for (int i=0; i<=k; i++) dp[0][i]=0;
	for (int i=1; i<=n; i++){
		for (int j=1; j<=i; j++){
			ll cost=_sq(A[i].second-A[j].first+1);
			if (j!=1 && A[j].first<=A[j-1].second) cost-=_sq(A[j-1].second-A[j].first+1);
			// cerr<<i<<" "<<j<<"  "<<cost<<"\n";
			for (int t=1; t<=k; t++)
				dp[i][t]=min(dp[i][t], dp[j-1][t]+cost);
		}
	}
	return dp[n][k];
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2252 KB Correct answer: answer = 4
2 Correct 1 ms 2252 KB Correct answer: answer = 4
3 Correct 2 ms 2252 KB Correct answer: answer = 4
4 Correct 2 ms 2252 KB Correct answer: answer = 12
5 Correct 2 ms 2252 KB Correct answer: answer = 52
6 Correct 2 ms 2252 KB Correct answer: answer = 210
7 Correct 2 ms 2252 KB Correct answer: answer = 88
8 Correct 2 ms 2224 KB Correct answer: answer = 7696
9 Correct 2 ms 2252 KB Correct answer: answer = 1
10 Correct 2 ms 2224 KB Correct answer: answer = 2374
11 Correct 2 ms 2252 KB Correct answer: answer = 9502
12 Correct 2 ms 2252 KB Correct answer: answer = 49
13 Correct 2 ms 2252 KB Correct answer: answer = 151
14 Correct 2 ms 2252 KB Correct answer: answer = 7550
15 Correct 2 ms 2252 KB Correct answer: answer = 7220
16 Correct 2 ms 2252 KB Correct answer: answer = 7550
17 Correct 2 ms 2252 KB Correct answer: answer = 10000
18 Correct 2 ms 2252 KB Correct answer: answer = 10000
19 Correct 2 ms 2252 KB Correct answer: answer = 624
20 Correct 2 ms 2252 KB Correct answer: answer = 10000
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2244 KB Correct answer: answer = 1
2 Incorrect 2 ms 2256 KB Wrong answer: output = 2, expected = 4
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2252 KB Correct answer: answer = 4
2 Correct 1 ms 2252 KB Correct answer: answer = 4
3 Correct 2 ms 2252 KB Correct answer: answer = 4
4 Correct 2 ms 2252 KB Correct answer: answer = 12
5 Correct 2 ms 2252 KB Correct answer: answer = 52
6 Correct 2 ms 2252 KB Correct answer: answer = 210
7 Correct 2 ms 2252 KB Correct answer: answer = 88
8 Correct 2 ms 2224 KB Correct answer: answer = 7696
9 Correct 2 ms 2252 KB Correct answer: answer = 1
10 Correct 2 ms 2224 KB Correct answer: answer = 2374
11 Correct 2 ms 2252 KB Correct answer: answer = 9502
12 Correct 2 ms 2252 KB Correct answer: answer = 49
13 Correct 2 ms 2252 KB Correct answer: answer = 151
14 Correct 2 ms 2252 KB Correct answer: answer = 7550
15 Correct 2 ms 2252 KB Correct answer: answer = 7220
16 Correct 2 ms 2252 KB Correct answer: answer = 7550
17 Correct 2 ms 2252 KB Correct answer: answer = 10000
18 Correct 2 ms 2252 KB Correct answer: answer = 10000
19 Correct 2 ms 2252 KB Correct answer: answer = 624
20 Correct 2 ms 2252 KB Correct answer: answer = 10000
21 Correct 2 ms 2244 KB Correct answer: answer = 1
22 Incorrect 2 ms 2256 KB Wrong answer: output = 2, expected = 4
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2252 KB Correct answer: answer = 4
2 Correct 1 ms 2252 KB Correct answer: answer = 4
3 Correct 2 ms 2252 KB Correct answer: answer = 4
4 Correct 2 ms 2252 KB Correct answer: answer = 12
5 Correct 2 ms 2252 KB Correct answer: answer = 52
6 Correct 2 ms 2252 KB Correct answer: answer = 210
7 Correct 2 ms 2252 KB Correct answer: answer = 88
8 Correct 2 ms 2224 KB Correct answer: answer = 7696
9 Correct 2 ms 2252 KB Correct answer: answer = 1
10 Correct 2 ms 2224 KB Correct answer: answer = 2374
11 Correct 2 ms 2252 KB Correct answer: answer = 9502
12 Correct 2 ms 2252 KB Correct answer: answer = 49
13 Correct 2 ms 2252 KB Correct answer: answer = 151
14 Correct 2 ms 2252 KB Correct answer: answer = 7550
15 Correct 2 ms 2252 KB Correct answer: answer = 7220
16 Correct 2 ms 2252 KB Correct answer: answer = 7550
17 Correct 2 ms 2252 KB Correct answer: answer = 10000
18 Correct 2 ms 2252 KB Correct answer: answer = 10000
19 Correct 2 ms 2252 KB Correct answer: answer = 624
20 Correct 2 ms 2252 KB Correct answer: answer = 10000
21 Correct 2 ms 2244 KB Correct answer: answer = 1
22 Incorrect 2 ms 2256 KB Wrong answer: output = 2, expected = 4
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2252 KB Correct answer: answer = 4
2 Correct 1 ms 2252 KB Correct answer: answer = 4
3 Correct 2 ms 2252 KB Correct answer: answer = 4
4 Correct 2 ms 2252 KB Correct answer: answer = 12
5 Correct 2 ms 2252 KB Correct answer: answer = 52
6 Correct 2 ms 2252 KB Correct answer: answer = 210
7 Correct 2 ms 2252 KB Correct answer: answer = 88
8 Correct 2 ms 2224 KB Correct answer: answer = 7696
9 Correct 2 ms 2252 KB Correct answer: answer = 1
10 Correct 2 ms 2224 KB Correct answer: answer = 2374
11 Correct 2 ms 2252 KB Correct answer: answer = 9502
12 Correct 2 ms 2252 KB Correct answer: answer = 49
13 Correct 2 ms 2252 KB Correct answer: answer = 151
14 Correct 2 ms 2252 KB Correct answer: answer = 7550
15 Correct 2 ms 2252 KB Correct answer: answer = 7220
16 Correct 2 ms 2252 KB Correct answer: answer = 7550
17 Correct 2 ms 2252 KB Correct answer: answer = 10000
18 Correct 2 ms 2252 KB Correct answer: answer = 10000
19 Correct 2 ms 2252 KB Correct answer: answer = 624
20 Correct 2 ms 2252 KB Correct answer: answer = 10000
21 Correct 2 ms 2244 KB Correct answer: answer = 1
22 Incorrect 2 ms 2256 KB Wrong answer: output = 2, expected = 4
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2252 KB Correct answer: answer = 4
2 Correct 1 ms 2252 KB Correct answer: answer = 4
3 Correct 2 ms 2252 KB Correct answer: answer = 4
4 Correct 2 ms 2252 KB Correct answer: answer = 12
5 Correct 2 ms 2252 KB Correct answer: answer = 52
6 Correct 2 ms 2252 KB Correct answer: answer = 210
7 Correct 2 ms 2252 KB Correct answer: answer = 88
8 Correct 2 ms 2224 KB Correct answer: answer = 7696
9 Correct 2 ms 2252 KB Correct answer: answer = 1
10 Correct 2 ms 2224 KB Correct answer: answer = 2374
11 Correct 2 ms 2252 KB Correct answer: answer = 9502
12 Correct 2 ms 2252 KB Correct answer: answer = 49
13 Correct 2 ms 2252 KB Correct answer: answer = 151
14 Correct 2 ms 2252 KB Correct answer: answer = 7550
15 Correct 2 ms 2252 KB Correct answer: answer = 7220
16 Correct 2 ms 2252 KB Correct answer: answer = 7550
17 Correct 2 ms 2252 KB Correct answer: answer = 10000
18 Correct 2 ms 2252 KB Correct answer: answer = 10000
19 Correct 2 ms 2252 KB Correct answer: answer = 624
20 Correct 2 ms 2252 KB Correct answer: answer = 10000
21 Correct 2 ms 2244 KB Correct answer: answer = 1
22 Incorrect 2 ms 2256 KB Wrong answer: output = 2, expected = 4
23 Halted 0 ms 0 KB -