Submission #25232

# Submission time Handle Problem Language Result Execution time Memory
25232 2017-06-21T01:56:31 Z RezwanArefin01 Aliens (IOI16_aliens) C++14
4 / 100
0 ms 2024 KB
#include "aliens.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll solveSubtask1(int n, int m, int k, std::vector<int> r, std::vector<int> c) { 
	bool grid[m][m];
	memset(grid,0, sizeof grid); 
	for(int i=0; i<n; i++) {
		int x = r[i], y = c[i];
		if(y < x) swap(x, y);
		for(int j=x; j <= y; j++) 
			for(int k = x; k <= y; k++) 
				grid[j][k] = 1;
	} 
	int ans = 0;
	for(int i=0; i<m; i++) 
		for(int j=0; j<m; j++) 
			ans += grid[i][j];
	return ans;
}
#define sq(a) ((a) * (a))
ll solveSubtask2(int n, int m, int kk, std::vector<int> r, std::vector<int> c) { 
	sort(r.begin(), r.end());
	r.erase(unique(r.begin(), r.end()), r.end());  
	ll dp[kk+1][n+1];
	memset(dp, 0x3f, sizeof dp);
	for(int i=1; i <= n; i++) {
		dp[1][i] = sq(r[i-1] - r[0] + 1); 
	}  
	for(int k=2; k <= kk; k++) {
		for(int i=k; i<=n; i++) {
			for(int j=0; j < i; j++) {
				dp[k][i] = min(dp[k][i], dp[k-1][j] + sq(r[i-1] - r[j] + 1)); 
			}
		}
	} 
	ll Min = 1e18;
	for(int k = 1; k <= kk; k++) 
		Min = min(Min, dp[k][n]);
	return dp[kk][n];
}

ll take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c) { 
	if(n <= 50 && m <= 100 && n == k) return solveSubtask1(n, m, k, r, c); 
	bool f = 0;
	for(int i=0; i<n; i++) 
		if(r[i] != c[i]) { f = 1; break; }
	if(!f) return solveSubtask2(n, m, k, r, c); 
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2024 KB Correct answer: answer = 4
2 Correct 0 ms 2024 KB Correct answer: answer = 4
3 Correct 0 ms 2024 KB Correct answer: answer = 4
4 Correct 0 ms 2024 KB Correct answer: answer = 12
5 Correct 0 ms 2024 KB Correct answer: answer = 52
6 Correct 0 ms 2024 KB Correct answer: answer = 210
7 Correct 0 ms 2024 KB Correct answer: answer = 88
8 Correct 0 ms 2024 KB Correct answer: answer = 7696
9 Correct 0 ms 2024 KB Correct answer: answer = 1
10 Correct 0 ms 2024 KB Correct answer: answer = 2374
11 Correct 0 ms 2024 KB Correct answer: answer = 9502
12 Correct 0 ms 2024 KB Correct answer: answer = 49
13 Correct 0 ms 2024 KB Correct answer: answer = 151
14 Correct 0 ms 2024 KB Correct answer: answer = 7550
15 Correct 0 ms 2024 KB Correct answer: answer = 7220
16 Correct 0 ms 2024 KB Correct answer: answer = 7550
17 Correct 0 ms 2024 KB Correct answer: answer = 10000
18 Correct 0 ms 2024 KB Correct answer: answer = 10000
19 Correct 0 ms 2024 KB Correct answer: answer = 624
20 Correct 0 ms 2024 KB Correct answer: answer = 10000
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2024 KB Correct answer: answer = 1
2 Correct 0 ms 2024 KB Correct answer: answer = 4
3 Incorrect 0 ms 2024 KB Wrong answer: output = 2, expected = 1
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2024 KB Correct answer: answer = 4
2 Correct 0 ms 2024 KB Correct answer: answer = 4
3 Correct 0 ms 2024 KB Correct answer: answer = 4
4 Correct 0 ms 2024 KB Correct answer: answer = 12
5 Correct 0 ms 2024 KB Correct answer: answer = 52
6 Correct 0 ms 2024 KB Correct answer: answer = 210
7 Correct 0 ms 2024 KB Correct answer: answer = 88
8 Correct 0 ms 2024 KB Correct answer: answer = 7696
9 Correct 0 ms 2024 KB Correct answer: answer = 1
10 Correct 0 ms 2024 KB Correct answer: answer = 2374
11 Correct 0 ms 2024 KB Correct answer: answer = 9502
12 Correct 0 ms 2024 KB Correct answer: answer = 49
13 Correct 0 ms 2024 KB Correct answer: answer = 151
14 Correct 0 ms 2024 KB Correct answer: answer = 7550
15 Correct 0 ms 2024 KB Correct answer: answer = 7220
16 Correct 0 ms 2024 KB Correct answer: answer = 7550
17 Correct 0 ms 2024 KB Correct answer: answer = 10000
18 Correct 0 ms 2024 KB Correct answer: answer = 10000
19 Correct 0 ms 2024 KB Correct answer: answer = 624
20 Correct 0 ms 2024 KB Correct answer: answer = 10000
21 Correct 0 ms 2024 KB Correct answer: answer = 1
22 Correct 0 ms 2024 KB Correct answer: answer = 4
23 Incorrect 0 ms 2024 KB Wrong answer: output = 2, expected = 1
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2024 KB Correct answer: answer = 4
2 Correct 0 ms 2024 KB Correct answer: answer = 4
3 Correct 0 ms 2024 KB Correct answer: answer = 4
4 Correct 0 ms 2024 KB Correct answer: answer = 12
5 Correct 0 ms 2024 KB Correct answer: answer = 52
6 Correct 0 ms 2024 KB Correct answer: answer = 210
7 Correct 0 ms 2024 KB Correct answer: answer = 88
8 Correct 0 ms 2024 KB Correct answer: answer = 7696
9 Correct 0 ms 2024 KB Correct answer: answer = 1
10 Correct 0 ms 2024 KB Correct answer: answer = 2374
11 Correct 0 ms 2024 KB Correct answer: answer = 9502
12 Correct 0 ms 2024 KB Correct answer: answer = 49
13 Correct 0 ms 2024 KB Correct answer: answer = 151
14 Correct 0 ms 2024 KB Correct answer: answer = 7550
15 Correct 0 ms 2024 KB Correct answer: answer = 7220
16 Correct 0 ms 2024 KB Correct answer: answer = 7550
17 Correct 0 ms 2024 KB Correct answer: answer = 10000
18 Correct 0 ms 2024 KB Correct answer: answer = 10000
19 Correct 0 ms 2024 KB Correct answer: answer = 624
20 Correct 0 ms 2024 KB Correct answer: answer = 10000
21 Correct 0 ms 2024 KB Correct answer: answer = 1
22 Correct 0 ms 2024 KB Correct answer: answer = 4
23 Incorrect 0 ms 2024 KB Wrong answer: output = 2, expected = 1
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2024 KB Correct answer: answer = 4
2 Correct 0 ms 2024 KB Correct answer: answer = 4
3 Correct 0 ms 2024 KB Correct answer: answer = 4
4 Correct 0 ms 2024 KB Correct answer: answer = 12
5 Correct 0 ms 2024 KB Correct answer: answer = 52
6 Correct 0 ms 2024 KB Correct answer: answer = 210
7 Correct 0 ms 2024 KB Correct answer: answer = 88
8 Correct 0 ms 2024 KB Correct answer: answer = 7696
9 Correct 0 ms 2024 KB Correct answer: answer = 1
10 Correct 0 ms 2024 KB Correct answer: answer = 2374
11 Correct 0 ms 2024 KB Correct answer: answer = 9502
12 Correct 0 ms 2024 KB Correct answer: answer = 49
13 Correct 0 ms 2024 KB Correct answer: answer = 151
14 Correct 0 ms 2024 KB Correct answer: answer = 7550
15 Correct 0 ms 2024 KB Correct answer: answer = 7220
16 Correct 0 ms 2024 KB Correct answer: answer = 7550
17 Correct 0 ms 2024 KB Correct answer: answer = 10000
18 Correct 0 ms 2024 KB Correct answer: answer = 10000
19 Correct 0 ms 2024 KB Correct answer: answer = 624
20 Correct 0 ms 2024 KB Correct answer: answer = 10000
21 Correct 0 ms 2024 KB Correct answer: answer = 1
22 Correct 0 ms 2024 KB Correct answer: answer = 4
23 Incorrect 0 ms 2024 KB Wrong answer: output = 2, expected = 1
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2024 KB Correct answer: answer = 4
2 Correct 0 ms 2024 KB Correct answer: answer = 4
3 Correct 0 ms 2024 KB Correct answer: answer = 4
4 Correct 0 ms 2024 KB Correct answer: answer = 12
5 Correct 0 ms 2024 KB Correct answer: answer = 52
6 Correct 0 ms 2024 KB Correct answer: answer = 210
7 Correct 0 ms 2024 KB Correct answer: answer = 88
8 Correct 0 ms 2024 KB Correct answer: answer = 7696
9 Correct 0 ms 2024 KB Correct answer: answer = 1
10 Correct 0 ms 2024 KB Correct answer: answer = 2374
11 Correct 0 ms 2024 KB Correct answer: answer = 9502
12 Correct 0 ms 2024 KB Correct answer: answer = 49
13 Correct 0 ms 2024 KB Correct answer: answer = 151
14 Correct 0 ms 2024 KB Correct answer: answer = 7550
15 Correct 0 ms 2024 KB Correct answer: answer = 7220
16 Correct 0 ms 2024 KB Correct answer: answer = 7550
17 Correct 0 ms 2024 KB Correct answer: answer = 10000
18 Correct 0 ms 2024 KB Correct answer: answer = 10000
19 Correct 0 ms 2024 KB Correct answer: answer = 624
20 Correct 0 ms 2024 KB Correct answer: answer = 10000
21 Correct 0 ms 2024 KB Correct answer: answer = 1
22 Correct 0 ms 2024 KB Correct answer: answer = 4
23 Incorrect 0 ms 2024 KB Wrong answer: output = 2, expected = 1
24 Halted 0 ms 0 KB -