Submission #68754

# Submission time Handle Problem Language Result Execution time Memory
68754 2018-08-18T10:32:19 Z FedericoS Bali Sculptures (APIO15_sculpture) C++14
0 / 100
1000 ms 760 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()<1000000);

		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;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;

	}

}
/*
6 1 3
8 1 2 1 5 4
*/
# Verdict Execution time Memory Grader output
1 Correct 1000 ms 504 KB Output is correct
2 Correct 1000 ms 548 KB Output is correct
3 Correct 1000 ms 548 KB Output is correct
4 Execution timed out 1000 ms 640 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 999 ms 640 KB Output is correct
2 Correct 999 ms 640 KB Output is correct
3 Correct 1000 ms 640 KB Output is correct
4 Correct 1000 ms 696 KB Output is correct
5 Correct 1000 ms 696 KB Output is correct
6 Correct 1000 ms 696 KB Output is correct
7 Correct 1000 ms 696 KB Output is correct
8 Correct 1000 ms 696 KB Output is correct
9 Execution timed out 1000 ms 696 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1000 ms 696 KB Output is correct
2 Correct 1000 ms 696 KB Output is correct
3 Correct 1000 ms 728 KB Output is correct
4 Correct 1000 ms 728 KB Output is correct
5 Correct 1000 ms 728 KB Output is correct
6 Correct 1000 ms 728 KB Output is correct
7 Correct 1000 ms 728 KB Output is correct
8 Correct 1000 ms 728 KB Output is correct
9 Correct 1000 ms 728 KB Output is correct
10 Correct 1000 ms 728 KB Output is correct
11 Correct 1000 ms 728 KB Output is correct
12 Correct 1000 ms 728 KB Output is correct
13 Correct 1000 ms 728 KB Output is correct
14 Correct 1000 ms 728 KB Output is correct
15 Correct 1000 ms 728 KB Output is correct
16 Correct 1000 ms 728 KB Output is correct
17 Correct 1000 ms 728 KB Output is correct
18 Correct 1000 ms 728 KB Output is correct
19 Correct 1000 ms 728 KB Output is correct
20 Correct 1000 ms 728 KB Output is correct
21 Correct 1000 ms 728 KB Output is correct
22 Correct 1000 ms 728 KB Output is correct
23 Correct 1000 ms 728 KB Output is correct
24 Correct 1000 ms 728 KB Output is correct
25 Correct 1000 ms 728 KB Output is correct
26 Correct 1000 ms 728 KB Output is correct
27 Execution timed out 1000 ms 728 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1000 ms 728 KB Output is correct
2 Correct 999 ms 728 KB Output is correct
3 Correct 1000 ms 728 KB Output is correct
4 Correct 1000 ms 728 KB Output is correct
5 Correct 1000 ms 728 KB Output is correct
6 Correct 1000 ms 728 KB Output is correct
7 Correct 1000 ms 752 KB Output is correct
8 Correct 1000 ms 752 KB Output is correct
9 Correct 1000 ms 752 KB Output is correct
10 Correct 1000 ms 752 KB Output is correct
11 Correct 1000 ms 752 KB Output is correct
12 Correct 1000 ms 752 KB Output is correct
13 Correct 1000 ms 752 KB Output is correct
14 Correct 2 ms 752 KB Output is correct
15 Incorrect 2 ms 752 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1000 ms 752 KB Output is correct
2 Correct 1000 ms 752 KB Output is correct
3 Correct 1000 ms 752 KB Output is correct
4 Correct 1000 ms 752 KB Output is correct
5 Correct 1000 ms 752 KB Output is correct
6 Correct 1000 ms 752 KB Output is correct
7 Correct 1000 ms 752 KB Output is correct
8 Correct 1000 ms 752 KB Output is correct
9 Correct 1000 ms 752 KB Output is correct
10 Correct 1000 ms 752 KB Output is correct
11 Correct 1000 ms 752 KB Output is correct
12 Correct 1000 ms 752 KB Output is correct
13 Correct 1000 ms 752 KB Output is correct
14 Correct 1000 ms 752 KB Output is correct
15 Correct 1000 ms 760 KB Output is correct
16 Correct 1000 ms 760 KB Output is correct
17 Correct 1000 ms 760 KB Output is correct
18 Correct 1000 ms 760 KB Output is correct
19 Correct 1000 ms 760 KB Output is correct
20 Correct 1000 ms 760 KB Output is correct
21 Correct 1000 ms 760 KB Output is correct
22 Correct 1000 ms 760 KB Output is correct
23 Correct 1000 ms 760 KB Output is correct
24 Correct 1000 ms 760 KB Output is correct
25 Correct 1000 ms 760 KB Output is correct
26 Correct 1000 ms 760 KB Output is correct
27 Correct 1000 ms 760 KB Output is correct
28 Correct 1000 ms 760 KB Output is correct
29 Correct 1000 ms 760 KB Output is correct
30 Correct 1000 ms 760 KB Output is correct
31 Correct 1000 ms 760 KB Output is correct
32 Correct 1000 ms 760 KB Output is correct
33 Correct 1000 ms 760 KB Output is correct
34 Correct 1000 ms 760 KB Output is correct
35 Correct 1000 ms 760 KB Output is correct
36 Correct 1000 ms 760 KB Output is correct
37 Execution timed out 1000 ms 760 KB Time limit exceeded
38 Halted 0 ms 0 KB -