Submission #42103

# Submission time Handle Problem Language Result Execution time Memory
42103 2018-02-22T13:50:01 Z fefe Bali Sculptures (APIO15_sculpture) C++14
100 / 100
246 ms 908 KB
//omt...
//왜그랬지ㅠㅠ


#include<bits/stdc++.h>
#define MAX_N 2005
#define inf (1LL<<62)
#define LL long long
using namespace std;
LL n,a,b,ans,arr[MAX_N];
LL t[MAX_N];
bool ct[MAX_N][MAX_N];
bool case1(LL x){
	LL i,j,sum,test,y,z,k,l;
	bool p=false;
	y=inf-1;y-=(1LL<<x)-1;
	z=ans&y;
	for(i=0;i<=n;i++)	for(j=0;j<=n;j++)	ct[i][j]=false;
	ct[0][0]=true;
	for(l=1;l<=b;l++){
		for(i=1;i<=n;i++){
			sum=0;
			for(j=i;j>=1;j--){
				sum+=arr[j];
				k=sum&y;
				if((z|k)==z)	ct[l][i]|=ct[l-1][j-1];
			}
			if(l>=a)	p|=ct[l][n];
		}
	}
	return p;
}
bool is_ok(LL x){
	LL i,j,sum,test,y,z,k;
	y=inf-1;y-=(1LL<<x)-1;
	z=ans&y;
	for(i=1;i<=n;i++)	t[i]=inf;
	t[0]=0;
	for(i=1;i<=n;i++){
		sum=0;
		for(j=i;j>=1;j--){
			sum+=arr[j];
			k=sum&y;
			if((z|k)==z)	t[i]=min(t[i],t[j-1]+1);
		}
	}
	return t[n]<=b;
}
int main(){
	LL i,x;
	scanf("%lld",&n);
	scanf("%lld %lld",&a,&b);
	for(i=1;i<=n;i++)	scanf("%lld",&arr[i]);
	if(n<=100){ans=0;for(i=60;i>=0;i--)	ans|=case1(i)?0LL:(1LL<<i);}
	else{ans=0;for(i=60;i>=0;i--)	ans|=is_ok(i)?0LL:(1LL<<i);}
	printf("%lld\n",ans);
	return 0;
}

Compilation message

sculpture.cpp: In function 'bool case1(long long int)':
sculpture.cpp:14:13: warning: unused variable 'test' [-Wunused-variable]
  LL i,j,sum,test,y,z,k,l;
             ^
sculpture.cpp: In function 'bool is_ok(long long int)':
sculpture.cpp:34:13: warning: unused variable 'test' [-Wunused-variable]
  LL i,j,sum,test,y,z,k;
             ^
sculpture.cpp: In function 'int main()':
sculpture.cpp:50:7: warning: unused variable 'x' [-Wunused-variable]
  LL i,x;
       ^
sculpture.cpp:51:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&n);
                  ^
sculpture.cpp:52:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld",&a,&b);
                          ^
sculpture.cpp:53:41: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1;i<=n;i++) scanf("%lld",&arr[i]);
                                         ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 352 KB Output is correct
3 Correct 2 ms 388 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 2 ms 532 KB Output is correct
6 Correct 2 ms 660 KB Output is correct
7 Correct 2 ms 660 KB Output is correct
8 Correct 2 ms 660 KB Output is correct
9 Correct 2 ms 660 KB Output is correct
10 Correct 2 ms 660 KB Output is correct
11 Correct 2 ms 660 KB Output is correct
12 Correct 2 ms 660 KB Output is correct
13 Correct 3 ms 660 KB Output is correct
14 Correct 2 ms 660 KB Output is correct
15 Correct 2 ms 660 KB Output is correct
16 Correct 2 ms 660 KB Output is correct
17 Correct 2 ms 660 KB Output is correct
18 Correct 2 ms 660 KB Output is correct
19 Correct 2 ms 660 KB Output is correct
20 Correct 2 ms 660 KB Output is correct
21 Correct 2 ms 660 KB Output is correct
22 Correct 2 ms 660 KB Output is correct
23 Correct 2 ms 660 KB Output is correct
24 Correct 2 ms 660 KB Output is correct
25 Correct 2 ms 660 KB Output is correct
26 Correct 2 ms 660 KB Output is correct
27 Correct 2 ms 660 KB Output is correct
28 Correct 2 ms 660 KB Output is correct
29 Correct 2 ms 660 KB Output is correct
30 Correct 2 ms 660 KB Output is correct
31 Correct 2 ms 660 KB Output is correct
32 Correct 2 ms 700 KB Output is correct
33 Correct 2 ms 700 KB Output is correct
34 Correct 2 ms 700 KB Output is correct
35 Correct 2 ms 700 KB Output is correct
36 Correct 2 ms 700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 700 KB Output is correct
2 Correct 1 ms 700 KB Output is correct
3 Correct 2 ms 700 KB Output is correct
4 Correct 2 ms 700 KB Output is correct
5 Correct 1 ms 700 KB Output is correct
6 Correct 2 ms 700 KB Output is correct
7 Correct 2 ms 700 KB Output is correct
8 Correct 2 ms 700 KB Output is correct
9 Correct 2 ms 700 KB Output is correct
10 Correct 2 ms 700 KB Output is correct
11 Correct 2 ms 700 KB Output is correct
12 Correct 2 ms 700 KB Output is correct
13 Correct 2 ms 700 KB Output is correct
14 Correct 2 ms 700 KB Output is correct
15 Correct 2 ms 700 KB Output is correct
16 Correct 2 ms 700 KB Output is correct
17 Correct 2 ms 740 KB Output is correct
18 Correct 2 ms 740 KB Output is correct
19 Correct 2 ms 740 KB Output is correct
20 Correct 2 ms 740 KB Output is correct
21 Correct 2 ms 740 KB Output is correct
22 Correct 2 ms 740 KB Output is correct
23 Correct 2 ms 740 KB Output is correct
24 Correct 2 ms 740 KB Output is correct
25 Correct 2 ms 740 KB Output is correct
26 Correct 2 ms 740 KB Output is correct
27 Correct 3 ms 740 KB Output is correct
28 Correct 2 ms 740 KB Output is correct
29 Correct 2 ms 740 KB Output is correct
30 Correct 4 ms 740 KB Output is correct
31 Correct 5 ms 740 KB Output is correct
32 Correct 5 ms 740 KB Output is correct
33 Correct 2 ms 740 KB Output is correct
34 Correct 5 ms 740 KB Output is correct
35 Correct 4 ms 740 KB Output is correct
36 Correct 3 ms 740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 740 KB Output is correct
2 Correct 1 ms 740 KB Output is correct
3 Correct 2 ms 740 KB Output is correct
4 Correct 2 ms 740 KB Output is correct
5 Correct 2 ms 740 KB Output is correct
6 Correct 2 ms 740 KB Output is correct
7 Correct 2 ms 740 KB Output is correct
8 Correct 1 ms 740 KB Output is correct
9 Correct 2 ms 740 KB Output is correct
10 Correct 2 ms 740 KB Output is correct
11 Correct 2 ms 740 KB Output is correct
12 Correct 2 ms 740 KB Output is correct
13 Correct 2 ms 740 KB Output is correct
14 Correct 2 ms 740 KB Output is correct
15 Correct 3 ms 740 KB Output is correct
16 Correct 2 ms 740 KB Output is correct
17 Correct 4 ms 740 KB Output is correct
18 Correct 5 ms 740 KB Output is correct
19 Correct 5 ms 740 KB Output is correct
20 Correct 3 ms 740 KB Output is correct
21 Correct 5 ms 740 KB Output is correct
22 Correct 6 ms 740 KB Output is correct
23 Correct 4 ms 740 KB Output is correct
24 Correct 6 ms 740 KB Output is correct
25 Correct 5 ms 748 KB Output is correct
26 Correct 11 ms 748 KB Output is correct
27 Correct 33 ms 748 KB Output is correct
28 Correct 69 ms 876 KB Output is correct
29 Correct 76 ms 876 KB Output is correct
30 Correct 3 ms 876 KB Output is correct
31 Correct 34 ms 880 KB Output is correct
32 Correct 53 ms 880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 880 KB Output is correct
2 Correct 2 ms 880 KB Output is correct
3 Correct 2 ms 880 KB Output is correct
4 Correct 2 ms 880 KB Output is correct
5 Correct 2 ms 880 KB Output is correct
6 Correct 2 ms 880 KB Output is correct
7 Correct 2 ms 880 KB Output is correct
8 Correct 2 ms 880 KB Output is correct
9 Correct 2 ms 880 KB Output is correct
10 Correct 2 ms 880 KB Output is correct
11 Correct 1 ms 880 KB Output is correct
12 Correct 2 ms 880 KB Output is correct
13 Correct 3 ms 880 KB Output is correct
14 Correct 1 ms 880 KB Output is correct
15 Correct 2 ms 880 KB Output is correct
16 Correct 2 ms 880 KB Output is correct
17 Correct 1 ms 880 KB Output is correct
18 Correct 2 ms 880 KB Output is correct
19 Correct 2 ms 880 KB Output is correct
20 Correct 2 ms 880 KB Output is correct
21 Correct 2 ms 880 KB Output is correct
22 Correct 2 ms 880 KB Output is correct
23 Correct 2 ms 880 KB Output is correct
24 Correct 2 ms 880 KB Output is correct
25 Correct 2 ms 880 KB Output is correct
26 Correct 2 ms 880 KB Output is correct
27 Correct 1 ms 880 KB Output is correct
28 Correct 1 ms 880 KB Output is correct
29 Correct 2 ms 880 KB Output is correct
30 Correct 2 ms 880 KB Output is correct
31 Correct 2 ms 880 KB Output is correct
32 Correct 2 ms 880 KB Output is correct
33 Correct 2 ms 880 KB Output is correct
34 Correct 2 ms 880 KB Output is correct
35 Correct 1 ms 880 KB Output is correct
36 Correct 2 ms 880 KB Output is correct
37 Correct 2 ms 880 KB Output is correct
38 Correct 2 ms 880 KB Output is correct
39 Correct 2 ms 880 KB Output is correct
40 Correct 4 ms 880 KB Output is correct
41 Correct 6 ms 880 KB Output is correct
42 Correct 7 ms 880 KB Output is correct
43 Correct 2 ms 880 KB Output is correct
44 Correct 6 ms 880 KB Output is correct
45 Correct 5 ms 880 KB Output is correct
46 Correct 3 ms 880 KB Output is correct
47 Correct 6 ms 880 KB Output is correct
48 Correct 5 ms 880 KB Output is correct
49 Correct 13 ms 880 KB Output is correct
50 Correct 35 ms 880 KB Output is correct
51 Correct 73 ms 880 KB Output is correct
52 Correct 68 ms 880 KB Output is correct
53 Correct 3 ms 880 KB Output is correct
54 Correct 37 ms 880 KB Output is correct
55 Correct 53 ms 880 KB Output is correct
56 Correct 5 ms 880 KB Output is correct
57 Correct 10 ms 880 KB Output is correct
58 Correct 28 ms 880 KB Output is correct
59 Correct 57 ms 880 KB Output is correct
60 Correct 58 ms 880 KB Output is correct
61 Correct 3 ms 880 KB Output is correct
62 Correct 60 ms 880 KB Output is correct
63 Correct 60 ms 908 KB Output is correct
64 Correct 56 ms 908 KB Output is correct
65 Correct 5 ms 908 KB Output is correct
66 Correct 6 ms 908 KB Output is correct
67 Correct 10 ms 908 KB Output is correct
68 Correct 28 ms 908 KB Output is correct
69 Correct 60 ms 908 KB Output is correct
70 Correct 55 ms 908 KB Output is correct
71 Correct 3 ms 908 KB Output is correct
72 Correct 60 ms 908 KB Output is correct
73 Correct 48 ms 908 KB Output is correct
74 Correct 41 ms 908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 908 KB Output is correct
2 Correct 1 ms 908 KB Output is correct
3 Correct 1 ms 908 KB Output is correct
4 Correct 2 ms 908 KB Output is correct
5 Correct 1 ms 908 KB Output is correct
6 Correct 2 ms 908 KB Output is correct
7 Correct 1 ms 908 KB Output is correct
8 Correct 2 ms 908 KB Output is correct
9 Correct 2 ms 908 KB Output is correct
10 Correct 2 ms 908 KB Output is correct
11 Correct 1 ms 908 KB Output is correct
12 Correct 1 ms 908 KB Output is correct
13 Correct 2 ms 908 KB Output is correct
14 Correct 2 ms 908 KB Output is correct
15 Correct 2 ms 908 KB Output is correct
16 Correct 2 ms 908 KB Output is correct
17 Correct 2 ms 908 KB Output is correct
18 Correct 2 ms 908 KB Output is correct
19 Correct 1 ms 908 KB Output is correct
20 Correct 2 ms 908 KB Output is correct
21 Correct 2 ms 908 KB Output is correct
22 Correct 1 ms 908 KB Output is correct
23 Correct 3 ms 908 KB Output is correct
24 Correct 2 ms 908 KB Output is correct
25 Correct 2 ms 908 KB Output is correct
26 Correct 3 ms 908 KB Output is correct
27 Correct 3 ms 908 KB Output is correct
28 Correct 5 ms 908 KB Output is correct
29 Correct 5 ms 908 KB Output is correct
30 Correct 2 ms 908 KB Output is correct
31 Correct 5 ms 908 KB Output is correct
32 Correct 4 ms 908 KB Output is correct
33 Correct 4 ms 908 KB Output is correct
34 Correct 5 ms 908 KB Output is correct
35 Correct 5 ms 908 KB Output is correct
36 Correct 11 ms 908 KB Output is correct
37 Correct 33 ms 908 KB Output is correct
38 Correct 71 ms 908 KB Output is correct
39 Correct 68 ms 908 KB Output is correct
40 Correct 3 ms 908 KB Output is correct
41 Correct 34 ms 908 KB Output is correct
42 Correct 52 ms 908 KB Output is correct
43 Correct 5 ms 908 KB Output is correct
44 Correct 10 ms 908 KB Output is correct
45 Correct 27 ms 908 KB Output is correct
46 Correct 56 ms 908 KB Output is correct
47 Correct 55 ms 908 KB Output is correct
48 Correct 3 ms 908 KB Output is correct
49 Correct 58 ms 908 KB Output is correct
50 Correct 57 ms 908 KB Output is correct
51 Correct 2 ms 908 KB Output is correct
52 Correct 21 ms 908 KB Output is correct
53 Correct 39 ms 908 KB Output is correct
54 Correct 63 ms 908 KB Output is correct
55 Correct 66 ms 908 KB Output is correct
56 Correct 238 ms 908 KB Output is correct
57 Correct 237 ms 908 KB Output is correct
58 Correct 242 ms 908 KB Output is correct
59 Correct 225 ms 908 KB Output is correct
60 Correct 246 ms 908 KB Output is correct
61 Correct 2 ms 908 KB Output is correct
62 Correct 35 ms 908 KB Output is correct
63 Correct 62 ms 908 KB Output is correct
64 Correct 67 ms 908 KB Output is correct
65 Correct 121 ms 908 KB Output is correct
66 Correct 188 ms 908 KB Output is correct
67 Correct 229 ms 908 KB Output is correct
68 Correct 242 ms 908 KB Output is correct
69 Correct 231 ms 908 KB Output is correct