답안 #68770

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
68770 2018-08-18T10:52:31 Z FedericoS Bali Sculptures (APIO15_sculpture) C++14
100 / 100
332 ms 1480 KB
#include <iostream>
using namespace std;
typedef long long int ll;

ll INF=1e18;
ll P=60;
int N,A,B;
ll Y[2005];
ll V[2005];
ll ans,res;
bool M[2005][2005];
bool flag;

int main(){

	cin>>N>>A>>B;
	for(int i=0;i<N;i++)
		cin>>Y[i];

	if(A==1){

		while(clock()<100000);

		ans=(1LL<<P)-1;

		for(int c=P-1;c>=0;c--){

			ans=ans^(1LL<<c);

			fill(V,V+N,INF);

			for(int i=N-1;i>=0;i--){
				res=0;
				for(int j=i;j<N;j++){
					res+=Y[j];
					if((res|ans)==ans)
						V[i]=min(V[i],V[j+1]+1);
				}

			}

			if(V[0]==INF or V[0]>B)
				ans=ans^(1LL<<c);

			//for(int i=0;i<N+1;i++)cout<<(V[i]==INF?-1:V[i])<<" ";cout<<endl;

		}

		cout<<ans;
			
	}
	else{

		M[0][N]=true;

		ans=(1LL<<P)-1;

		for(int c=P-1;c>=0;c--){

			ans=ans^(1LL<<c);

			for(int k=1;k<N+1;k++){

				fill(M[k],M[k]+N,false);

				for(int i=N-1;i>=0;i--){
					res=0;
					for(int j=i;j<N;j++){
						res+=Y[j];
						if((res|ans)==ans)
							M[k][i]=M[k][i]|M[k-1][j+1];
					}

				}
				
			}

			flag=false;
			for(int k=A;k<=B;k++)
				if(M[k][0])
					flag=true;

			if(!flag)
				ans=ans^(1LL<<c);

			//for(int i=0;i<N+1;i++)cout<<(V[i]==INF?-1:V[i])<<" ";cout<<endl;

			/*cout<<ans<<endl;
			for(int k=0;k<N+1;k++){
				for(int i=0;i<N;i++)
					cout<<M[k][i]<<" ";
				cout<<endl;
			}
			cout<<"********\n";*/


		}

		cout<<ans;

	}

}
/*
6 6 6
8 1 2 1 5 4
*/	
# 결과 실행 시간 메모리 Grader output
1 Correct 100 ms 248 KB Output is correct
2 Correct 100 ms 424 KB Output is correct
3 Correct 100 ms 432 KB Output is correct
4 Correct 100 ms 508 KB Output is correct
5 Correct 100 ms 540 KB Output is correct
6 Correct 100 ms 612 KB Output is correct
7 Correct 100 ms 620 KB Output is correct
8 Correct 100 ms 748 KB Output is correct
9 Correct 100 ms 748 KB Output is correct
10 Correct 100 ms 748 KB Output is correct
11 Correct 100 ms 748 KB Output is correct
12 Correct 100 ms 748 KB Output is correct
13 Correct 99 ms 748 KB Output is correct
14 Correct 2 ms 748 KB Output is correct
15 Correct 2 ms 748 KB Output is correct
16 Correct 2 ms 748 KB Output is correct
17 Correct 3 ms 748 KB Output is correct
18 Correct 2 ms 748 KB Output is correct
19 Correct 2 ms 748 KB Output is correct
20 Correct 2 ms 748 KB Output is correct
21 Correct 3 ms 748 KB Output is correct
22 Correct 3 ms 748 KB Output is correct
23 Correct 3 ms 748 KB Output is correct
24 Correct 3 ms 748 KB Output is correct
25 Correct 3 ms 748 KB Output is correct
26 Correct 3 ms 748 KB Output is correct
27 Correct 100 ms 748 KB Output is correct
28 Correct 100 ms 748 KB Output is correct
29 Correct 100 ms 748 KB Output is correct
30 Correct 100 ms 748 KB Output is correct
31 Correct 100 ms 748 KB Output is correct
32 Correct 101 ms 748 KB Output is correct
33 Correct 100 ms 748 KB Output is correct
34 Correct 100 ms 748 KB Output is correct
35 Correct 101 ms 760 KB Output is correct
36 Correct 100 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 100 ms 760 KB Output is correct
2 Correct 101 ms 760 KB Output is correct
3 Correct 99 ms 760 KB Output is correct
4 Correct 100 ms 760 KB Output is correct
5 Correct 100 ms 760 KB Output is correct
6 Correct 100 ms 760 KB Output is correct
7 Correct 100 ms 760 KB Output is correct
8 Correct 100 ms 760 KB Output is correct
9 Correct 100 ms 760 KB Output is correct
10 Correct 100 ms 760 KB Output is correct
11 Correct 100 ms 760 KB Output is correct
12 Correct 100 ms 760 KB Output is correct
13 Correct 100 ms 760 KB Output is correct
14 Correct 2 ms 768 KB Output is correct
15 Correct 3 ms 768 KB Output is correct
16 Correct 2 ms 768 KB Output is correct
17 Correct 3 ms 768 KB Output is correct
18 Correct 2 ms 768 KB Output is correct
19 Correct 3 ms 768 KB Output is correct
20 Correct 3 ms 768 KB Output is correct
21 Correct 3 ms 768 KB Output is correct
22 Correct 3 ms 768 KB Output is correct
23 Correct 3 ms 768 KB Output is correct
24 Correct 3 ms 768 KB Output is correct
25 Correct 3 ms 768 KB Output is correct
26 Correct 3 ms 768 KB Output is correct
27 Correct 100 ms 768 KB Output is correct
28 Correct 100 ms 768 KB Output is correct
29 Correct 100 ms 768 KB Output is correct
30 Correct 100 ms 768 KB Output is correct
31 Correct 100 ms 768 KB Output is correct
32 Correct 99 ms 768 KB Output is correct
33 Correct 100 ms 768 KB Output is correct
34 Correct 100 ms 768 KB Output is correct
35 Correct 100 ms 768 KB Output is correct
36 Correct 100 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 100 ms 768 KB Output is correct
2 Correct 100 ms 768 KB Output is correct
3 Correct 100 ms 768 KB Output is correct
4 Correct 100 ms 768 KB Output is correct
5 Correct 100 ms 768 KB Output is correct
6 Correct 101 ms 768 KB Output is correct
7 Correct 100 ms 768 KB Output is correct
8 Correct 100 ms 768 KB Output is correct
9 Correct 100 ms 768 KB Output is correct
10 Correct 99 ms 768 KB Output is correct
11 Correct 100 ms 768 KB Output is correct
12 Correct 100 ms 768 KB Output is correct
13 Correct 100 ms 768 KB Output is correct
14 Correct 100 ms 768 KB Output is correct
15 Correct 100 ms 768 KB Output is correct
16 Correct 100 ms 768 KB Output is correct
17 Correct 100 ms 768 KB Output is correct
18 Correct 100 ms 768 KB Output is correct
19 Correct 100 ms 768 KB Output is correct
20 Correct 100 ms 792 KB Output is correct
21 Correct 100 ms 792 KB Output is correct
22 Correct 100 ms 792 KB Output is correct
23 Correct 101 ms 792 KB Output is correct
24 Correct 100 ms 792 KB Output is correct
25 Correct 100 ms 792 KB Output is correct
26 Correct 101 ms 792 KB Output is correct
27 Correct 101 ms 792 KB Output is correct
28 Correct 101 ms 792 KB Output is correct
29 Correct 101 ms 792 KB Output is correct
30 Correct 101 ms 792 KB Output is correct
31 Correct 101 ms 792 KB Output is correct
32 Correct 100 ms 792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 100 ms 792 KB Output is correct
2 Correct 100 ms 792 KB Output is correct
3 Correct 100 ms 792 KB Output is correct
4 Correct 100 ms 792 KB Output is correct
5 Correct 100 ms 792 KB Output is correct
6 Correct 100 ms 792 KB Output is correct
7 Correct 100 ms 792 KB Output is correct
8 Correct 100 ms 792 KB Output is correct
9 Correct 100 ms 792 KB Output is correct
10 Correct 100 ms 792 KB Output is correct
11 Correct 100 ms 792 KB Output is correct
12 Correct 100 ms 792 KB Output is correct
13 Correct 100 ms 792 KB Output is correct
14 Correct 2 ms 792 KB Output is correct
15 Correct 3 ms 792 KB Output is correct
16 Correct 3 ms 792 KB Output is correct
17 Correct 2 ms 792 KB Output is correct
18 Correct 3 ms 792 KB Output is correct
19 Correct 4 ms 792 KB Output is correct
20 Correct 3 ms 792 KB Output is correct
21 Correct 3 ms 792 KB Output is correct
22 Correct 3 ms 792 KB Output is correct
23 Correct 4 ms 792 KB Output is correct
24 Correct 4 ms 792 KB Output is correct
25 Correct 3 ms 792 KB Output is correct
26 Correct 3 ms 792 KB Output is correct
27 Correct 100 ms 792 KB Output is correct
28 Correct 100 ms 792 KB Output is correct
29 Correct 100 ms 792 KB Output is correct
30 Correct 99 ms 792 KB Output is correct
31 Correct 100 ms 792 KB Output is correct
32 Correct 99 ms 792 KB Output is correct
33 Correct 101 ms 796 KB Output is correct
34 Correct 100 ms 796 KB Output is correct
35 Correct 100 ms 804 KB Output is correct
36 Correct 100 ms 804 KB Output is correct
37 Correct 100 ms 812 KB Output is correct
38 Correct 100 ms 816 KB Output is correct
39 Correct 99 ms 820 KB Output is correct
40 Correct 101 ms 824 KB Output is correct
41 Correct 101 ms 824 KB Output is correct
42 Correct 100 ms 832 KB Output is correct
43 Correct 100 ms 836 KB Output is correct
44 Correct 100 ms 836 KB Output is correct
45 Correct 100 ms 844 KB Output is correct
46 Correct 100 ms 848 KB Output is correct
47 Correct 100 ms 848 KB Output is correct
48 Correct 100 ms 856 KB Output is correct
49 Correct 100 ms 864 KB Output is correct
50 Correct 101 ms 864 KB Output is correct
51 Correct 101 ms 872 KB Output is correct
52 Correct 101 ms 880 KB Output is correct
53 Correct 101 ms 880 KB Output is correct
54 Correct 101 ms 884 KB Output is correct
55 Correct 101 ms 888 KB Output is correct
56 Correct 100 ms 896 KB Output is correct
57 Correct 100 ms 896 KB Output is correct
58 Correct 100 ms 900 KB Output is correct
59 Correct 101 ms 900 KB Output is correct
60 Correct 101 ms 908 KB Output is correct
61 Correct 100 ms 908 KB Output is correct
62 Correct 101 ms 908 KB Output is correct
63 Correct 101 ms 920 KB Output is correct
64 Correct 60 ms 1044 KB Output is correct
65 Correct 12 ms 1044 KB Output is correct
66 Correct 20 ms 1060 KB Output is correct
67 Correct 34 ms 1064 KB Output is correct
68 Correct 50 ms 1120 KB Output is correct
69 Correct 59 ms 1120 KB Output is correct
70 Correct 63 ms 1204 KB Output is correct
71 Correct 69 ms 1204 KB Output is correct
72 Correct 63 ms 1204 KB Output is correct
73 Correct 60 ms 1204 KB Output is correct
74 Correct 60 ms 1204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 100 ms 1204 KB Output is correct
2 Correct 100 ms 1204 KB Output is correct
3 Correct 100 ms 1204 KB Output is correct
4 Correct 100 ms 1204 KB Output is correct
5 Correct 100 ms 1204 KB Output is correct
6 Correct 100 ms 1204 KB Output is correct
7 Correct 100 ms 1204 KB Output is correct
8 Correct 100 ms 1204 KB Output is correct
9 Correct 100 ms 1204 KB Output is correct
10 Correct 100 ms 1204 KB Output is correct
11 Correct 100 ms 1204 KB Output is correct
12 Correct 100 ms 1204 KB Output is correct
13 Correct 100 ms 1204 KB Output is correct
14 Correct 100 ms 1204 KB Output is correct
15 Correct 100 ms 1204 KB Output is correct
16 Correct 100 ms 1204 KB Output is correct
17 Correct 100 ms 1204 KB Output is correct
18 Correct 100 ms 1204 KB Output is correct
19 Correct 100 ms 1204 KB Output is correct
20 Correct 100 ms 1204 KB Output is correct
21 Correct 100 ms 1204 KB Output is correct
22 Correct 100 ms 1204 KB Output is correct
23 Correct 100 ms 1204 KB Output is correct
24 Correct 100 ms 1204 KB Output is correct
25 Correct 100 ms 1204 KB Output is correct
26 Correct 100 ms 1204 KB Output is correct
27 Correct 100 ms 1204 KB Output is correct
28 Correct 100 ms 1204 KB Output is correct
29 Correct 100 ms 1204 KB Output is correct
30 Correct 101 ms 1204 KB Output is correct
31 Correct 101 ms 1204 KB Output is correct
32 Correct 100 ms 1204 KB Output is correct
33 Correct 100 ms 1204 KB Output is correct
34 Correct 100 ms 1204 KB Output is correct
35 Correct 100 ms 1204 KB Output is correct
36 Correct 101 ms 1204 KB Output is correct
37 Correct 101 ms 1204 KB Output is correct
38 Correct 101 ms 1204 KB Output is correct
39 Correct 101 ms 1204 KB Output is correct
40 Correct 101 ms 1204 KB Output is correct
41 Correct 101 ms 1204 KB Output is correct
42 Correct 100 ms 1204 KB Output is correct
43 Correct 100 ms 1204 KB Output is correct
44 Correct 100 ms 1204 KB Output is correct
45 Correct 101 ms 1204 KB Output is correct
46 Correct 100 ms 1204 KB Output is correct
47 Correct 100 ms 1204 KB Output is correct
48 Correct 100 ms 1204 KB Output is correct
49 Correct 100 ms 1204 KB Output is correct
50 Correct 101 ms 1204 KB Output is correct
51 Correct 100 ms 1204 KB Output is correct
52 Correct 120 ms 1204 KB Output is correct
53 Correct 130 ms 1204 KB Output is correct
54 Correct 160 ms 1204 KB Output is correct
55 Correct 159 ms 1204 KB Output is correct
56 Correct 327 ms 1280 KB Output is correct
57 Correct 309 ms 1280 KB Output is correct
58 Correct 319 ms 1280 KB Output is correct
59 Correct 312 ms 1280 KB Output is correct
60 Correct 332 ms 1364 KB Output is correct
61 Correct 100 ms 1364 KB Output is correct
62 Correct 131 ms 1364 KB Output is correct
63 Correct 160 ms 1364 KB Output is correct
64 Correct 153 ms 1364 KB Output is correct
65 Correct 207 ms 1364 KB Output is correct
66 Correct 265 ms 1364 KB Output is correct
67 Correct 321 ms 1372 KB Output is correct
68 Correct 316 ms 1480 KB Output is correct
69 Correct 323 ms 1480 KB Output is correct