Submission #45003

# Submission time Handle Problem Language Result Execution time Memory
45003 2018-04-10T14:03:04 Z RezwanArefin01 Bali Sculptures (APIO15_sculpture) C++14
37 / 100
43 ms 1048 KB
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii; 

int n, A, B, a[2001]; ll C[2001][2001]; 
bool dp[110][110]; 

int main(int argc, char const *argv[]) {
#ifdef LOCAL_TESTING
	freopen("in", "r", stdin);
#endif
	scanf("%d %d %d", &n, &A, &B); 
	for(int i = 1; i <= n; i++) 
		scanf("%d", &a[i]); 

	for(int i = 1; i <= n; i++) {
		C[i][i] = a[i];
		for(int j = i + 1; j <= n; j++) 
			C[i][j] = C[i][j - 1] + a[j]; 
	}

	if(A == 0) {
		// todo
	} else {
		ll mask = (1ll << 36) - 1; 
		#define nyc(a, b) ((a & b) == a)
		for(int b = 35; b >= 0; b--) {
			mask ^= 1ll << b; 
			for(int i = 1; i <= n; i++) 
				dp[1][i] = nyc(C[1][i], mask);
			for(int k = 2; k <= B; k++) {
				for(int i = 1; i <= n; i++) { dp[k][i] = 0;
					for(int j = 1; j < i; j++) 
						dp[k][i] |= (dp[k - 1][j] & nyc(C[j + 1][i], mask));  
				}
			} 
			bool f = 0;
			for(int i = A; i <= B; i++) if(dp[i][n]) f = 1; 
			if(!f) mask ^= 1 << b;
		} printf("%d\n", mask);
	}

}

Compilation message

sculpture.cpp: In function 'int main(int, const char**)':
sculpture.cpp:45:24: warning: format '%d' expects argument of type 'int', but argument 2 has type 'll {aka long long int}' [-Wformat=]
   } printf("%d\n", mask);
                        ^
sculpture.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &n, &A, &B); 
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]); 
   ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 480 KB Output is correct
5 Correct 2 ms 520 KB Output is correct
6 Correct 2 ms 720 KB Output is correct
7 Correct 2 ms 720 KB Output is correct
8 Correct 2 ms 720 KB Output is correct
9 Correct 2 ms 720 KB Output is correct
10 Correct 2 ms 720 KB Output is correct
11 Correct 2 ms 720 KB Output is correct
12 Correct 2 ms 720 KB Output is correct
13 Correct 2 ms 720 KB Output is correct
14 Correct 2 ms 720 KB Output is correct
15 Correct 2 ms 720 KB Output is correct
16 Correct 2 ms 720 KB Output is correct
17 Correct 2 ms 720 KB Output is correct
18 Correct 2 ms 720 KB Output is correct
19 Correct 2 ms 720 KB Output is correct
20 Correct 2 ms 720 KB Output is correct
21 Correct 3 ms 720 KB Output is correct
22 Correct 2 ms 720 KB Output is correct
23 Correct 2 ms 740 KB Output is correct
24 Correct 2 ms 740 KB Output is correct
25 Correct 2 ms 740 KB Output is correct
26 Correct 2 ms 740 KB Output is correct
27 Correct 2 ms 740 KB Output is correct
28 Correct 2 ms 740 KB Output is correct
29 Correct 2 ms 740 KB Output is correct
30 Incorrect 2 ms 740 KB Output isn't correct
31 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 740 KB Output is correct
2 Correct 2 ms 740 KB Output is correct
3 Correct 2 ms 740 KB Output is correct
4 Correct 2 ms 740 KB Output is correct
5 Correct 2 ms 740 KB Output is correct
6 Correct 2 ms 740 KB Output is correct
7 Correct 2 ms 740 KB Output is correct
8 Correct 2 ms 740 KB Output is correct
9 Correct 2 ms 740 KB Output is correct
10 Correct 2 ms 740 KB Output is correct
11 Correct 2 ms 740 KB Output is correct
12 Correct 2 ms 740 KB Output is correct
13 Correct 2 ms 740 KB Output is correct
14 Correct 2 ms 740 KB Output is correct
15 Correct 2 ms 740 KB Output is correct
16 Correct 2 ms 740 KB Output is correct
17 Correct 2 ms 740 KB Output is correct
18 Correct 2 ms 740 KB Output is correct
19 Correct 2 ms 740 KB Output is correct
20 Correct 2 ms 740 KB Output is correct
21 Correct 2 ms 740 KB Output is correct
22 Correct 2 ms 740 KB Output is correct
23 Correct 2 ms 740 KB Output is correct
24 Correct 2 ms 740 KB Output is correct
25 Correct 2 ms 740 KB Output is correct
26 Correct 2 ms 740 KB Output is correct
27 Correct 3 ms 740 KB Output is correct
28 Correct 2 ms 740 KB Output is correct
29 Correct 3 ms 904 KB Output is correct
30 Correct 4 ms 904 KB Output is correct
31 Correct 3 ms 904 KB Output is correct
32 Correct 4 ms 904 KB Output is correct
33 Correct 3 ms 904 KB Output is correct
34 Correct 3 ms 904 KB Output is correct
35 Correct 3 ms 904 KB Output is correct
36 Correct 2 ms 904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 904 KB Output is correct
2 Correct 2 ms 904 KB Output is correct
3 Correct 2 ms 904 KB Output is correct
4 Correct 3 ms 904 KB Output is correct
5 Correct 2 ms 904 KB Output is correct
6 Correct 3 ms 904 KB Output is correct
7 Correct 2 ms 904 KB Output is correct
8 Correct 2 ms 904 KB Output is correct
9 Correct 2 ms 904 KB Output is correct
10 Correct 2 ms 904 KB Output is correct
11 Correct 2 ms 904 KB Output is correct
12 Correct 2 ms 904 KB Output is correct
13 Correct 2 ms 904 KB Output is correct
14 Correct 2 ms 904 KB Output is correct
15 Correct 2 ms 904 KB Output is correct
16 Correct 3 ms 904 KB Output is correct
17 Correct 3 ms 904 KB Output is correct
18 Correct 5 ms 904 KB Output is correct
19 Correct 3 ms 904 KB Output is correct
20 Correct 2 ms 904 KB Output is correct
21 Correct 3 ms 904 KB Output is correct
22 Correct 3 ms 904 KB Output is correct
23 Correct 3 ms 904 KB Output is correct
24 Correct 3 ms 904 KB Output is correct
25 Correct 3 ms 904 KB Output is correct
26 Correct 8 ms 904 KB Output is correct
27 Correct 13 ms 1024 KB Output is correct
28 Correct 43 ms 1024 KB Output is correct
29 Correct 31 ms 1048 KB Output is correct
30 Correct 2 ms 1048 KB Output is correct
31 Correct 12 ms 1048 KB Output is correct
32 Correct 18 ms 1048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1048 KB Output is correct
2 Correct 2 ms 1048 KB Output is correct
3 Correct 2 ms 1048 KB Output is correct
4 Correct 2 ms 1048 KB Output is correct
5 Correct 2 ms 1048 KB Output is correct
6 Correct 2 ms 1048 KB Output is correct
7 Correct 2 ms 1048 KB Output is correct
8 Correct 2 ms 1048 KB Output is correct
9 Correct 2 ms 1048 KB Output is correct
10 Correct 2 ms 1048 KB Output is correct
11 Correct 2 ms 1048 KB Output is correct
12 Correct 2 ms 1048 KB Output is correct
13 Correct 3 ms 1048 KB Output is correct
14 Correct 2 ms 1048 KB Output is correct
15 Correct 2 ms 1048 KB Output is correct
16 Correct 2 ms 1048 KB Output is correct
17 Correct 2 ms 1048 KB Output is correct
18 Correct 2 ms 1048 KB Output is correct
19 Correct 2 ms 1048 KB Output is correct
20 Correct 2 ms 1048 KB Output is correct
21 Correct 2 ms 1048 KB Output is correct
22 Correct 3 ms 1048 KB Output is correct
23 Correct 2 ms 1048 KB Output is correct
24 Correct 2 ms 1048 KB Output is correct
25 Correct 2 ms 1048 KB Output is correct
26 Correct 2 ms 1048 KB Output is correct
27 Correct 2 ms 1048 KB Output is correct
28 Correct 2 ms 1048 KB Output is correct
29 Correct 2 ms 1048 KB Output is correct
30 Incorrect 2 ms 1048 KB Output isn't correct
31 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1048 KB Output is correct
2 Correct 2 ms 1048 KB Output is correct
3 Correct 2 ms 1048 KB Output is correct
4 Correct 2 ms 1048 KB Output is correct
5 Correct 2 ms 1048 KB Output is correct
6 Correct 2 ms 1048 KB Output is correct
7 Correct 2 ms 1048 KB Output is correct
8 Correct 2 ms 1048 KB Output is correct
9 Correct 2 ms 1048 KB Output is correct
10 Correct 2 ms 1048 KB Output is correct
11 Correct 2 ms 1048 KB Output is correct
12 Correct 2 ms 1048 KB Output is correct
13 Correct 2 ms 1048 KB Output is correct
14 Correct 2 ms 1048 KB Output is correct
15 Correct 2 ms 1048 KB Output is correct
16 Correct 2 ms 1048 KB Output is correct
17 Incorrect 2 ms 1048 KB Output isn't correct
18 Halted 0 ms 0 KB -