답안 #45005

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
45005 2018-04-10T14:11:15 Z RezwanArefin01 Bali Sculptures (APIO15_sculpture) C++17
100 / 100
632 ms 23420 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], f[2010]; ll C[2001][2001]; 
bool dp[110][110];

int main(int argc, char const *argv[]) {
	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]; 
	}

	ll mask = (1ll << 42) - 1; 
	#define nyc(a, b) ((a & b) == a)
	if(A == 1) {
		for(int b = 41; b >= 0; b--) {
			mask ^= 1ll << b; 
			f[0] = 0;
			for(int i = 1; i <= n; i++) { f[i] = B + 1; 
				for(int j = 1; j <= i; j++) 
					if(nyc(C[j][i], mask)) 
						f[i] = min(f[i], f[j - 1] + 1);
			}
			if(f[n] > B) mask ^= 1ll << b;
		}
	} else {
		for(int b = 41; 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 ^= 1ll << b;
		}
	}  printf("%lld\n", mask);
}

Compilation message

sculpture.cpp: In function 'int main(int, const char**)':
sculpture.cpp:14: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:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]); 
   ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 428 KB Output is correct
4 Correct 2 ms 540 KB Output is correct
5 Correct 2 ms 540 KB Output is correct
6 Correct 2 ms 544 KB Output is correct
7 Correct 2 ms 608 KB Output is correct
8 Correct 2 ms 608 KB Output is correct
9 Correct 2 ms 688 KB Output is correct
10 Correct 2 ms 688 KB Output is correct
11 Correct 2 ms 704 KB Output is correct
12 Correct 2 ms 704 KB Output is correct
13 Correct 2 ms 704 KB Output is correct
14 Correct 2 ms 704 KB Output is correct
15 Correct 2 ms 704 KB Output is correct
16 Correct 2 ms 704 KB Output is correct
17 Correct 2 ms 704 KB Output is correct
18 Correct 2 ms 704 KB Output is correct
19 Correct 2 ms 728 KB Output is correct
20 Correct 2 ms 728 KB Output is correct
21 Correct 2 ms 728 KB Output is correct
22 Correct 3 ms 728 KB Output is correct
23 Correct 2 ms 728 KB Output is correct
24 Correct 2 ms 728 KB Output is correct
25 Correct 3 ms 728 KB Output is correct
26 Correct 3 ms 728 KB Output is correct
27 Correct 2 ms 728 KB Output is correct
28 Correct 2 ms 728 KB Output is correct
29 Correct 2 ms 728 KB Output is correct
30 Correct 2 ms 728 KB Output is correct
31 Correct 2 ms 728 KB Output is correct
32 Correct 2 ms 728 KB Output is correct
33 Correct 2 ms 728 KB Output is correct
34 Correct 2 ms 728 KB Output is correct
35 Correct 2 ms 728 KB Output is correct
36 Correct 2 ms 728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 728 KB Output is correct
2 Correct 2 ms 728 KB Output is correct
3 Correct 2 ms 728 KB Output is correct
4 Correct 3 ms 728 KB Output is correct
5 Correct 2 ms 728 KB Output is correct
6 Correct 2 ms 728 KB Output is correct
7 Correct 2 ms 728 KB Output is correct
8 Correct 2 ms 728 KB Output is correct
9 Correct 2 ms 728 KB Output is correct
10 Correct 2 ms 728 KB Output is correct
11 Correct 2 ms 728 KB Output is correct
12 Correct 2 ms 728 KB Output is correct
13 Correct 2 ms 728 KB Output is correct
14 Correct 2 ms 728 KB Output is correct
15 Correct 2 ms 728 KB Output is correct
16 Correct 2 ms 728 KB Output is correct
17 Correct 2 ms 728 KB Output is correct
18 Correct 2 ms 728 KB Output is correct
19 Correct 2 ms 728 KB Output is correct
20 Correct 2 ms 728 KB Output is correct
21 Correct 2 ms 728 KB Output is correct
22 Correct 2 ms 728 KB Output is correct
23 Correct 2 ms 728 KB Output is correct
24 Correct 2 ms 728 KB Output is correct
25 Correct 2 ms 728 KB Output is correct
26 Correct 3 ms 728 KB Output is correct
27 Correct 2 ms 728 KB Output is correct
28 Correct 2 ms 728 KB Output is correct
29 Correct 2 ms 764 KB Output is correct
30 Correct 2 ms 764 KB Output is correct
31 Correct 3 ms 764 KB Output is correct
32 Correct 2 ms 800 KB Output is correct
33 Correct 2 ms 836 KB Output is correct
34 Correct 2 ms 836 KB Output is correct
35 Correct 2 ms 836 KB Output is correct
36 Correct 3 ms 836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 836 KB Output is correct
2 Correct 2 ms 836 KB Output is correct
3 Correct 2 ms 836 KB Output is correct
4 Correct 2 ms 836 KB Output is correct
5 Correct 2 ms 836 KB Output is correct
6 Correct 2 ms 836 KB Output is correct
7 Correct 2 ms 836 KB Output is correct
8 Correct 2 ms 836 KB Output is correct
9 Correct 2 ms 836 KB Output is correct
10 Correct 3 ms 836 KB Output is correct
11 Correct 2 ms 836 KB Output is correct
12 Correct 2 ms 836 KB Output is correct
13 Correct 2 ms 836 KB Output is correct
14 Correct 2 ms 836 KB Output is correct
15 Correct 2 ms 836 KB Output is correct
16 Correct 2 ms 836 KB Output is correct
17 Correct 3 ms 836 KB Output is correct
18 Correct 3 ms 836 KB Output is correct
19 Correct 3 ms 836 KB Output is correct
20 Correct 2 ms 836 KB Output is correct
21 Correct 3 ms 836 KB Output is correct
22 Correct 3 ms 836 KB Output is correct
23 Correct 3 ms 836 KB Output is correct
24 Correct 2 ms 836 KB Output is correct
25 Correct 3 ms 892 KB Output is correct
26 Correct 2 ms 892 KB Output is correct
27 Correct 3 ms 1020 KB Output is correct
28 Correct 3 ms 1020 KB Output is correct
29 Correct 3 ms 1020 KB Output is correct
30 Correct 3 ms 1020 KB Output is correct
31 Correct 3 ms 1020 KB Output is correct
32 Correct 4 ms 1024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1024 KB Output is correct
2 Correct 2 ms 1024 KB Output is correct
3 Correct 2 ms 1024 KB Output is correct
4 Correct 2 ms 1024 KB Output is correct
5 Correct 2 ms 1024 KB Output is correct
6 Correct 2 ms 1024 KB Output is correct
7 Correct 2 ms 1024 KB Output is correct
8 Correct 2 ms 1024 KB Output is correct
9 Correct 2 ms 1024 KB Output is correct
10 Correct 2 ms 1024 KB Output is correct
11 Correct 2 ms 1024 KB Output is correct
12 Correct 2 ms 1024 KB Output is correct
13 Correct 2 ms 1024 KB Output is correct
14 Correct 2 ms 1024 KB Output is correct
15 Correct 2 ms 1024 KB Output is correct
16 Correct 2 ms 1024 KB Output is correct
17 Correct 2 ms 1024 KB Output is correct
18 Correct 2 ms 1024 KB Output is correct
19 Correct 2 ms 1024 KB Output is correct
20 Correct 2 ms 1024 KB Output is correct
21 Correct 2 ms 1024 KB Output is correct
22 Correct 2 ms 1024 KB Output is correct
23 Correct 2 ms 1024 KB Output is correct
24 Correct 2 ms 1024 KB Output is correct
25 Correct 2 ms 1024 KB Output is correct
26 Correct 2 ms 1024 KB Output is correct
27 Correct 2 ms 1024 KB Output is correct
28 Correct 2 ms 1024 KB Output is correct
29 Correct 2 ms 1024 KB Output is correct
30 Correct 2 ms 1024 KB Output is correct
31 Correct 2 ms 1024 KB Output is correct
32 Correct 2 ms 1024 KB Output is correct
33 Correct 2 ms 1024 KB Output is correct
34 Correct 3 ms 1024 KB Output is correct
35 Correct 2 ms 1024 KB Output is correct
36 Correct 3 ms 1024 KB Output is correct
37 Correct 2 ms 1024 KB Output is correct
38 Correct 2 ms 1024 KB Output is correct
39 Correct 3 ms 1024 KB Output is correct
40 Correct 3 ms 1024 KB Output is correct
41 Correct 3 ms 1024 KB Output is correct
42 Correct 2 ms 1024 KB Output is correct
43 Correct 2 ms 1024 KB Output is correct
44 Correct 2 ms 1024 KB Output is correct
45 Correct 2 ms 1024 KB Output is correct
46 Correct 2 ms 1024 KB Output is correct
47 Correct 2 ms 1024 KB Output is correct
48 Correct 2 ms 1024 KB Output is correct
49 Correct 3 ms 1024 KB Output is correct
50 Correct 3 ms 1064 KB Output is correct
51 Correct 3 ms 1064 KB Output is correct
52 Correct 3 ms 1064 KB Output is correct
53 Correct 3 ms 1080 KB Output is correct
54 Correct 3 ms 1140 KB Output is correct
55 Correct 3 ms 1140 KB Output is correct
56 Correct 2 ms 1140 KB Output is correct
57 Correct 2 ms 1140 KB Output is correct
58 Correct 3 ms 1140 KB Output is correct
59 Correct 3 ms 1140 KB Output is correct
60 Correct 2 ms 1140 KB Output is correct
61 Correct 2 ms 1140 KB Output is correct
62 Correct 3 ms 1140 KB Output is correct
63 Correct 3 ms 1140 KB Output is correct
64 Correct 24 ms 1140 KB Output is correct
65 Correct 4 ms 1140 KB Output is correct
66 Correct 4 ms 1140 KB Output is correct
67 Correct 5 ms 1140 KB Output is correct
68 Correct 14 ms 1140 KB Output is correct
69 Correct 32 ms 1140 KB Output is correct
70 Correct 47 ms 1140 KB Output is correct
71 Correct 3 ms 1140 KB Output is correct
72 Correct 28 ms 1140 KB Output is correct
73 Correct 23 ms 1140 KB Output is correct
74 Correct 19 ms 1140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1140 KB Output is correct
2 Correct 2 ms 1140 KB Output is correct
3 Correct 2 ms 1140 KB Output is correct
4 Correct 2 ms 1140 KB Output is correct
5 Correct 2 ms 1140 KB Output is correct
6 Correct 2 ms 1140 KB Output is correct
7 Correct 2 ms 1140 KB Output is correct
8 Correct 2 ms 1140 KB Output is correct
9 Correct 2 ms 1140 KB Output is correct
10 Correct 2 ms 1140 KB Output is correct
11 Correct 3 ms 1140 KB Output is correct
12 Correct 2 ms 1140 KB Output is correct
13 Correct 2 ms 1140 KB Output is correct
14 Correct 2 ms 1140 KB Output is correct
15 Correct 2 ms 1140 KB Output is correct
16 Correct 2 ms 1140 KB Output is correct
17 Correct 3 ms 1140 KB Output is correct
18 Correct 2 ms 1140 KB Output is correct
19 Correct 2 ms 1140 KB Output is correct
20 Correct 2 ms 1140 KB Output is correct
21 Correct 2 ms 1140 KB Output is correct
22 Correct 2 ms 1140 KB Output is correct
23 Correct 2 ms 1140 KB Output is correct
24 Correct 3 ms 1140 KB Output is correct
25 Correct 2 ms 1140 KB Output is correct
26 Correct 2 ms 1140 KB Output is correct
27 Correct 2 ms 1140 KB Output is correct
28 Correct 3 ms 1140 KB Output is correct
29 Correct 3 ms 1140 KB Output is correct
30 Correct 2 ms 1140 KB Output is correct
31 Correct 2 ms 1140 KB Output is correct
32 Correct 2 ms 1140 KB Output is correct
33 Correct 2 ms 1140 KB Output is correct
34 Correct 2 ms 1140 KB Output is correct
35 Correct 2 ms 1140 KB Output is correct
36 Correct 3 ms 1140 KB Output is correct
37 Correct 3 ms 1140 KB Output is correct
38 Correct 3 ms 1140 KB Output is correct
39 Correct 3 ms 1140 KB Output is correct
40 Correct 3 ms 1140 KB Output is correct
41 Correct 3 ms 1140 KB Output is correct
42 Correct 3 ms 1140 KB Output is correct
43 Correct 3 ms 1140 KB Output is correct
44 Correct 2 ms 1140 KB Output is correct
45 Correct 2 ms 1140 KB Output is correct
46 Correct 2 ms 1140 KB Output is correct
47 Correct 2 ms 1140 KB Output is correct
48 Correct 2 ms 1140 KB Output is correct
49 Correct 2 ms 1140 KB Output is correct
50 Correct 2 ms 1140 KB Output is correct
51 Correct 2 ms 1140 KB Output is correct
52 Correct 14 ms 4220 KB Output is correct
53 Correct 35 ms 5756 KB Output is correct
54 Correct 112 ms 8444 KB Output is correct
55 Correct 57 ms 8572 KB Output is correct
56 Correct 531 ms 23420 KB Output is correct
57 Correct 515 ms 23420 KB Output is correct
58 Correct 505 ms 23420 KB Output is correct
59 Correct 577 ms 23420 KB Output is correct
60 Correct 632 ms 23420 KB Output is correct
61 Correct 2 ms 23420 KB Output is correct
62 Correct 35 ms 23420 KB Output is correct
63 Correct 43 ms 23420 KB Output is correct
64 Correct 41 ms 23420 KB Output is correct
65 Correct 162 ms 23420 KB Output is correct
66 Correct 358 ms 23420 KB Output is correct
67 Correct 532 ms 23420 KB Output is correct
68 Correct 494 ms 23420 KB Output is correct
69 Correct 501 ms 23420 KB Output is correct