Submission #115681

# Submission time Handle Problem Language Result Execution time Memory
115681 2019-06-08T15:27:42 Z suzy Bali Sculptures (APIO15_sculpture) C++17
37 / 100
5 ms 640 KB
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long lli;

lli a[2001], p[2001];
int n, L, R;
vector<int> con[2001], tmp[2001];
int d1[101][101], d2[2001];

int f1(int c, int k) {
	if(k>n) return L<=c && c<=R;
	if(d1[c][k]>=0) return d1[c][k];
	for(int i=0;i<con[k].size();i++) {
		int v=con[k][i];
		if(f1(c+1,v+1)) return d1[c][k]=1;
	}
	return d1[c][k]=0;
}

int f2(int k) {
	if(k>n) return 0;
	if(d2[k]>=0) return d2[k];
	int ret=(1<<30);
	for(int i=0;i<con[k].size();i++) {
		int v=con[k][i];
		ret=min(ret,f2(v+1)+1);
	}
	return d2[k]=ret;
}

void make(int b) {
	for(int i=1;i<=n;i++) {
		tmp[i]=con[i];
		con[i].clear();
		for(int j=0;j<tmp[i].size();j++) {
			if((p[tmp[i][j]]-p[i-1])&(1<<b)) continue;
			con[i].push_back(tmp[i][j]);
		}
	}
}

int solve1() {
	int ret=0;
	for(int b=29;b>=0;b--) {
		memset(d1,-1,sizeof(d1));
		make(b);
		if(f1(0,1)==0) {
			for(int i=1;i<=n;i++)
				con[i]=tmp[i];
			ret|=(1<<b);
		}
	}
	return ret;
}

int solve2() {
	int ret=0;
	for(int b=29;b>=0;b--) {
		memset(d2,-1,sizeof(d2));
		make(b);
		if(f2(1)>R) {
			for(int i=1;i<=n;i++)
				con[i]=tmp[i];
			ret|=(1<<b);
		}
	}
	return ret;
}

int main() {
	scanf("%d %d %d",&n,&L,&R);
	for(int i=1;i<=n;i++) {
		scanf("%lld",&a[i]);
		p[i]=p[i-1]+a[i];
	}
	for(int i=1;i<=n;i++) {
		for(int j=i;j<=n;j++)
			con[i].push_back(j);
	}
	int res;
	if(L>1) res=solve1();
	else res=solve2();
	printf("%d\n",res);
	return 0;
}

Compilation message

sculpture.cpp: In function 'int f1(int, int)':
sculpture.cpp:18:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<con[k].size();i++) {
              ~^~~~~~~~~~~~~~
sculpture.cpp: In function 'int f2(int)':
sculpture.cpp:29:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<con[k].size();i++) {
              ~^~~~~~~~~~~~~~
sculpture.cpp: In function 'void make(int)':
sculpture.cpp:40:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<tmp[i].size();j++) {
               ~^~~~~~~~~~~~~~
sculpture.cpp: In function 'int main()':
sculpture.cpp:76:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d",&n,&L,&R);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:78:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&a[i]);
   ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 2 ms 512 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 512 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 512 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Incorrect 1 ms 384 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 512 KB Output is correct
15 Correct 2 ms 512 KB Output is correct
16 Correct 2 ms 512 KB Output is correct
17 Correct 2 ms 512 KB Output is correct
18 Correct 2 ms 512 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 512 KB Output is correct
21 Correct 2 ms 512 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 3 ms 512 KB Output is correct
24 Correct 2 ms 512 KB Output is correct
25 Correct 2 ms 512 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 2 ms 512 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 412 KB Output is correct
30 Correct 2 ms 512 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 512 KB Output is correct
33 Correct 3 ms 512 KB Output is correct
34 Correct 2 ms 512 KB Output is correct
35 Correct 2 ms 512 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 512 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 512 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 512 KB Output is correct
16 Correct 2 ms 512 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 512 KB Output is correct
24 Correct 2 ms 512 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 2 ms 512 KB Output is correct
28 Correct 3 ms 512 KB Output is correct
29 Correct 2 ms 512 KB Output is correct
30 Correct 3 ms 512 KB Output is correct
31 Correct 2 ms 512 KB Output is correct
32 Correct 3 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 512 KB Output is correct
15 Correct 2 ms 512 KB Output is correct
16 Correct 2 ms 512 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 512 KB Output is correct
20 Correct 2 ms 512 KB Output is correct
21 Correct 2 ms 512 KB Output is correct
22 Correct 2 ms 512 KB Output is correct
23 Correct 2 ms 512 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 512 KB Output is correct
26 Correct 2 ms 512 KB Output is correct
27 Incorrect 2 ms 384 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 512 KB Output is correct
13 Correct 2 ms 512 KB Output is correct
14 Incorrect 2 ms 384 KB Output isn't correct
15 Halted 0 ms 0 KB -