답안 #14387

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
14387 2015-05-13T15:40:31 Z woqja125 Bali Sculptures (APIO15_sculpture) C++14
100 / 100
827 ms 8944 KB
#include<stdio.h>
#include<string.h>
int y[2001];
long long s[2001];
bool t1[2001][2001];
bool t2[2001][2001];
long long min(long long a, long long b){if(a<b)return a; return b;}
bool chk();
int n, a, b;
int main()
{
	int i, j;
	scanf("%d%d%d", &n, &a, &b);
	for(i=1; i<=n; i++)scanf("%d", y+i);
	for(i=1; i<=n; i++) s[i] = s[i-1] + y[i];
	for(i=1; i<=n; i++)for(j=i; j<=n; j++) t1[i][j] = true;
	long long ans = 0;
	for(int B=50; B>=0; B--)
	{
		for(i=1; i<=n; i++)for(j=1; j<=n; j++) t2[i][j] = t1[i][j];
		for(i=1; i<=n; i++) for(j=i; j<=n; j++) if( ((s[j] - s[i-1])&(1ll<<B)) != 0 ) t2[i][j] = false;
		if(chk())
		{
			for(i=1; i<=n; i++)for(j=1; j<=n; j++) t1[i][j] = t2[i][j];
		}
		else ans += (1ll<<B);
	}
	printf("%lld\n", ans);
	return 0;
}

bool chk1();
bool chk2();
bool chk()
{
	if(a!=1) return chk1();
	else return chk2();
}

bool dp[101][101];
bool chk1()
{
	int i, j, k;
	memset(dp, 0, sizeof(dp));
	dp[0][0] = true;
	for(i=0; i<b; i++)for(j=0; j<n; j++)
	{
		if(!dp[i][j]) continue;
		for(k=j+1; k<=n; k++)
		{
			if(t2[j+1][k] == true) dp[i+1][k] = true;
		}
	}
	for(i=a; i<=b; i++) if(dp[i][n]) return true;
	return false;
}

int d[2001];
bool chk2()
{
	int i, j;
	for(i=1; i<=n; i++) d[i] = 10000;
	for(i=0; i<n; i++)
	{
		for(j=i+1; j<=n; j++) if(t2[i+1][j]) d[j] = min(d[j], d[i]+1);
	}
	return d[n]<=b;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 8944 KB Output is correct
2 Correct 0 ms 8944 KB Output is correct
3 Correct 0 ms 8944 KB Output is correct
4 Correct 0 ms 8944 KB Output is correct
5 Correct 0 ms 8944 KB Output is correct
6 Correct 0 ms 8944 KB Output is correct
7 Correct 0 ms 8944 KB Output is correct
8 Correct 0 ms 8944 KB Output is correct
9 Correct 0 ms 8944 KB Output is correct
10 Correct 0 ms 8944 KB Output is correct
11 Correct 0 ms 8944 KB Output is correct
12 Correct 0 ms 8944 KB Output is correct
13 Correct 0 ms 8944 KB Output is correct
14 Correct 0 ms 8944 KB Output is correct
15 Correct 0 ms 8944 KB Output is correct
16 Correct 0 ms 8944 KB Output is correct
17 Correct 0 ms 8944 KB Output is correct
18 Correct 0 ms 8944 KB Output is correct
19 Correct 0 ms 8944 KB Output is correct
20 Correct 0 ms 8944 KB Output is correct
21 Correct 0 ms 8944 KB Output is correct
22 Correct 0 ms 8944 KB Output is correct
23 Correct 0 ms 8944 KB Output is correct
24 Correct 0 ms 8944 KB Output is correct
25 Correct 0 ms 8944 KB Output is correct
26 Correct 0 ms 8944 KB Output is correct
27 Correct 0 ms 8944 KB Output is correct
28 Correct 0 ms 8944 KB Output is correct
29 Correct 0 ms 8944 KB Output is correct
30 Correct 0 ms 8944 KB Output is correct
31 Correct 0 ms 8944 KB Output is correct
32 Correct 0 ms 8944 KB Output is correct
33 Correct 0 ms 8944 KB Output is correct
34 Correct 0 ms 8944 KB Output is correct
35 Correct 0 ms 8944 KB Output is correct
36 Correct 0 ms 8944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 8944 KB Output is correct
2 Correct 0 ms 8944 KB Output is correct
3 Correct 0 ms 8944 KB Output is correct
4 Correct 0 ms 8944 KB Output is correct
5 Correct 0 ms 8944 KB Output is correct
6 Correct 0 ms 8944 KB Output is correct
7 Correct 0 ms 8944 KB Output is correct
8 Correct 0 ms 8944 KB Output is correct
9 Correct 0 ms 8944 KB Output is correct
10 Correct 0 ms 8944 KB Output is correct
11 Correct 0 ms 8944 KB Output is correct
12 Correct 0 ms 8944 KB Output is correct
13 Correct 0 ms 8944 KB Output is correct
14 Correct 0 ms 8944 KB Output is correct
15 Correct 0 ms 8944 KB Output is correct
16 Correct 0 ms 8944 KB Output is correct
17 Correct 0 ms 8944 KB Output is correct
18 Correct 0 ms 8944 KB Output is correct
19 Correct 0 ms 8944 KB Output is correct
20 Correct 0 ms 8944 KB Output is correct
21 Correct 0 ms 8944 KB Output is correct
22 Correct 0 ms 8944 KB Output is correct
23 Correct 1 ms 8944 KB Output is correct
24 Correct 0 ms 8944 KB Output is correct
25 Correct 0 ms 8944 KB Output is correct
26 Correct 0 ms 8944 KB Output is correct
27 Correct 0 ms 8944 KB Output is correct
28 Correct 0 ms 8944 KB Output is correct
29 Correct 1 ms 8944 KB Output is correct
30 Correct 0 ms 8944 KB Output is correct
31 Correct 0 ms 8944 KB Output is correct
32 Correct 0 ms 8944 KB Output is correct
33 Correct 0 ms 8944 KB Output is correct
34 Correct 0 ms 8944 KB Output is correct
35 Correct 0 ms 8944 KB Output is correct
36 Correct 0 ms 8944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 8944 KB Output is correct
2 Correct 0 ms 8944 KB Output is correct
3 Correct 0 ms 8944 KB Output is correct
4 Correct 0 ms 8944 KB Output is correct
5 Correct 0 ms 8944 KB Output is correct
6 Correct 0 ms 8944 KB Output is correct
7 Correct 0 ms 8944 KB Output is correct
8 Correct 0 ms 8944 KB Output is correct
9 Correct 0 ms 8944 KB Output is correct
10 Correct 0 ms 8944 KB Output is correct
11 Correct 0 ms 8944 KB Output is correct
12 Correct 0 ms 8944 KB Output is correct
13 Correct 0 ms 8944 KB Output is correct
14 Correct 0 ms 8944 KB Output is correct
15 Correct 0 ms 8944 KB Output is correct
16 Correct 1 ms 8944 KB Output is correct
17 Correct 0 ms 8944 KB Output is correct
18 Correct 1 ms 8944 KB Output is correct
19 Correct 0 ms 8944 KB Output is correct
20 Correct 0 ms 8944 KB Output is correct
21 Correct 0 ms 8944 KB Output is correct
22 Correct 0 ms 8944 KB Output is correct
23 Correct 1 ms 8944 KB Output is correct
24 Correct 0 ms 8944 KB Output is correct
25 Correct 1 ms 8944 KB Output is correct
26 Correct 0 ms 8944 KB Output is correct
27 Correct 0 ms 8944 KB Output is correct
28 Correct 0 ms 8944 KB Output is correct
29 Correct 2 ms 8944 KB Output is correct
30 Correct 2 ms 8944 KB Output is correct
31 Correct 3 ms 8944 KB Output is correct
32 Correct 2 ms 8944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 8944 KB Output is correct
2 Correct 0 ms 8944 KB Output is correct
3 Correct 0 ms 8944 KB Output is correct
4 Correct 0 ms 8944 KB Output is correct
5 Correct 0 ms 8944 KB Output is correct
6 Correct 0 ms 8944 KB Output is correct
7 Correct 0 ms 8944 KB Output is correct
8 Correct 0 ms 8944 KB Output is correct
9 Correct 0 ms 8944 KB Output is correct
10 Correct 0 ms 8944 KB Output is correct
11 Correct 0 ms 8944 KB Output is correct
12 Correct 0 ms 8944 KB Output is correct
13 Correct 0 ms 8944 KB Output is correct
14 Correct 0 ms 8944 KB Output is correct
15 Correct 0 ms 8944 KB Output is correct
16 Correct 0 ms 8944 KB Output is correct
17 Correct 0 ms 8944 KB Output is correct
18 Correct 0 ms 8944 KB Output is correct
19 Correct 0 ms 8944 KB Output is correct
20 Correct 0 ms 8944 KB Output is correct
21 Correct 0 ms 8944 KB Output is correct
22 Correct 0 ms 8944 KB Output is correct
23 Correct 0 ms 8944 KB Output is correct
24 Correct 0 ms 8944 KB Output is correct
25 Correct 0 ms 8944 KB Output is correct
26 Correct 0 ms 8944 KB Output is correct
27 Correct 0 ms 8944 KB Output is correct
28 Correct 0 ms 8944 KB Output is correct
29 Correct 0 ms 8944 KB Output is correct
30 Correct 0 ms 8944 KB Output is correct
31 Correct 0 ms 8944 KB Output is correct
32 Correct 0 ms 8944 KB Output is correct
33 Correct 0 ms 8944 KB Output is correct
34 Correct 0 ms 8944 KB Output is correct
35 Correct 0 ms 8944 KB Output is correct
36 Correct 0 ms 8944 KB Output is correct
37 Correct 0 ms 8944 KB Output is correct
38 Correct 0 ms 8944 KB Output is correct
39 Correct 0 ms 8944 KB Output is correct
40 Correct 0 ms 8944 KB Output is correct
41 Correct 0 ms 8944 KB Output is correct
42 Correct 1 ms 8944 KB Output is correct
43 Correct 0 ms 8944 KB Output is correct
44 Correct 0 ms 8944 KB Output is correct
45 Correct 0 ms 8944 KB Output is correct
46 Correct 0 ms 8944 KB Output is correct
47 Correct 0 ms 8944 KB Output is correct
48 Correct 0 ms 8944 KB Output is correct
49 Correct 2 ms 8944 KB Output is correct
50 Correct 2 ms 8944 KB Output is correct
51 Correct 0 ms 8944 KB Output is correct
52 Correct 0 ms 8944 KB Output is correct
53 Correct 2 ms 8944 KB Output is correct
54 Correct 0 ms 8944 KB Output is correct
55 Correct 0 ms 8944 KB Output is correct
56 Correct 0 ms 8944 KB Output is correct
57 Correct 0 ms 8944 KB Output is correct
58 Correct 0 ms 8944 KB Output is correct
59 Correct 0 ms 8944 KB Output is correct
60 Correct 0 ms 8944 KB Output is correct
61 Correct 2 ms 8944 KB Output is correct
62 Correct 2 ms 8944 KB Output is correct
63 Correct 2 ms 8944 KB Output is correct
64 Correct 11 ms 8944 KB Output is correct
65 Correct 0 ms 8944 KB Output is correct
66 Correct 2 ms 8944 KB Output is correct
67 Correct 0 ms 8944 KB Output is correct
68 Correct 3 ms 8944 KB Output is correct
69 Correct 8 ms 8944 KB Output is correct
70 Correct 7 ms 8944 KB Output is correct
71 Correct 2 ms 8944 KB Output is correct
72 Correct 8 ms 8944 KB Output is correct
73 Correct 8 ms 8944 KB Output is correct
74 Correct 8 ms 8944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 8944 KB Output is correct
2 Correct 0 ms 8944 KB Output is correct
3 Correct 0 ms 8944 KB Output is correct
4 Correct 0 ms 8944 KB Output is correct
5 Correct 0 ms 8944 KB Output is correct
6 Correct 0 ms 8944 KB Output is correct
7 Correct 0 ms 8944 KB Output is correct
8 Correct 0 ms 8944 KB Output is correct
9 Correct 0 ms 8944 KB Output is correct
10 Correct 0 ms 8944 KB Output is correct
11 Correct 0 ms 8944 KB Output is correct
12 Correct 0 ms 8944 KB Output is correct
13 Correct 0 ms 8944 KB Output is correct
14 Correct 0 ms 8944 KB Output is correct
15 Correct 0 ms 8944 KB Output is correct
16 Correct 0 ms 8944 KB Output is correct
17 Correct 0 ms 8944 KB Output is correct
18 Correct 0 ms 8944 KB Output is correct
19 Correct 0 ms 8944 KB Output is correct
20 Correct 0 ms 8944 KB Output is correct
21 Correct 0 ms 8944 KB Output is correct
22 Correct 0 ms 8944 KB Output is correct
23 Correct 0 ms 8944 KB Output is correct
24 Correct 0 ms 8944 KB Output is correct
25 Correct 0 ms 8944 KB Output is correct
26 Correct 0 ms 8944 KB Output is correct
27 Correct 0 ms 8944 KB Output is correct
28 Correct 0 ms 8944 KB Output is correct
29 Correct 0 ms 8944 KB Output is correct
30 Correct 0 ms 8944 KB Output is correct
31 Correct 0 ms 8944 KB Output is correct
32 Correct 0 ms 8944 KB Output is correct
33 Correct 0 ms 8944 KB Output is correct
34 Correct 0 ms 8944 KB Output is correct
35 Correct 0 ms 8944 KB Output is correct
36 Correct 2 ms 8944 KB Output is correct
37 Correct 0 ms 8944 KB Output is correct
38 Correct 3 ms 8944 KB Output is correct
39 Correct 2 ms 8944 KB Output is correct
40 Correct 0 ms 8944 KB Output is correct
41 Correct 0 ms 8944 KB Output is correct
42 Correct 0 ms 8944 KB Output is correct
43 Correct 0 ms 8944 KB Output is correct
44 Correct 2 ms 8944 KB Output is correct
45 Correct 0 ms 8944 KB Output is correct
46 Correct 3 ms 8944 KB Output is correct
47 Correct 2 ms 8944 KB Output is correct
48 Correct 0 ms 8944 KB Output is correct
49 Correct 0 ms 8944 KB Output is correct
50 Correct 0 ms 8944 KB Output is correct
51 Correct 3 ms 8944 KB Output is correct
52 Correct 68 ms 8944 KB Output is correct
53 Correct 116 ms 8944 KB Output is correct
54 Correct 202 ms 8944 KB Output is correct
55 Correct 205 ms 8944 KB Output is correct
56 Correct 826 ms 8944 KB Output is correct
57 Correct 827 ms 8944 KB Output is correct
58 Correct 676 ms 8944 KB Output is correct
59 Correct 609 ms 8944 KB Output is correct
60 Correct 612 ms 8944 KB Output is correct
61 Correct 0 ms 8944 KB Output is correct
62 Correct 108 ms 8944 KB Output is correct
63 Correct 191 ms 8944 KB Output is correct
64 Correct 189 ms 8944 KB Output is correct
65 Correct 353 ms 8944 KB Output is correct
66 Correct 534 ms 8944 KB Output is correct
67 Correct 725 ms 8944 KB Output is correct
68 Correct 682 ms 8944 KB Output is correct
69 Correct 689 ms 8944 KB Output is correct