Submission #25230

# Submission time Handle Problem Language Result Execution time Memory
25230 2017-06-21T01:52:13 Z RezwanArefin01 Aliens (IOI16_aliens) C++14
16 / 100
133 ms 3860 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 Min;
}

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 Correct 0 ms 2024 KB Correct answer: answer = 1
4 Correct 0 ms 2024 KB Correct answer: answer = 5
5 Correct 0 ms 2024 KB Correct answer: answer = 41
6 Correct 0 ms 2024 KB Correct answer: answer = 71923
7 Correct 0 ms 2024 KB Correct answer: answer = 77137
8 Correct 89 ms 2884 KB Correct answer: answer = 764
9 Correct 0 ms 2024 KB Correct answer: answer = 250000
10 Correct 133 ms 3860 KB Correct answer: answer = 500
11 Correct 0 ms 2024 KB Correct answer: answer = 32
12 Correct 0 ms 2024 KB Correct answer: answer = 130050
13 Correct 16 ms 2096 KB Correct answer: answer = 5110
14 Correct 0 ms 2024 KB Correct answer: answer = 2626
15 Correct 6 ms 2072 KB Correct answer: answer = 796
16 Correct 13 ms 2028 KB Correct answer: answer = 7580
17 Correct 49 ms 2424 KB Correct answer: answer = 1904
18 Correct 0 ms 2024 KB Correct answer: answer = 996004
19 Correct 6 ms 2024 KB Correct answer: answer = 38817
20 Correct 39 ms 2292 KB Correct answer: answer = 4096
21 Correct 0 ms 2024 KB Correct answer: answer = 1
22 Correct 133 ms 3860 KB Correct answer: answer = 1
23 Correct 46 ms 2384 KB Correct answer: answer = 2040
24 Correct 133 ms 3860 KB Correct answer: answer = 2
# 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 Correct 0 ms 2024 KB Correct answer: answer = 1
24 Correct 0 ms 2024 KB Correct answer: answer = 5
25 Correct 0 ms 2024 KB Correct answer: answer = 41
26 Correct 0 ms 2024 KB Correct answer: answer = 71923
27 Correct 0 ms 2024 KB Correct answer: answer = 77137
28 Correct 89 ms 2884 KB Correct answer: answer = 764
29 Correct 0 ms 2024 KB Correct answer: answer = 250000
30 Correct 133 ms 3860 KB Correct answer: answer = 500
31 Correct 0 ms 2024 KB Correct answer: answer = 32
32 Correct 0 ms 2024 KB Correct answer: answer = 130050
33 Correct 16 ms 2096 KB Correct answer: answer = 5110
34 Correct 0 ms 2024 KB Correct answer: answer = 2626
35 Correct 6 ms 2072 KB Correct answer: answer = 796
36 Correct 13 ms 2028 KB Correct answer: answer = 7580
37 Correct 49 ms 2424 KB Correct answer: answer = 1904
38 Correct 0 ms 2024 KB Correct answer: answer = 996004
39 Correct 6 ms 2024 KB Correct answer: answer = 38817
40 Correct 39 ms 2292 KB Correct answer: answer = 4096
41 Correct 0 ms 2024 KB Correct answer: answer = 1
42 Correct 133 ms 3860 KB Correct answer: answer = 1
43 Correct 46 ms 2384 KB Correct answer: answer = 2040
44 Correct 133 ms 3860 KB Correct answer: answer = 2
45 Incorrect 0 ms 2024 KB Wrong answer: output = 0, expected = 4
46 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 Correct 0 ms 2024 KB Correct answer: answer = 1
24 Correct 0 ms 2024 KB Correct answer: answer = 5
25 Correct 0 ms 2024 KB Correct answer: answer = 41
26 Correct 0 ms 2024 KB Correct answer: answer = 71923
27 Correct 0 ms 2024 KB Correct answer: answer = 77137
28 Correct 89 ms 2884 KB Correct answer: answer = 764
29 Correct 0 ms 2024 KB Correct answer: answer = 250000
30 Correct 133 ms 3860 KB Correct answer: answer = 500
31 Correct 0 ms 2024 KB Correct answer: answer = 32
32 Correct 0 ms 2024 KB Correct answer: answer = 130050
33 Correct 16 ms 2096 KB Correct answer: answer = 5110
34 Correct 0 ms 2024 KB Correct answer: answer = 2626
35 Correct 6 ms 2072 KB Correct answer: answer = 796
36 Correct 13 ms 2028 KB Correct answer: answer = 7580
37 Correct 49 ms 2424 KB Correct answer: answer = 1904
38 Correct 0 ms 2024 KB Correct answer: answer = 996004
39 Correct 6 ms 2024 KB Correct answer: answer = 38817
40 Correct 39 ms 2292 KB Correct answer: answer = 4096
41 Correct 0 ms 2024 KB Correct answer: answer = 1
42 Correct 133 ms 3860 KB Correct answer: answer = 1
43 Correct 46 ms 2384 KB Correct answer: answer = 2040
44 Correct 133 ms 3860 KB Correct answer: answer = 2
45 Incorrect 0 ms 2024 KB Wrong answer: output = 0, expected = 4
46 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 Correct 0 ms 2024 KB Correct answer: answer = 1
24 Correct 0 ms 2024 KB Correct answer: answer = 5
25 Correct 0 ms 2024 KB Correct answer: answer = 41
26 Correct 0 ms 2024 KB Correct answer: answer = 71923
27 Correct 0 ms 2024 KB Correct answer: answer = 77137
28 Correct 89 ms 2884 KB Correct answer: answer = 764
29 Correct 0 ms 2024 KB Correct answer: answer = 250000
30 Correct 133 ms 3860 KB Correct answer: answer = 500
31 Correct 0 ms 2024 KB Correct answer: answer = 32
32 Correct 0 ms 2024 KB Correct answer: answer = 130050
33 Correct 16 ms 2096 KB Correct answer: answer = 5110
34 Correct 0 ms 2024 KB Correct answer: answer = 2626
35 Correct 6 ms 2072 KB Correct answer: answer = 796
36 Correct 13 ms 2028 KB Correct answer: answer = 7580
37 Correct 49 ms 2424 KB Correct answer: answer = 1904
38 Correct 0 ms 2024 KB Correct answer: answer = 996004
39 Correct 6 ms 2024 KB Correct answer: answer = 38817
40 Correct 39 ms 2292 KB Correct answer: answer = 4096
41 Correct 0 ms 2024 KB Correct answer: answer = 1
42 Correct 133 ms 3860 KB Correct answer: answer = 1
43 Correct 46 ms 2384 KB Correct answer: answer = 2040
44 Correct 133 ms 3860 KB Correct answer: answer = 2
45 Incorrect 0 ms 2024 KB Wrong answer: output = 0, expected = 4
46 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 Correct 0 ms 2024 KB Correct answer: answer = 1
24 Correct 0 ms 2024 KB Correct answer: answer = 5
25 Correct 0 ms 2024 KB Correct answer: answer = 41
26 Correct 0 ms 2024 KB Correct answer: answer = 71923
27 Correct 0 ms 2024 KB Correct answer: answer = 77137
28 Correct 89 ms 2884 KB Correct answer: answer = 764
29 Correct 0 ms 2024 KB Correct answer: answer = 250000
30 Correct 133 ms 3860 KB Correct answer: answer = 500
31 Correct 0 ms 2024 KB Correct answer: answer = 32
32 Correct 0 ms 2024 KB Correct answer: answer = 130050
33 Correct 16 ms 2096 KB Correct answer: answer = 5110
34 Correct 0 ms 2024 KB Correct answer: answer = 2626
35 Correct 6 ms 2072 KB Correct answer: answer = 796
36 Correct 13 ms 2028 KB Correct answer: answer = 7580
37 Correct 49 ms 2424 KB Correct answer: answer = 1904
38 Correct 0 ms 2024 KB Correct answer: answer = 996004
39 Correct 6 ms 2024 KB Correct answer: answer = 38817
40 Correct 39 ms 2292 KB Correct answer: answer = 4096
41 Correct 0 ms 2024 KB Correct answer: answer = 1
42 Correct 133 ms 3860 KB Correct answer: answer = 1
43 Correct 46 ms 2384 KB Correct answer: answer = 2040
44 Correct 133 ms 3860 KB Correct answer: answer = 2
45 Incorrect 0 ms 2024 KB Wrong answer: output = 0, expected = 4
46 Halted 0 ms 0 KB -