Submission #164779

# Submission time Handle Problem Language Result Execution time Memory
164779 2019-11-23T10:47:33 Z mosiashvililuka Bootfall (IZhO17_bootfall) C++14
44 / 100
1000 ms 5848 KB
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,f[509],p[509],pi,jm,pas[250009],pa;
bitset <250007> dp[177];
set <int> s;
set <int>::iterator it;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a;
	for(c=1; c<=a; c++) cin>>f[c];
	if(a==1){
		cout<<0;
		return 0;
	}
	for(c=1; c<=a; c++){
		s.insert(f[c]);
	}
	for(it=s.begin(); it!=s.end(); it++){
		pi++;
		p[pi]=(*it);
	}
	d=0;
	for(c=1; c<=a; c++) d+=f[c];
	e=d;
	jm=e;
	for(c=2; c<=a; c++){
		if(f[c]%2!=f[c-1]%2){
			cout<<0;
			return 0;
		}
	}
/*	for(c=1; c<=pi; c++) cout<<p[c]<<" ";
	cout<<endl<<endl;*/
	for(c=1; c<=pi+1; c++){
//	    cout<<jm<<endl;
	    dp[c][0]=1;
	    e=0;
		for(d=1; d<=a; d++){
    		if(f[d]==p[c]&&e==0){
			   e=1;
			   continue;
			}
			//if(c==1) cout<<d<<" ";
			dp[c]=dp[c]|(dp[c]<<f[d]);
		}
		dp[c][0]=0;
//		dp[c][jm-p[c]]=0;
	}
//	cout<<dp[1][400]<<endl;
/*	cout<<endl;
	for(c=1; c<=14; c++){
	    cout<<c<<" "<<dp[1][c]<<endl;
	}*/
//	cout<<dp[4][5]<<endl;
	if(f[1]%2==0) d=2; else d=1;
	for(c=d; c<=jm; c+=2){
		pi++;p[pi]=c;
		jm+=c;
		e=0;
		for(d=1; d<=pi; d++){
			if(d==pi){
			if((jm-p[d])%2==1||dp[pi][(jm-p[d])/2]==0){
//			    if(c==600) cout<<jm<<" "<<p[d]<<" "<<d<<endl;
//			    if(c==3) cout<<jm<<" "<<p[d]<<" "<<d<<endl;
				e=1;break;
			}
			}else{
			if((jm-p[d])%2==1||dp[d][(jm-p[d])/2]==0){
//			    if(c==600) cout<<jm<<" "<<p[d]<<" "<<d<<endl;
//			    if(c==3) cout<<jm<<" "<<p[d]<<" "<<d<<endl;
				e=1;break;
			}
			}
		}
		if(e==0){
			pa++;
			pas[pa]=c;
		}
		jm-=c;
		pi--;
	}
	cout<<pa<<endl;
	for(c=1; c<=pa; c++) cout<<pas[c]<<" ";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 632 KB Output is correct
2 Correct 3 ms 632 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 5 ms 764 KB Output is correct
6 Correct 3 ms 632 KB Output is correct
7 Correct 3 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 632 KB Output is correct
2 Correct 3 ms 632 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 5 ms 764 KB Output is correct
6 Correct 3 ms 632 KB Output is correct
7 Correct 3 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 9 ms 760 KB Output is correct
12 Correct 8 ms 760 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 8 ms 760 KB Output is correct
15 Correct 7 ms 764 KB Output is correct
16 Correct 8 ms 760 KB Output is correct
17 Correct 5 ms 760 KB Output is correct
18 Correct 6 ms 760 KB Output is correct
19 Correct 7 ms 760 KB Output is correct
20 Correct 3 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 632 KB Output is correct
2 Correct 3 ms 632 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 5 ms 764 KB Output is correct
6 Correct 3 ms 632 KB Output is correct
7 Correct 3 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 9 ms 760 KB Output is correct
12 Correct 8 ms 760 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 8 ms 760 KB Output is correct
15 Correct 7 ms 764 KB Output is correct
16 Correct 8 ms 760 KB Output is correct
17 Correct 5 ms 760 KB Output is correct
18 Correct 6 ms 760 KB Output is correct
19 Correct 7 ms 760 KB Output is correct
20 Correct 3 ms 504 KB Output is correct
21 Correct 44 ms 1528 KB Output is correct
22 Correct 54 ms 1656 KB Output is correct
23 Correct 32 ms 1272 KB Output is correct
24 Correct 74 ms 1832 KB Output is correct
25 Correct 14 ms 632 KB Output is correct
26 Correct 15 ms 760 KB Output is correct
27 Correct 15 ms 636 KB Output is correct
28 Correct 9 ms 624 KB Output is correct
29 Correct 9 ms 632 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 49 ms 1240 KB Output is correct
32 Correct 83 ms 1912 KB Output is correct
33 Correct 6 ms 504 KB Output is correct
34 Correct 6 ms 504 KB Output is correct
35 Correct 9 ms 660 KB Output is correct
36 Correct 93 ms 2096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 632 KB Output is correct
2 Correct 3 ms 632 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 5 ms 764 KB Output is correct
6 Correct 3 ms 632 KB Output is correct
7 Correct 3 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 9 ms 760 KB Output is correct
12 Correct 8 ms 760 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 8 ms 760 KB Output is correct
15 Correct 7 ms 764 KB Output is correct
16 Correct 8 ms 760 KB Output is correct
17 Correct 5 ms 760 KB Output is correct
18 Correct 6 ms 760 KB Output is correct
19 Correct 7 ms 760 KB Output is correct
20 Correct 3 ms 504 KB Output is correct
21 Correct 44 ms 1528 KB Output is correct
22 Correct 54 ms 1656 KB Output is correct
23 Correct 32 ms 1272 KB Output is correct
24 Correct 74 ms 1832 KB Output is correct
25 Correct 14 ms 632 KB Output is correct
26 Correct 15 ms 760 KB Output is correct
27 Correct 15 ms 636 KB Output is correct
28 Correct 9 ms 624 KB Output is correct
29 Correct 9 ms 632 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 49 ms 1240 KB Output is correct
32 Correct 83 ms 1912 KB Output is correct
33 Correct 6 ms 504 KB Output is correct
34 Correct 6 ms 504 KB Output is correct
35 Correct 9 ms 660 KB Output is correct
36 Correct 93 ms 2096 KB Output is correct
37 Correct 176 ms 2112 KB Output is correct
38 Correct 190 ms 2168 KB Output is correct
39 Correct 11 ms 504 KB Output is correct
40 Correct 654 ms 4928 KB Output is correct
41 Correct 12 ms 680 KB Output is correct
42 Correct 513 ms 4136 KB Output is correct
43 Correct 120 ms 1528 KB Output is correct
44 Correct 121 ms 1452 KB Output is correct
45 Correct 122 ms 1500 KB Output is correct
46 Correct 665 ms 4728 KB Output is correct
47 Correct 497 ms 3964 KB Output is correct
48 Correct 31 ms 888 KB Output is correct
49 Correct 22 ms 632 KB Output is correct
50 Correct 569 ms 4596 KB Output is correct
51 Correct 2 ms 376 KB Output is correct
52 Correct 63 ms 1144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 632 KB Output is correct
2 Correct 3 ms 632 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 5 ms 764 KB Output is correct
6 Correct 3 ms 632 KB Output is correct
7 Correct 3 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 9 ms 760 KB Output is correct
12 Correct 8 ms 760 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 8 ms 760 KB Output is correct
15 Correct 7 ms 764 KB Output is correct
16 Correct 8 ms 760 KB Output is correct
17 Correct 5 ms 760 KB Output is correct
18 Correct 6 ms 760 KB Output is correct
19 Correct 7 ms 760 KB Output is correct
20 Correct 3 ms 504 KB Output is correct
21 Correct 44 ms 1528 KB Output is correct
22 Correct 54 ms 1656 KB Output is correct
23 Correct 32 ms 1272 KB Output is correct
24 Correct 74 ms 1832 KB Output is correct
25 Correct 14 ms 632 KB Output is correct
26 Correct 15 ms 760 KB Output is correct
27 Correct 15 ms 636 KB Output is correct
28 Correct 9 ms 624 KB Output is correct
29 Correct 9 ms 632 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 49 ms 1240 KB Output is correct
32 Correct 83 ms 1912 KB Output is correct
33 Correct 6 ms 504 KB Output is correct
34 Correct 6 ms 504 KB Output is correct
35 Correct 9 ms 660 KB Output is correct
36 Correct 93 ms 2096 KB Output is correct
37 Correct 176 ms 2112 KB Output is correct
38 Correct 190 ms 2168 KB Output is correct
39 Correct 11 ms 504 KB Output is correct
40 Correct 654 ms 4928 KB Output is correct
41 Correct 12 ms 680 KB Output is correct
42 Correct 513 ms 4136 KB Output is correct
43 Correct 120 ms 1528 KB Output is correct
44 Correct 121 ms 1452 KB Output is correct
45 Correct 122 ms 1500 KB Output is correct
46 Correct 665 ms 4728 KB Output is correct
47 Correct 497 ms 3964 KB Output is correct
48 Correct 31 ms 888 KB Output is correct
49 Correct 22 ms 632 KB Output is correct
50 Correct 569 ms 4596 KB Output is correct
51 Correct 2 ms 376 KB Output is correct
52 Correct 63 ms 1144 KB Output is correct
53 Correct 642 ms 4292 KB Output is correct
54 Correct 757 ms 4444 KB Output is correct
55 Correct 96 ms 1528 KB Output is correct
56 Correct 743 ms 4856 KB Output is correct
57 Correct 120 ms 1460 KB Output is correct
58 Execution timed out 1081 ms 5848 KB Time limit exceeded
59 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 632 KB Output is correct
2 Correct 3 ms 632 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 5 ms 764 KB Output is correct
6 Correct 3 ms 632 KB Output is correct
7 Correct 3 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 9 ms 760 KB Output is correct
12 Correct 8 ms 760 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 8 ms 760 KB Output is correct
15 Correct 7 ms 764 KB Output is correct
16 Correct 8 ms 760 KB Output is correct
17 Correct 5 ms 760 KB Output is correct
18 Correct 6 ms 760 KB Output is correct
19 Correct 7 ms 760 KB Output is correct
20 Correct 3 ms 504 KB Output is correct
21 Correct 44 ms 1528 KB Output is correct
22 Correct 54 ms 1656 KB Output is correct
23 Correct 32 ms 1272 KB Output is correct
24 Correct 74 ms 1832 KB Output is correct
25 Correct 14 ms 632 KB Output is correct
26 Correct 15 ms 760 KB Output is correct
27 Correct 15 ms 636 KB Output is correct
28 Correct 9 ms 624 KB Output is correct
29 Correct 9 ms 632 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 49 ms 1240 KB Output is correct
32 Correct 83 ms 1912 KB Output is correct
33 Correct 6 ms 504 KB Output is correct
34 Correct 6 ms 504 KB Output is correct
35 Correct 9 ms 660 KB Output is correct
36 Correct 93 ms 2096 KB Output is correct
37 Correct 176 ms 2112 KB Output is correct
38 Correct 190 ms 2168 KB Output is correct
39 Correct 11 ms 504 KB Output is correct
40 Correct 654 ms 4928 KB Output is correct
41 Correct 12 ms 680 KB Output is correct
42 Correct 513 ms 4136 KB Output is correct
43 Correct 120 ms 1528 KB Output is correct
44 Correct 121 ms 1452 KB Output is correct
45 Correct 122 ms 1500 KB Output is correct
46 Correct 665 ms 4728 KB Output is correct
47 Correct 497 ms 3964 KB Output is correct
48 Correct 31 ms 888 KB Output is correct
49 Correct 22 ms 632 KB Output is correct
50 Correct 569 ms 4596 KB Output is correct
51 Correct 2 ms 376 KB Output is correct
52 Correct 63 ms 1144 KB Output is correct
53 Correct 642 ms 4292 KB Output is correct
54 Correct 757 ms 4444 KB Output is correct
55 Correct 96 ms 1528 KB Output is correct
56 Correct 743 ms 4856 KB Output is correct
57 Correct 120 ms 1460 KB Output is correct
58 Execution timed out 1081 ms 5848 KB Time limit exceeded
59 Halted 0 ms 0 KB -