Submission #1095007

# Submission time Handle Problem Language Result Execution time Memory
1095007 2024-10-01T07:11:33 Z alexander707070 Toys (CEOI18_toy) C++14
79 / 100
422 ms 262144 KB
#include<bits/stdc++.h>
#define MAXN 2007
using namespace std;

int n;
vector<int> dels;

vector<int> sums[MAXN][MAXN];
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;

	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;
	}
	
	ff(dels.size()-1,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:56:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |  for(int i=0;i<dels.size();i++){
      |              ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 43 ms 94812 KB Output is correct
2 Correct 50 ms 94804 KB Output is correct
3 Correct 43 ms 94812 KB Output is correct
4 Correct 43 ms 94812 KB Output is correct
5 Correct 42 ms 94800 KB Output is correct
6 Correct 39 ms 94804 KB Output is correct
7 Correct 39 ms 94804 KB Output is correct
8 Correct 42 ms 94804 KB Output is correct
9 Correct 42 ms 94808 KB Output is correct
10 Correct 40 ms 94952 KB Output is correct
11 Correct 41 ms 94800 KB Output is correct
12 Correct 38 ms 94808 KB Output is correct
13 Correct 45 ms 94800 KB Output is correct
14 Correct 41 ms 94804 KB Output is correct
15 Correct 37 ms 94876 KB Output is correct
16 Correct 37 ms 94960 KB Output is correct
17 Correct 36 ms 94808 KB Output is correct
18 Correct 40 ms 94800 KB Output is correct
19 Correct 47 ms 95008 KB Output is correct
20 Correct 37 ms 94800 KB Output is correct
21 Correct 41 ms 94808 KB Output is correct
22 Correct 41 ms 94808 KB Output is correct
23 Correct 39 ms 94812 KB Output is correct
24 Correct 42 ms 94800 KB Output is correct
25 Correct 38 ms 94804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 94812 KB Output is correct
2 Correct 50 ms 94804 KB Output is correct
3 Correct 43 ms 94812 KB Output is correct
4 Correct 43 ms 94812 KB Output is correct
5 Correct 42 ms 94800 KB Output is correct
6 Correct 39 ms 94804 KB Output is correct
7 Correct 39 ms 94804 KB Output is correct
8 Correct 42 ms 94804 KB Output is correct
9 Correct 42 ms 94808 KB Output is correct
10 Correct 40 ms 94952 KB Output is correct
11 Correct 41 ms 94800 KB Output is correct
12 Correct 38 ms 94808 KB Output is correct
13 Correct 45 ms 94800 KB Output is correct
14 Correct 41 ms 94804 KB Output is correct
15 Correct 37 ms 94876 KB Output is correct
16 Correct 37 ms 94960 KB Output is correct
17 Correct 36 ms 94808 KB Output is correct
18 Correct 40 ms 94800 KB Output is correct
19 Correct 47 ms 95008 KB Output is correct
20 Correct 37 ms 94800 KB Output is correct
21 Correct 41 ms 94808 KB Output is correct
22 Correct 41 ms 94808 KB Output is correct
23 Correct 39 ms 94812 KB Output is correct
24 Correct 42 ms 94800 KB Output is correct
25 Correct 38 ms 94804 KB Output is correct
26 Correct 37 ms 95068 KB Output is correct
27 Correct 37 ms 95068 KB Output is correct
28 Correct 39 ms 95068 KB Output is correct
29 Correct 36 ms 95068 KB Output is correct
30 Correct 35 ms 94804 KB Output is correct
31 Correct 35 ms 95180 KB Output is correct
32 Correct 56 ms 95060 KB Output is correct
33 Correct 35 ms 94936 KB Output is correct
34 Correct 33 ms 94804 KB Output is correct
35 Correct 55 ms 94804 KB Output is correct
36 Correct 36 ms 94804 KB Output is correct
37 Correct 33 ms 95064 KB Output is correct
38 Correct 33 ms 94804 KB Output is correct
39 Correct 35 ms 94812 KB Output is correct
40 Correct 39 ms 95056 KB Output is correct
41 Correct 36 ms 94784 KB Output is correct
42 Correct 44 ms 95004 KB Output is correct
43 Correct 38 ms 95004 KB Output is correct
44 Correct 39 ms 94828 KB Output is correct
45 Correct 40 ms 94940 KB Output is correct
46 Correct 36 ms 94768 KB Output is correct
47 Correct 35 ms 95060 KB Output is correct
48 Correct 37 ms 94804 KB Output is correct
49 Correct 58 ms 94800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 94812 KB Output is correct
2 Correct 50 ms 94804 KB Output is correct
3 Correct 43 ms 94812 KB Output is correct
4 Correct 43 ms 94812 KB Output is correct
5 Correct 42 ms 94800 KB Output is correct
6 Correct 39 ms 94804 KB Output is correct
7 Correct 39 ms 94804 KB Output is correct
8 Correct 42 ms 94804 KB Output is correct
9 Correct 42 ms 94808 KB Output is correct
10 Correct 40 ms 94952 KB Output is correct
11 Correct 41 ms 94800 KB Output is correct
12 Correct 38 ms 94808 KB Output is correct
13 Correct 45 ms 94800 KB Output is correct
14 Correct 41 ms 94804 KB Output is correct
15 Correct 37 ms 94876 KB Output is correct
16 Correct 37 ms 94960 KB Output is correct
17 Correct 36 ms 94808 KB Output is correct
18 Correct 40 ms 94800 KB Output is correct
19 Correct 47 ms 95008 KB Output is correct
20 Correct 37 ms 94800 KB Output is correct
21 Correct 41 ms 94808 KB Output is correct
22 Correct 41 ms 94808 KB Output is correct
23 Correct 39 ms 94812 KB Output is correct
24 Correct 42 ms 94800 KB Output is correct
25 Correct 38 ms 94804 KB Output is correct
26 Correct 37 ms 95068 KB Output is correct
27 Correct 37 ms 95068 KB Output is correct
28 Correct 39 ms 95068 KB Output is correct
29 Correct 36 ms 95068 KB Output is correct
30 Correct 35 ms 94804 KB Output is correct
31 Correct 35 ms 95180 KB Output is correct
32 Correct 56 ms 95060 KB Output is correct
33 Correct 35 ms 94936 KB Output is correct
34 Correct 33 ms 94804 KB Output is correct
35 Correct 55 ms 94804 KB Output is correct
36 Correct 36 ms 94804 KB Output is correct
37 Correct 33 ms 95064 KB Output is correct
38 Correct 33 ms 94804 KB Output is correct
39 Correct 35 ms 94812 KB Output is correct
40 Correct 39 ms 95056 KB Output is correct
41 Correct 36 ms 94784 KB Output is correct
42 Correct 44 ms 95004 KB Output is correct
43 Correct 38 ms 95004 KB Output is correct
44 Correct 39 ms 94828 KB Output is correct
45 Correct 40 ms 94940 KB Output is correct
46 Correct 36 ms 94768 KB Output is correct
47 Correct 35 ms 95060 KB Output is correct
48 Correct 37 ms 94804 KB Output is correct
49 Correct 58 ms 94800 KB Output is correct
50 Correct 37 ms 95828 KB Output is correct
51 Correct 42 ms 95580 KB Output is correct
52 Correct 39 ms 95572 KB Output is correct
53 Correct 43 ms 95568 KB Output is correct
54 Correct 40 ms 95316 KB Output is correct
55 Correct 39 ms 95836 KB Output is correct
56 Correct 39 ms 95580 KB Output is correct
57 Correct 43 ms 95836 KB Output is correct
58 Correct 39 ms 94804 KB Output is correct
59 Correct 37 ms 94804 KB Output is correct
60 Correct 48 ms 94808 KB Output is correct
61 Correct 44 ms 95316 KB Output is correct
62 Correct 39 ms 95060 KB Output is correct
63 Correct 42 ms 95076 KB Output is correct
64 Correct 43 ms 94996 KB Output is correct
65 Correct 40 ms 95204 KB Output is correct
66 Correct 39 ms 94800 KB Output is correct
67 Correct 39 ms 94804 KB Output is correct
68 Correct 42 ms 94920 KB Output is correct
69 Correct 37 ms 95056 KB Output is correct
70 Correct 37 ms 95212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 94812 KB Output is correct
2 Correct 50 ms 94804 KB Output is correct
3 Correct 43 ms 94812 KB Output is correct
4 Correct 43 ms 94812 KB Output is correct
5 Correct 42 ms 94800 KB Output is correct
6 Correct 39 ms 94804 KB Output is correct
7 Correct 39 ms 94804 KB Output is correct
8 Correct 42 ms 94804 KB Output is correct
9 Correct 42 ms 94808 KB Output is correct
10 Correct 40 ms 94952 KB Output is correct
11 Correct 41 ms 94800 KB Output is correct
12 Correct 38 ms 94808 KB Output is correct
13 Correct 45 ms 94800 KB Output is correct
14 Correct 41 ms 94804 KB Output is correct
15 Correct 37 ms 94876 KB Output is correct
16 Correct 37 ms 94960 KB Output is correct
17 Correct 36 ms 94808 KB Output is correct
18 Correct 40 ms 94800 KB Output is correct
19 Correct 47 ms 95008 KB Output is correct
20 Correct 37 ms 94800 KB Output is correct
21 Correct 41 ms 94808 KB Output is correct
22 Correct 41 ms 94808 KB Output is correct
23 Correct 39 ms 94812 KB Output is correct
24 Correct 42 ms 94800 KB Output is correct
25 Correct 38 ms 94804 KB Output is correct
26 Correct 37 ms 95068 KB Output is correct
27 Correct 37 ms 95068 KB Output is correct
28 Correct 39 ms 95068 KB Output is correct
29 Correct 36 ms 95068 KB Output is correct
30 Correct 35 ms 94804 KB Output is correct
31 Correct 35 ms 95180 KB Output is correct
32 Correct 56 ms 95060 KB Output is correct
33 Correct 35 ms 94936 KB Output is correct
34 Correct 33 ms 94804 KB Output is correct
35 Correct 55 ms 94804 KB Output is correct
36 Correct 36 ms 94804 KB Output is correct
37 Correct 33 ms 95064 KB Output is correct
38 Correct 33 ms 94804 KB Output is correct
39 Correct 35 ms 94812 KB Output is correct
40 Correct 39 ms 95056 KB Output is correct
41 Correct 36 ms 94784 KB Output is correct
42 Correct 44 ms 95004 KB Output is correct
43 Correct 38 ms 95004 KB Output is correct
44 Correct 39 ms 94828 KB Output is correct
45 Correct 40 ms 94940 KB Output is correct
46 Correct 36 ms 94768 KB Output is correct
47 Correct 35 ms 95060 KB Output is correct
48 Correct 37 ms 94804 KB Output is correct
49 Correct 58 ms 94800 KB Output is correct
50 Correct 37 ms 95828 KB Output is correct
51 Correct 42 ms 95580 KB Output is correct
52 Correct 39 ms 95572 KB Output is correct
53 Correct 43 ms 95568 KB Output is correct
54 Correct 40 ms 95316 KB Output is correct
55 Correct 39 ms 95836 KB Output is correct
56 Correct 39 ms 95580 KB Output is correct
57 Correct 43 ms 95836 KB Output is correct
58 Correct 39 ms 94804 KB Output is correct
59 Correct 37 ms 94804 KB Output is correct
60 Correct 48 ms 94808 KB Output is correct
61 Correct 44 ms 95316 KB Output is correct
62 Correct 39 ms 95060 KB Output is correct
63 Correct 42 ms 95076 KB Output is correct
64 Correct 43 ms 94996 KB Output is correct
65 Correct 40 ms 95204 KB Output is correct
66 Correct 39 ms 94800 KB Output is correct
67 Correct 39 ms 94804 KB Output is correct
68 Correct 42 ms 94920 KB Output is correct
69 Correct 37 ms 95056 KB Output is correct
70 Correct 37 ms 95212 KB Output is correct
71 Correct 294 ms 194988 KB Output is correct
72 Correct 226 ms 172720 KB Output is correct
73 Correct 245 ms 178092 KB Output is correct
74 Correct 174 ms 152492 KB Output is correct
75 Correct 189 ms 153336 KB Output is correct
76 Correct 422 ms 222448 KB Output is correct
77 Correct 316 ms 185836 KB Output is correct
78 Correct 337 ms 190640 KB Output is correct
79 Correct 296 ms 181936 KB Output is correct
80 Correct 38 ms 94812 KB Output is correct
81 Correct 41 ms 94900 KB Output is correct
82 Correct 50 ms 95056 KB Output is correct
83 Correct 57 ms 99156 KB Output is correct
84 Correct 68 ms 104480 KB Output is correct
85 Correct 49 ms 96080 KB Output is correct
86 Correct 40 ms 95064 KB Output is correct
87 Correct 68 ms 103616 KB Output is correct
88 Correct 37 ms 94812 KB Output is correct
89 Correct 37 ms 94800 KB Output is correct
90 Correct 37 ms 95064 KB Output is correct
91 Correct 59 ms 99900 KB Output is correct
92 Correct 113 ms 129964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 94812 KB Output is correct
2 Correct 50 ms 94804 KB Output is correct
3 Correct 43 ms 94812 KB Output is correct
4 Correct 43 ms 94812 KB Output is correct
5 Correct 42 ms 94800 KB Output is correct
6 Correct 39 ms 94804 KB Output is correct
7 Correct 39 ms 94804 KB Output is correct
8 Correct 42 ms 94804 KB Output is correct
9 Correct 42 ms 94808 KB Output is correct
10 Correct 40 ms 94952 KB Output is correct
11 Correct 41 ms 94800 KB Output is correct
12 Correct 38 ms 94808 KB Output is correct
13 Correct 45 ms 94800 KB Output is correct
14 Correct 41 ms 94804 KB Output is correct
15 Correct 37 ms 94876 KB Output is correct
16 Correct 37 ms 94960 KB Output is correct
17 Correct 36 ms 94808 KB Output is correct
18 Correct 40 ms 94800 KB Output is correct
19 Correct 47 ms 95008 KB Output is correct
20 Correct 37 ms 94800 KB Output is correct
21 Correct 41 ms 94808 KB Output is correct
22 Correct 41 ms 94808 KB Output is correct
23 Correct 39 ms 94812 KB Output is correct
24 Correct 42 ms 94800 KB Output is correct
25 Correct 38 ms 94804 KB Output is correct
26 Correct 37 ms 95068 KB Output is correct
27 Correct 37 ms 95068 KB Output is correct
28 Correct 39 ms 95068 KB Output is correct
29 Correct 36 ms 95068 KB Output is correct
30 Correct 35 ms 94804 KB Output is correct
31 Correct 35 ms 95180 KB Output is correct
32 Correct 56 ms 95060 KB Output is correct
33 Correct 35 ms 94936 KB Output is correct
34 Correct 33 ms 94804 KB Output is correct
35 Correct 55 ms 94804 KB Output is correct
36 Correct 36 ms 94804 KB Output is correct
37 Correct 33 ms 95064 KB Output is correct
38 Correct 33 ms 94804 KB Output is correct
39 Correct 35 ms 94812 KB Output is correct
40 Correct 39 ms 95056 KB Output is correct
41 Correct 36 ms 94784 KB Output is correct
42 Correct 44 ms 95004 KB Output is correct
43 Correct 38 ms 95004 KB Output is correct
44 Correct 39 ms 94828 KB Output is correct
45 Correct 40 ms 94940 KB Output is correct
46 Correct 36 ms 94768 KB Output is correct
47 Correct 35 ms 95060 KB Output is correct
48 Correct 37 ms 94804 KB Output is correct
49 Correct 58 ms 94800 KB Output is correct
50 Correct 37 ms 95828 KB Output is correct
51 Correct 42 ms 95580 KB Output is correct
52 Correct 39 ms 95572 KB Output is correct
53 Correct 43 ms 95568 KB Output is correct
54 Correct 40 ms 95316 KB Output is correct
55 Correct 39 ms 95836 KB Output is correct
56 Correct 39 ms 95580 KB Output is correct
57 Correct 43 ms 95836 KB Output is correct
58 Correct 39 ms 94804 KB Output is correct
59 Correct 37 ms 94804 KB Output is correct
60 Correct 48 ms 94808 KB Output is correct
61 Correct 44 ms 95316 KB Output is correct
62 Correct 39 ms 95060 KB Output is correct
63 Correct 42 ms 95076 KB Output is correct
64 Correct 43 ms 94996 KB Output is correct
65 Correct 40 ms 95204 KB Output is correct
66 Correct 39 ms 94800 KB Output is correct
67 Correct 39 ms 94804 KB Output is correct
68 Correct 42 ms 94920 KB Output is correct
69 Correct 37 ms 95056 KB Output is correct
70 Correct 37 ms 95212 KB Output is correct
71 Correct 294 ms 194988 KB Output is correct
72 Correct 226 ms 172720 KB Output is correct
73 Correct 245 ms 178092 KB Output is correct
74 Correct 174 ms 152492 KB Output is correct
75 Correct 189 ms 153336 KB Output is correct
76 Correct 422 ms 222448 KB Output is correct
77 Correct 316 ms 185836 KB Output is correct
78 Correct 337 ms 190640 KB Output is correct
79 Correct 296 ms 181936 KB Output is correct
80 Correct 38 ms 94812 KB Output is correct
81 Correct 41 ms 94900 KB Output is correct
82 Correct 50 ms 95056 KB Output is correct
83 Correct 57 ms 99156 KB Output is correct
84 Correct 68 ms 104480 KB Output is correct
85 Correct 49 ms 96080 KB Output is correct
86 Correct 40 ms 95064 KB Output is correct
87 Correct 68 ms 103616 KB Output is correct
88 Correct 37 ms 94812 KB Output is correct
89 Correct 37 ms 94800 KB Output is correct
90 Correct 37 ms 95064 KB Output is correct
91 Correct 59 ms 99900 KB Output is correct
92 Correct 113 ms 129964 KB Output is correct
93 Runtime error 378 ms 262144 KB Execution killed with signal 9
94 Halted 0 ms 0 KB -