Submission #1095018

# Submission time Handle Problem Language Result Execution time Memory
1095018 2024-10-01T07:20:55 Z alexander707070 Toys (CEOI18_toy) C++14
100 / 100
1485 ms 24520 KB
#include<bits/stdc++.h>
#define MAXN 2007
using namespace std;

int n;
vector<int> dels;

vector<int> sums[MAXN][2];
unordered_map<int,int> pos;
vector<int> res;
vector<int> ans;

unordered_map<int,int> li;
int tim;

void ff(int d,int mins){
	if(mins>d){
		sums[d][mins]={dels[d]-1};
		return;
	}

	if(!sums[d][mins].empty())return;

	ff(d,mins+1);
	sums[d][mins]=sums[d][mins+1];
	
	if(dels[d]%dels[mins]==0){
		int x=pos[dels[d]/dels[mins]];
		ff(x,mins);

		tim++;
		for(int i:sums[d][mins])li[i]=tim;

		for(int i:sums[x][mins]){
			if(li[i+dels[mins]-1]==tim)continue;
			li[i+dels[mins]-1]=tim;
			
			sums[d][mins].push_back(i+dels[mins]-1);
		}
	}
}

int main(){

	cin>>n;

	if(n==1){
		cout<<1<<"\n"<<0<<"\n";
		return 0;
	}

	for(int i=1;i*i<=n;i++){
		if(n%i!=0)continue;

		dels.push_back(i);
		if(i!=n/i)dels.push_back(n/i);
	}

	sort(dels.begin(),dels.end());

	for(int i=0;i<dels.size();i++){
		pos[dels[i]]=i;
	}

	for(int mins=dels.size()-1;mins>=1;mins--){
		for(int d=0;d<dels.size();d++){

			if(mins>d){
				sums[d][mins%2]={dels[d]-1};
				continue;
			}

			sums[d][mins%2]=sums[d][1-mins%2];
			
			if(dels[d]%dels[mins]==0){
				int x=pos[dels[d]/dels[mins]];

				tim++;
				for(int i:sums[d][mins%2])li[i]=tim;

				for(int i:sums[x][mins%2]){
					if(li[i+dels[mins]-1]==tim)continue;
					li[i+dels[mins]-1]=tim;
					
					sums[d][mins%2].push_back(i+dels[mins]-1);
				}
			}	
		}
	}
	
	ans=sums[dels.size()-1][1];

	sort(ans.begin(),ans.end());

	cout<<ans.size()<<"\n";
	for(int i:ans){
		cout<<i<<" ";
	}
	cout<<"\n";

    return 0;
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:61:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |  for(int i=0;i<dels.size();i++){
      |              ~^~~~~~~~~~~~
toy.cpp:66:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |   for(int d=0;d<dels.size();d++){
      |               ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 528 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 528 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 444 KB Output is correct
33 Correct 0 ms 532 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 344 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 352 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 1 ms 356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 528 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 444 KB Output is correct
33 Correct 0 ms 532 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 344 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 352 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 1 ms 356 KB Output is correct
50 Correct 2 ms 616 KB Output is correct
51 Correct 2 ms 544 KB Output is correct
52 Correct 1 ms 616 KB Output is correct
53 Correct 1 ms 616 KB Output is correct
54 Correct 1 ms 540 KB Output is correct
55 Correct 2 ms 616 KB Output is correct
56 Correct 2 ms 612 KB Output is correct
57 Correct 1 ms 616 KB Output is correct
58 Correct 1 ms 356 KB Output is correct
59 Correct 0 ms 360 KB Output is correct
60 Correct 1 ms 360 KB Output is correct
61 Correct 1 ms 612 KB Output is correct
62 Correct 1 ms 360 KB Output is correct
63 Correct 0 ms 616 KB Output is correct
64 Correct 0 ms 360 KB Output is correct
65 Correct 1 ms 616 KB Output is correct
66 Correct 0 ms 544 KB Output is correct
67 Correct 0 ms 348 KB Output is correct
68 Correct 0 ms 348 KB Output is correct
69 Correct 1 ms 344 KB Output is correct
70 Correct 1 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 528 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 444 KB Output is correct
33 Correct 0 ms 532 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 344 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 352 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 1 ms 356 KB Output is correct
50 Correct 2 ms 616 KB Output is correct
51 Correct 2 ms 544 KB Output is correct
52 Correct 1 ms 616 KB Output is correct
53 Correct 1 ms 616 KB Output is correct
54 Correct 1 ms 540 KB Output is correct
55 Correct 2 ms 616 KB Output is correct
56 Correct 2 ms 612 KB Output is correct
57 Correct 1 ms 616 KB Output is correct
58 Correct 1 ms 356 KB Output is correct
59 Correct 0 ms 360 KB Output is correct
60 Correct 1 ms 360 KB Output is correct
61 Correct 1 ms 612 KB Output is correct
62 Correct 1 ms 360 KB Output is correct
63 Correct 0 ms 616 KB Output is correct
64 Correct 0 ms 360 KB Output is correct
65 Correct 1 ms 616 KB Output is correct
66 Correct 0 ms 544 KB Output is correct
67 Correct 0 ms 348 KB Output is correct
68 Correct 0 ms 348 KB Output is correct
69 Correct 1 ms 344 KB Output is correct
70 Correct 1 ms 600 KB Output is correct
71 Correct 180 ms 6328 KB Output is correct
72 Correct 149 ms 5040 KB Output is correct
73 Correct 161 ms 5772 KB Output is correct
74 Correct 100 ms 4432 KB Output is correct
75 Correct 115 ms 4280 KB Output is correct
76 Correct 262 ms 7564 KB Output is correct
77 Correct 199 ms 7080 KB Output is correct
78 Correct 218 ms 6820 KB Output is correct
79 Correct 179 ms 6316 KB Output is correct
80 Correct 0 ms 348 KB Output is correct
81 Correct 0 ms 532 KB Output is correct
82 Correct 1 ms 604 KB Output is correct
83 Correct 14 ms 1628 KB Output is correct
84 Correct 19 ms 1968 KB Output is correct
85 Correct 4 ms 1116 KB Output is correct
86 Correct 0 ms 348 KB Output is correct
87 Correct 20 ms 2188 KB Output is correct
88 Correct 0 ms 344 KB Output is correct
89 Correct 1 ms 348 KB Output is correct
90 Correct 1 ms 348 KB Output is correct
91 Correct 9 ms 1420 KB Output is correct
92 Correct 66 ms 3128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 528 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 444 KB Output is correct
33 Correct 0 ms 532 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 344 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 352 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 1 ms 356 KB Output is correct
50 Correct 2 ms 616 KB Output is correct
51 Correct 2 ms 544 KB Output is correct
52 Correct 1 ms 616 KB Output is correct
53 Correct 1 ms 616 KB Output is correct
54 Correct 1 ms 540 KB Output is correct
55 Correct 2 ms 616 KB Output is correct
56 Correct 2 ms 612 KB Output is correct
57 Correct 1 ms 616 KB Output is correct
58 Correct 1 ms 356 KB Output is correct
59 Correct 0 ms 360 KB Output is correct
60 Correct 1 ms 360 KB Output is correct
61 Correct 1 ms 612 KB Output is correct
62 Correct 1 ms 360 KB Output is correct
63 Correct 0 ms 616 KB Output is correct
64 Correct 0 ms 360 KB Output is correct
65 Correct 1 ms 616 KB Output is correct
66 Correct 0 ms 544 KB Output is correct
67 Correct 0 ms 348 KB Output is correct
68 Correct 0 ms 348 KB Output is correct
69 Correct 1 ms 344 KB Output is correct
70 Correct 1 ms 600 KB Output is correct
71 Correct 180 ms 6328 KB Output is correct
72 Correct 149 ms 5040 KB Output is correct
73 Correct 161 ms 5772 KB Output is correct
74 Correct 100 ms 4432 KB Output is correct
75 Correct 115 ms 4280 KB Output is correct
76 Correct 262 ms 7564 KB Output is correct
77 Correct 199 ms 7080 KB Output is correct
78 Correct 218 ms 6820 KB Output is correct
79 Correct 179 ms 6316 KB Output is correct
80 Correct 0 ms 348 KB Output is correct
81 Correct 0 ms 532 KB Output is correct
82 Correct 1 ms 604 KB Output is correct
83 Correct 14 ms 1628 KB Output is correct
84 Correct 19 ms 1968 KB Output is correct
85 Correct 4 ms 1116 KB Output is correct
86 Correct 0 ms 348 KB Output is correct
87 Correct 20 ms 2188 KB Output is correct
88 Correct 0 ms 344 KB Output is correct
89 Correct 1 ms 348 KB Output is correct
90 Correct 1 ms 348 KB Output is correct
91 Correct 9 ms 1420 KB Output is correct
92 Correct 66 ms 3128 KB Output is correct
93 Correct 1264 ms 22076 KB Output is correct
94 Correct 897 ms 16260 KB Output is correct
95 Correct 891 ms 16960 KB Output is correct
96 Correct 742 ms 14176 KB Output is correct
97 Correct 583 ms 13168 KB Output is correct
98 Correct 1362 ms 24012 KB Output is correct
99 Correct 1485 ms 24520 KB Output is correct
100 Correct 1280 ms 24520 KB Output is correct
101 Correct 1107 ms 22212 KB Output is correct
102 Correct 941 ms 19912 KB Output is correct
103 Correct 884 ms 19136 KB Output is correct
104 Correct 1 ms 344 KB Output is correct
105 Correct 1 ms 348 KB Output is correct
106 Correct 2 ms 604 KB Output is correct
107 Correct 38 ms 3760 KB Output is correct
108 Correct 158 ms 7248 KB Output is correct
109 Correct 9 ms 1628 KB Output is correct
110 Correct 0 ms 348 KB Output is correct
111 Correct 65 ms 4612 KB Output is correct
112 Correct 0 ms 348 KB Output is correct
113 Correct 0 ms 348 KB Output is correct
114 Correct 4 ms 860 KB Output is correct
115 Correct 0 ms 348 KB Output is correct
116 Correct 8 ms 1372 KB Output is correct
117 Correct 352 ms 8800 KB Output is correct