Submission #72708

# Submission time Handle Problem Language Result Execution time Memory
72708 2018-08-26T18:31:46 Z Pajaraja Bali Sculptures (APIO15_sculpture) C++17
0 / 100
5 ms 916 KB
#include <bits/stdc++.h>
#define MAXN 2007
using namespace std;
long long s[MAXN][MAXN],arr[MAXN];
bool g[MAXN][MAXN],ag[MAXN][MAXN],dp[MAXN][MAXN];
int dpl[MAXN];
int main()
{
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	for(int i=0;i<n;i++) scanf("%lld",&arr[i]);
	for(int i=0;i<n;i++) s[i][i]=arr[i];
	for(int i=0;i<n;i++) for(int j=i+1;j<=n;j++) {ag[i][j]=true; s[i][j]=s[i][j-1]+arr[j];}
	long long rez=0;
	for(int x=40;x>=0;x--)
	{
		for(int i=0;i<n;i++) for(int j=i+1;j<=n;j++) g[i][j]=(((1LL<<x)|s[i][j-1])!=s[i][j-1]) && ag[i][j];
		bool ra=false;
		if(n<=200)
		{
			for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) dp[i][j]=false;
			dp[0][0]=true;
			for(int i=0;i<n;i++) for(int j=i+1;j<=n;j++) if(g[i][j]) for(int r=1;r<n;r++) dp[j][r]=dp[j][r]||dp[i][r-1];
			for(int i=a;i<=b;i++) ra=ra||dp[n][i];
		}
		else
		{
			for(int i=1;i<=n;i++) dpl[i]=MAXN;
			dpl[0]=0;
			for(int i=0;i<n;i++) for(int j=i+1;j<=n;j++) dpl[j]=min(dpl[j],dpl[i]+1);
			if(dpl[n]<=b) ra=true; 
		}
		if(ra) for(int i=0;i<n;i++) for(int j=i+1;j<=n;j++) ag[i][j]=g[i][j];
		else rez+=(1LL<<x);
	}
	printf("%lld",rez);
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:10: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:11:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0;i<n;i++) scanf("%lld",&arr[i]);
                       ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 5 ms 444 KB Output is correct
3 Incorrect 4 ms 460 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 644 KB Output is correct
2 Correct 2 ms 648 KB Output is correct
3 Incorrect 2 ms 648 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 880 KB Output is correct
2 Correct 2 ms 880 KB Output is correct
3 Incorrect 2 ms 880 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 880 KB Output is correct
2 Correct 2 ms 916 KB Output is correct
3 Incorrect 2 ms 916 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 916 KB Output is correct
2 Correct 2 ms 916 KB Output is correct
3 Incorrect 3 ms 916 KB Output isn't correct
4 Halted 0 ms 0 KB -