Submission #115682

# Submission time Handle Problem Language Result Execution time Memory
115682 2019-06-08T15:29:49 Z suzy Bali Sculptures (APIO15_sculpture) C++17
100 / 100
94 ms 19072 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])&(1LL<<b)) continue;
			con[i].push_back(tmp[i][j]);
		}
	}
}

lli solve1() {
	lli ret=0;
	for(int b=41;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|=(1LL<<b);
		}
	}
	return ret;
}

lli solve2() {
	lli ret=0;
	for(int b=41;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|=(1LL<<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);
	}
	lli res;
	if(L>1) res=solve1();
	else res=solve2();
	printf("%lld\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 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 428 KB Output is correct
7 Correct 2 ms 356 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 2 ms 512 KB Output is correct
14 Correct 2 ms 640 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 512 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 512 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 512 KB Output is correct
31 Correct 2 ms 512 KB Output is correct
32 Correct 2 ms 512 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 2 ms 384 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 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 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 512 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 512 KB Output is correct
23 Correct 2 ms 384 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 356 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 3 ms 384 KB Output is correct
30 Correct 2 ms 512 KB Output is correct
31 Correct 2 ms 512 KB Output is correct
32 Correct 2 ms 512 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 3 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 2 ms 384 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 1 ms 384 KB Output is correct
4 Correct 15 ms 384 KB Output is correct
5 Correct 2 ms 356 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 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 512 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 2 ms 384 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 384 KB Output is correct
19 Correct 2 ms 512 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 512 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 512 KB Output is correct
26 Correct 3 ms 512 KB Output is correct
27 Correct 4 ms 512 KB Output is correct
28 Correct 4 ms 512 KB Output is correct
29 Correct 3 ms 512 KB Output is correct
30 Correct 3 ms 512 KB Output is correct
31 Correct 3 ms 512 KB Output is correct
32 Correct 3 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 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 3 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 384 KB Output is correct
10 Correct 1 ms 512 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 512 KB Output is correct
13 Correct 0 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 3 ms 512 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 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 512 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 512 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 2 ms 384 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
37 Correct 2 ms 512 KB Output is correct
38 Correct 2 ms 384 KB Output is correct
39 Correct 2 ms 384 KB Output is correct
40 Correct 4 ms 384 KB Output is correct
41 Correct 2 ms 512 KB Output is correct
42 Correct 2 ms 512 KB Output is correct
43 Correct 2 ms 512 KB Output is correct
44 Correct 2 ms 512 KB Output is correct
45 Correct 2 ms 384 KB Output is correct
46 Correct 3 ms 512 KB Output is correct
47 Correct 2 ms 512 KB Output is correct
48 Correct 2 ms 512 KB Output is correct
49 Correct 3 ms 512 KB Output is correct
50 Correct 3 ms 512 KB Output is correct
51 Correct 3 ms 512 KB Output is correct
52 Correct 3 ms 512 KB Output is correct
53 Correct 3 ms 512 KB Output is correct
54 Correct 3 ms 512 KB Output is correct
55 Correct 3 ms 512 KB Output is correct
56 Correct 2 ms 512 KB Output is correct
57 Correct 3 ms 512 KB Output is correct
58 Correct 3 ms 512 KB Output is correct
59 Correct 2 ms 512 KB Output is correct
60 Correct 3 ms 512 KB Output is correct
61 Correct 2 ms 512 KB Output is correct
62 Correct 3 ms 512 KB Output is correct
63 Correct 3 ms 512 KB Output is correct
64 Correct 2 ms 512 KB Output is correct
65 Correct 2 ms 512 KB Output is correct
66 Correct 3 ms 512 KB Output is correct
67 Correct 3 ms 512 KB Output is correct
68 Correct 2 ms 512 KB Output is correct
69 Correct 2 ms 512 KB Output is correct
70 Correct 3 ms 512 KB Output is correct
71 Correct 7 ms 512 KB Output is correct
72 Correct 2 ms 512 KB Output is correct
73 Correct 3 ms 512 KB Output is correct
74 Correct 3 ms 512 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 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 384 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 2 ms 480 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 384 KB Output is correct
15 Correct 2 ms 384 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 512 KB Output is correct
19 Correct 2 ms 512 KB Output is correct
20 Correct 3 ms 384 KB Output is correct
21 Correct 8 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 3 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 Correct 2 ms 512 KB Output is correct
28 Correct 2 ms 512 KB Output is correct
29 Correct 2 ms 512 KB Output is correct
30 Correct 2 ms 512 KB Output is correct
31 Correct 2 ms 512 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 2 ms 512 KB Output is correct
35 Correct 3 ms 384 KB Output is correct
36 Correct 3 ms 512 KB Output is correct
37 Correct 3 ms 512 KB Output is correct
38 Correct 3 ms 512 KB Output is correct
39 Correct 4 ms 512 KB Output is correct
40 Correct 4 ms 512 KB Output is correct
41 Correct 3 ms 512 KB Output is correct
42 Correct 3 ms 412 KB Output is correct
43 Correct 2 ms 512 KB Output is correct
44 Correct 2 ms 512 KB Output is correct
45 Correct 2 ms 512 KB Output is correct
46 Correct 2 ms 512 KB Output is correct
47 Correct 3 ms 512 KB Output is correct
48 Correct 2 ms 512 KB Output is correct
49 Correct 2 ms 512 KB Output is correct
50 Correct 3 ms 512 KB Output is correct
51 Correct 3 ms 512 KB Output is correct
52 Correct 11 ms 2048 KB Output is correct
53 Correct 16 ms 3200 KB Output is correct
54 Correct 30 ms 5120 KB Output is correct
55 Correct 25 ms 5120 KB Output is correct
56 Correct 84 ms 19064 KB Output is correct
57 Correct 77 ms 19064 KB Output is correct
58 Correct 64 ms 19036 KB Output is correct
59 Correct 63 ms 19072 KB Output is correct
60 Correct 94 ms 19072 KB Output is correct
61 Correct 3 ms 512 KB Output is correct
62 Correct 14 ms 3200 KB Output is correct
63 Correct 29 ms 5144 KB Output is correct
64 Correct 21 ms 5120 KB Output is correct
65 Correct 39 ms 10240 KB Output is correct
66 Correct 57 ms 15096 KB Output is correct
67 Correct 77 ms 19064 KB Output is correct
68 Correct 86 ms 18936 KB Output is correct
69 Correct 69 ms 18944 KB Output is correct