답안 #199405

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
199405 2020-02-01T08:30:02 Z detaomega Bali Sculptures (APIO15_sculpture) C++14
71 / 100
24 ms 504 KB
//#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define de(x,y) cout<<#x<<" :"<<x<<y;
#define int long long
typedef pair<int,int> pii;

const int maxn = 1e2+5;

int arr[2005], ans = 0, n, A, B;
int pre[2005];
int two[60];
void solve() {
	int dp[maxn][maxn];
	int digit = __lg(pre[n]);
	for(int x=digit; x>=0; x--) {
		memset(dp, 0, sizeof(dp));
		dp[0][0] = 1;
		for(int i=1; i<=n; i++) {
			for(int j=1; j<=i; j++) {
				for(int k=0; k<i; k++) {
					if(dp[k][j-1]) {
						int tmp = pre[i] - pre[k];
						if((tmp & (two[x])) == 0 &&((tmp>>(int)(x+1))|ans)==ans ) {
							dp[i][j] = 1;
						}
					}
				} 
			} 
		}	
		ans<<=1;
		ans++; 
		for(int i=A; i<=B; i++) {
			if(dp[n][i]) {
				ans--;
				break;
			}
		}
	}
}
void solve2() {
	int dp[2005];
	dp[0] = 0;
	int digit = __lg(pre[n]);
	for(int x=digit; x>=0; x--) {
		for(int i=1; i<=n; i++) {
			dp[i] = 3005;
		}
		dp[0] = 0;
		for(int i=1; i<=n; i++) {
			for(int j=0; j<i; j++) {
				if(dp[j]) {
					int tmp = pre[i] - pre[j];
					if((tmp & (two[x])) == 0 &&((tmp>>(int)(x+1))|ans)==ans) {
						dp[i] = min(dp[i], dp[j]+1);
					}
				}
			}
		}
		ans <<= 1;
		ans++;
		if(dp[n] <= B)ans--;
	}
}
main() {IOS
//	int n, A, B;
	cin >> n >> A >> B;
	two[0] = 1;
	for(int i=1; i<=50; i++) {
		two[i] = two[i-1] * 2;
	}
	pre[0] = 0;
	for(int i=1; i<=n; i++) {
		cin >> arr[i];
		pre[i] = pre[i-1] + arr[i];
	}
	if(n>100)solve2();
	else
		solve();
	cout << ans << "\n"; 



}

Compilation message

sculpture.cpp:69:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {IOS
      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 424 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 380 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 5 ms 376 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 5 ms 376 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 5 ms 376 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
28 Correct 6 ms 376 KB Output is correct
29 Correct 5 ms 376 KB Output is correct
30 Correct 5 ms 376 KB Output is correct
31 Correct 5 ms 376 KB Output is correct
32 Correct 5 ms 504 KB Output is correct
33 Correct 6 ms 376 KB Output is correct
34 Correct 6 ms 376 KB Output is correct
35 Correct 6 ms 376 KB Output is correct
36 Correct 6 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 5 ms 380 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 5 ms 376 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 5 ms 376 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
28 Correct 5 ms 376 KB Output is correct
29 Correct 6 ms 504 KB Output is correct
30 Correct 6 ms 376 KB Output is correct
31 Correct 6 ms 376 KB Output is correct
32 Correct 6 ms 376 KB Output is correct
33 Correct 6 ms 376 KB Output is correct
34 Correct 7 ms 376 KB Output is correct
35 Correct 6 ms 376 KB Output is correct
36 Correct 6 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
9 Correct 5 ms 380 KB Output is correct
10 Correct 5 ms 504 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 380 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 6 ms 376 KB Output is correct
17 Correct 6 ms 376 KB Output is correct
18 Correct 6 ms 380 KB Output is correct
19 Correct 6 ms 376 KB Output is correct
20 Correct 6 ms 376 KB Output is correct
21 Correct 6 ms 376 KB Output is correct
22 Correct 6 ms 504 KB Output is correct
23 Correct 6 ms 504 KB Output is correct
24 Correct 7 ms 376 KB Output is correct
25 Correct 7 ms 376 KB Output is correct
26 Correct 8 ms 376 KB Output is correct
27 Correct 9 ms 376 KB Output is correct
28 Correct 11 ms 376 KB Output is correct
29 Correct 12 ms 376 KB Output is correct
30 Correct 14 ms 376 KB Output is correct
31 Correct 13 ms 376 KB Output is correct
32 Correct 11 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 6 ms 376 KB Output is correct
17 Correct 5 ms 504 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 6 ms 376 KB Output is correct
23 Correct 6 ms 376 KB Output is correct
24 Correct 5 ms 376 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 5 ms 380 KB Output is correct
27 Correct 6 ms 376 KB Output is correct
28 Correct 6 ms 504 KB Output is correct
29 Correct 5 ms 376 KB Output is correct
30 Correct 5 ms 376 KB Output is correct
31 Correct 5 ms 376 KB Output is correct
32 Correct 5 ms 376 KB Output is correct
33 Correct 6 ms 376 KB Output is correct
34 Correct 5 ms 376 KB Output is correct
35 Correct 5 ms 376 KB Output is correct
36 Correct 5 ms 376 KB Output is correct
37 Correct 5 ms 504 KB Output is correct
38 Correct 5 ms 504 KB Output is correct
39 Correct 6 ms 376 KB Output is correct
40 Correct 6 ms 376 KB Output is correct
41 Correct 6 ms 376 KB Output is correct
42 Correct 6 ms 376 KB Output is correct
43 Correct 6 ms 376 KB Output is correct
44 Correct 6 ms 376 KB Output is correct
45 Correct 6 ms 376 KB Output is correct
46 Correct 6 ms 376 KB Output is correct
47 Correct 6 ms 376 KB Output is correct
48 Correct 7 ms 376 KB Output is correct
49 Correct 8 ms 376 KB Output is correct
50 Correct 9 ms 376 KB Output is correct
51 Correct 11 ms 376 KB Output is correct
52 Correct 11 ms 376 KB Output is correct
53 Correct 12 ms 376 KB Output is correct
54 Correct 13 ms 376 KB Output is correct
55 Correct 12 ms 376 KB Output is correct
56 Correct 8 ms 504 KB Output is correct
57 Correct 15 ms 376 KB Output is correct
58 Correct 18 ms 376 KB Output is correct
59 Correct 21 ms 376 KB Output is correct
60 Correct 22 ms 376 KB Output is correct
61 Correct 24 ms 376 KB Output is correct
62 Correct 22 ms 376 KB Output is correct
63 Correct 24 ms 376 KB Output is correct
64 Correct 8 ms 376 KB Output is correct
65 Correct 8 ms 380 KB Output is correct
66 Correct 11 ms 376 KB Output is correct
67 Correct 14 ms 376 KB Output is correct
68 Correct 21 ms 504 KB Output is correct
69 Correct 21 ms 504 KB Output is correct
70 Correct 23 ms 504 KB Output is correct
71 Correct 22 ms 380 KB Output is correct
72 Correct 21 ms 380 KB Output is correct
73 Correct 22 ms 376 KB Output is correct
74 Correct 21 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 6 ms 504 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 380 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 504 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 504 KB Output is correct
20 Correct 6 ms 376 KB Output is correct
21 Correct 5 ms 504 KB Output is correct
22 Correct 5 ms 376 KB Output is correct
23 Correct 6 ms 504 KB Output is correct
24 Correct 6 ms 376 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 6 ms 376 KB Output is correct
27 Correct 6 ms 376 KB Output is correct
28 Correct 6 ms 376 KB Output is correct
29 Correct 7 ms 376 KB Output is correct
30 Correct 6 ms 376 KB Output is correct
31 Correct 6 ms 376 KB Output is correct
32 Correct 6 ms 380 KB Output is correct
33 Correct 6 ms 504 KB Output is correct
34 Correct 7 ms 376 KB Output is correct
35 Correct 7 ms 376 KB Output is correct
36 Correct 8 ms 504 KB Output is correct
37 Correct 9 ms 376 KB Output is correct
38 Correct 11 ms 376 KB Output is correct
39 Correct 11 ms 376 KB Output is correct
40 Correct 11 ms 376 KB Output is correct
41 Correct 11 ms 376 KB Output is correct
42 Correct 12 ms 376 KB Output is correct
43 Correct 8 ms 376 KB Output is correct
44 Correct 15 ms 376 KB Output is correct
45 Correct 20 ms 376 KB Output is correct
46 Correct 24 ms 504 KB Output is correct
47 Correct 24 ms 376 KB Output is correct
48 Correct 23 ms 476 KB Output is correct
49 Correct 22 ms 376 KB Output is correct
50 Correct 22 ms 504 KB Output is correct
51 Incorrect 6 ms 376 KB Output isn't correct
52 Halted 0 ms 0 KB -