Submission #426306

# Submission time Handle Problem Language Result Execution time Memory
426306 2021-06-13T17:16:55 Z fskarica Toys (CEOI18_toy) C++14
100 / 100
1347 ms 114496 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define fi first
#define se second

const int MAX = 2e5 + 10;
int n;
vector <int> v;
vector <int> dp[MAX];
map <int, int> mp;

int main() {
    cin >> n;

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

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

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


    for (int i = 0; i < v.size(); i++) {
        mp[v[i]] = i + 1;
    }

    dp[1] = {0};

    int id = 0;
    for (auto e : v) {
        id++;

        int id2 = 0;
        for (auto e2 : v) {
            id2++;

            if (id < id2) break;
            if (e % e2 != 0) continue;

            for (auto e3 : dp[mp[e / e2]]) {
                dp[id].push_back(e3 + e2 - 1);
            }
        }

        sort(dp[id].begin(), dp[id].end());
        dp[id].erase(unique(dp[id].begin(), dp[id].end()), dp[id].end());
    }

    cout << dp[v.size()].size() << endl;
    for (auto e : dp[v.size()]) {
        cout << e << " ";
    }
    cout << "\n";

    return 0;
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:27:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for (int i = 0; i < v.size(); i++) {
      |                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4940 KB Output is correct
2 Correct 4 ms 4940 KB Output is correct
3 Correct 4 ms 4940 KB Output is correct
4 Correct 4 ms 4996 KB Output is correct
5 Correct 4 ms 4940 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 5 ms 4940 KB Output is correct
8 Correct 4 ms 4992 KB Output is correct
9 Correct 4 ms 4940 KB Output is correct
10 Correct 5 ms 4940 KB Output is correct
11 Correct 4 ms 4952 KB Output is correct
12 Correct 4 ms 4992 KB Output is correct
13 Correct 4 ms 4940 KB Output is correct
14 Correct 5 ms 4940 KB Output is correct
15 Correct 5 ms 4876 KB Output is correct
16 Correct 4 ms 4992 KB Output is correct
17 Correct 4 ms 4996 KB Output is correct
18 Correct 4 ms 4940 KB Output is correct
19 Correct 4 ms 5068 KB Output is correct
20 Correct 5 ms 4940 KB Output is correct
21 Correct 4 ms 4940 KB Output is correct
22 Correct 4 ms 4940 KB Output is correct
23 Correct 4 ms 4996 KB Output is correct
24 Correct 4 ms 4940 KB Output is correct
25 Correct 4 ms 4940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4940 KB Output is correct
2 Correct 4 ms 4940 KB Output is correct
3 Correct 4 ms 4940 KB Output is correct
4 Correct 4 ms 4996 KB Output is correct
5 Correct 4 ms 4940 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 5 ms 4940 KB Output is correct
8 Correct 4 ms 4992 KB Output is correct
9 Correct 4 ms 4940 KB Output is correct
10 Correct 5 ms 4940 KB Output is correct
11 Correct 4 ms 4952 KB Output is correct
12 Correct 4 ms 4992 KB Output is correct
13 Correct 4 ms 4940 KB Output is correct
14 Correct 5 ms 4940 KB Output is correct
15 Correct 5 ms 4876 KB Output is correct
16 Correct 4 ms 4992 KB Output is correct
17 Correct 4 ms 4996 KB Output is correct
18 Correct 4 ms 4940 KB Output is correct
19 Correct 4 ms 5068 KB Output is correct
20 Correct 5 ms 4940 KB Output is correct
21 Correct 4 ms 4940 KB Output is correct
22 Correct 4 ms 4940 KB Output is correct
23 Correct 4 ms 4996 KB Output is correct
24 Correct 4 ms 4940 KB Output is correct
25 Correct 4 ms 4940 KB Output is correct
26 Correct 5 ms 4940 KB Output is correct
27 Correct 5 ms 4992 KB Output is correct
28 Correct 4 ms 4988 KB Output is correct
29 Correct 4 ms 4940 KB Output is correct
30 Correct 4 ms 4940 KB Output is correct
31 Correct 4 ms 4940 KB Output is correct
32 Correct 4 ms 4940 KB Output is correct
33 Correct 4 ms 4940 KB Output is correct
34 Correct 4 ms 4940 KB Output is correct
35 Correct 4 ms 4940 KB Output is correct
36 Correct 4 ms 4940 KB Output is correct
37 Correct 4 ms 4940 KB Output is correct
38 Correct 6 ms 4988 KB Output is correct
39 Correct 4 ms 4940 KB Output is correct
40 Correct 5 ms 4992 KB Output is correct
41 Correct 4 ms 4992 KB Output is correct
42 Correct 4 ms 4940 KB Output is correct
43 Correct 4 ms 4940 KB Output is correct
44 Correct 4 ms 4988 KB Output is correct
45 Correct 4 ms 5000 KB Output is correct
46 Correct 4 ms 4992 KB Output is correct
47 Correct 4 ms 4940 KB Output is correct
48 Correct 4 ms 4988 KB Output is correct
49 Correct 4 ms 4908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4940 KB Output is correct
2 Correct 4 ms 4940 KB Output is correct
3 Correct 4 ms 4940 KB Output is correct
4 Correct 4 ms 4996 KB Output is correct
5 Correct 4 ms 4940 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 5 ms 4940 KB Output is correct
8 Correct 4 ms 4992 KB Output is correct
9 Correct 4 ms 4940 KB Output is correct
10 Correct 5 ms 4940 KB Output is correct
11 Correct 4 ms 4952 KB Output is correct
12 Correct 4 ms 4992 KB Output is correct
13 Correct 4 ms 4940 KB Output is correct
14 Correct 5 ms 4940 KB Output is correct
15 Correct 5 ms 4876 KB Output is correct
16 Correct 4 ms 4992 KB Output is correct
17 Correct 4 ms 4996 KB Output is correct
18 Correct 4 ms 4940 KB Output is correct
19 Correct 4 ms 5068 KB Output is correct
20 Correct 5 ms 4940 KB Output is correct
21 Correct 4 ms 4940 KB Output is correct
22 Correct 4 ms 4940 KB Output is correct
23 Correct 4 ms 4996 KB Output is correct
24 Correct 4 ms 4940 KB Output is correct
25 Correct 4 ms 4940 KB Output is correct
26 Correct 5 ms 4940 KB Output is correct
27 Correct 5 ms 4992 KB Output is correct
28 Correct 4 ms 4988 KB Output is correct
29 Correct 4 ms 4940 KB Output is correct
30 Correct 4 ms 4940 KB Output is correct
31 Correct 4 ms 4940 KB Output is correct
32 Correct 4 ms 4940 KB Output is correct
33 Correct 4 ms 4940 KB Output is correct
34 Correct 4 ms 4940 KB Output is correct
35 Correct 4 ms 4940 KB Output is correct
36 Correct 4 ms 4940 KB Output is correct
37 Correct 4 ms 4940 KB Output is correct
38 Correct 6 ms 4988 KB Output is correct
39 Correct 4 ms 4940 KB Output is correct
40 Correct 5 ms 4992 KB Output is correct
41 Correct 4 ms 4992 KB Output is correct
42 Correct 4 ms 4940 KB Output is correct
43 Correct 4 ms 4940 KB Output is correct
44 Correct 4 ms 4988 KB Output is correct
45 Correct 4 ms 5000 KB Output is correct
46 Correct 4 ms 4992 KB Output is correct
47 Correct 4 ms 4940 KB Output is correct
48 Correct 4 ms 4988 KB Output is correct
49 Correct 4 ms 4908 KB Output is correct
50 Correct 6 ms 5196 KB Output is correct
51 Correct 6 ms 5068 KB Output is correct
52 Correct 6 ms 5068 KB Output is correct
53 Correct 5 ms 5068 KB Output is correct
54 Correct 5 ms 5068 KB Output is correct
55 Correct 7 ms 5324 KB Output is correct
56 Correct 6 ms 5196 KB Output is correct
57 Correct 7 ms 5116 KB Output is correct
58 Correct 4 ms 4940 KB Output is correct
59 Correct 4 ms 4940 KB Output is correct
60 Correct 4 ms 4996 KB Output is correct
61 Correct 6 ms 5068 KB Output is correct
62 Correct 4 ms 4940 KB Output is correct
63 Correct 4 ms 4940 KB Output is correct
64 Correct 4 ms 4940 KB Output is correct
65 Correct 5 ms 5068 KB Output is correct
66 Correct 4 ms 4940 KB Output is correct
67 Correct 5 ms 4940 KB Output is correct
68 Correct 4 ms 4996 KB Output is correct
69 Correct 4 ms 4940 KB Output is correct
70 Correct 5 ms 4924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4940 KB Output is correct
2 Correct 4 ms 4940 KB Output is correct
3 Correct 4 ms 4940 KB Output is correct
4 Correct 4 ms 4996 KB Output is correct
5 Correct 4 ms 4940 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 5 ms 4940 KB Output is correct
8 Correct 4 ms 4992 KB Output is correct
9 Correct 4 ms 4940 KB Output is correct
10 Correct 5 ms 4940 KB Output is correct
11 Correct 4 ms 4952 KB Output is correct
12 Correct 4 ms 4992 KB Output is correct
13 Correct 4 ms 4940 KB Output is correct
14 Correct 5 ms 4940 KB Output is correct
15 Correct 5 ms 4876 KB Output is correct
16 Correct 4 ms 4992 KB Output is correct
17 Correct 4 ms 4996 KB Output is correct
18 Correct 4 ms 4940 KB Output is correct
19 Correct 4 ms 5068 KB Output is correct
20 Correct 5 ms 4940 KB Output is correct
21 Correct 4 ms 4940 KB Output is correct
22 Correct 4 ms 4940 KB Output is correct
23 Correct 4 ms 4996 KB Output is correct
24 Correct 4 ms 4940 KB Output is correct
25 Correct 4 ms 4940 KB Output is correct
26 Correct 5 ms 4940 KB Output is correct
27 Correct 5 ms 4992 KB Output is correct
28 Correct 4 ms 4988 KB Output is correct
29 Correct 4 ms 4940 KB Output is correct
30 Correct 4 ms 4940 KB Output is correct
31 Correct 4 ms 4940 KB Output is correct
32 Correct 4 ms 4940 KB Output is correct
33 Correct 4 ms 4940 KB Output is correct
34 Correct 4 ms 4940 KB Output is correct
35 Correct 4 ms 4940 KB Output is correct
36 Correct 4 ms 4940 KB Output is correct
37 Correct 4 ms 4940 KB Output is correct
38 Correct 6 ms 4988 KB Output is correct
39 Correct 4 ms 4940 KB Output is correct
40 Correct 5 ms 4992 KB Output is correct
41 Correct 4 ms 4992 KB Output is correct
42 Correct 4 ms 4940 KB Output is correct
43 Correct 4 ms 4940 KB Output is correct
44 Correct 4 ms 4988 KB Output is correct
45 Correct 4 ms 5000 KB Output is correct
46 Correct 4 ms 4992 KB Output is correct
47 Correct 4 ms 4940 KB Output is correct
48 Correct 4 ms 4988 KB Output is correct
49 Correct 4 ms 4908 KB Output is correct
50 Correct 6 ms 5196 KB Output is correct
51 Correct 6 ms 5068 KB Output is correct
52 Correct 6 ms 5068 KB Output is correct
53 Correct 5 ms 5068 KB Output is correct
54 Correct 5 ms 5068 KB Output is correct
55 Correct 7 ms 5324 KB Output is correct
56 Correct 6 ms 5196 KB Output is correct
57 Correct 7 ms 5116 KB Output is correct
58 Correct 4 ms 4940 KB Output is correct
59 Correct 4 ms 4940 KB Output is correct
60 Correct 4 ms 4996 KB Output is correct
61 Correct 6 ms 5068 KB Output is correct
62 Correct 4 ms 4940 KB Output is correct
63 Correct 4 ms 4940 KB Output is correct
64 Correct 4 ms 4940 KB Output is correct
65 Correct 5 ms 5068 KB Output is correct
66 Correct 4 ms 4940 KB Output is correct
67 Correct 5 ms 4940 KB Output is correct
68 Correct 4 ms 4996 KB Output is correct
69 Correct 4 ms 4940 KB Output is correct
70 Correct 5 ms 4924 KB Output is correct
71 Correct 203 ms 22340 KB Output is correct
72 Correct 157 ms 17720 KB Output is correct
73 Correct 193 ms 21860 KB Output is correct
74 Correct 106 ms 13952 KB Output is correct
75 Correct 132 ms 15612 KB Output is correct
76 Correct 313 ms 31688 KB Output is correct
77 Correct 285 ms 29464 KB Output is correct
78 Correct 245 ms 25784 KB Output is correct
79 Correct 246 ms 26164 KB Output is correct
80 Correct 4 ms 4988 KB Output is correct
81 Correct 4 ms 4992 KB Output is correct
82 Correct 5 ms 5068 KB Output is correct
83 Correct 31 ms 7420 KB Output is correct
84 Correct 40 ms 8340 KB Output is correct
85 Correct 13 ms 5704 KB Output is correct
86 Correct 5 ms 4940 KB Output is correct
87 Correct 44 ms 8640 KB Output is correct
88 Correct 4 ms 4940 KB Output is correct
89 Correct 4 ms 4900 KB Output is correct
90 Correct 4 ms 4940 KB Output is correct
91 Correct 14 ms 5888 KB Output is correct
92 Correct 50 ms 8768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4940 KB Output is correct
2 Correct 4 ms 4940 KB Output is correct
3 Correct 4 ms 4940 KB Output is correct
4 Correct 4 ms 4996 KB Output is correct
5 Correct 4 ms 4940 KB Output is correct
6 Correct 4 ms 4992 KB Output is correct
7 Correct 5 ms 4940 KB Output is correct
8 Correct 4 ms 4992 KB Output is correct
9 Correct 4 ms 4940 KB Output is correct
10 Correct 5 ms 4940 KB Output is correct
11 Correct 4 ms 4952 KB Output is correct
12 Correct 4 ms 4992 KB Output is correct
13 Correct 4 ms 4940 KB Output is correct
14 Correct 5 ms 4940 KB Output is correct
15 Correct 5 ms 4876 KB Output is correct
16 Correct 4 ms 4992 KB Output is correct
17 Correct 4 ms 4996 KB Output is correct
18 Correct 4 ms 4940 KB Output is correct
19 Correct 4 ms 5068 KB Output is correct
20 Correct 5 ms 4940 KB Output is correct
21 Correct 4 ms 4940 KB Output is correct
22 Correct 4 ms 4940 KB Output is correct
23 Correct 4 ms 4996 KB Output is correct
24 Correct 4 ms 4940 KB Output is correct
25 Correct 4 ms 4940 KB Output is correct
26 Correct 5 ms 4940 KB Output is correct
27 Correct 5 ms 4992 KB Output is correct
28 Correct 4 ms 4988 KB Output is correct
29 Correct 4 ms 4940 KB Output is correct
30 Correct 4 ms 4940 KB Output is correct
31 Correct 4 ms 4940 KB Output is correct
32 Correct 4 ms 4940 KB Output is correct
33 Correct 4 ms 4940 KB Output is correct
34 Correct 4 ms 4940 KB Output is correct
35 Correct 4 ms 4940 KB Output is correct
36 Correct 4 ms 4940 KB Output is correct
37 Correct 4 ms 4940 KB Output is correct
38 Correct 6 ms 4988 KB Output is correct
39 Correct 4 ms 4940 KB Output is correct
40 Correct 5 ms 4992 KB Output is correct
41 Correct 4 ms 4992 KB Output is correct
42 Correct 4 ms 4940 KB Output is correct
43 Correct 4 ms 4940 KB Output is correct
44 Correct 4 ms 4988 KB Output is correct
45 Correct 4 ms 5000 KB Output is correct
46 Correct 4 ms 4992 KB Output is correct
47 Correct 4 ms 4940 KB Output is correct
48 Correct 4 ms 4988 KB Output is correct
49 Correct 4 ms 4908 KB Output is correct
50 Correct 6 ms 5196 KB Output is correct
51 Correct 6 ms 5068 KB Output is correct
52 Correct 6 ms 5068 KB Output is correct
53 Correct 5 ms 5068 KB Output is correct
54 Correct 5 ms 5068 KB Output is correct
55 Correct 7 ms 5324 KB Output is correct
56 Correct 6 ms 5196 KB Output is correct
57 Correct 7 ms 5116 KB Output is correct
58 Correct 4 ms 4940 KB Output is correct
59 Correct 4 ms 4940 KB Output is correct
60 Correct 4 ms 4996 KB Output is correct
61 Correct 6 ms 5068 KB Output is correct
62 Correct 4 ms 4940 KB Output is correct
63 Correct 4 ms 4940 KB Output is correct
64 Correct 4 ms 4940 KB Output is correct
65 Correct 5 ms 5068 KB Output is correct
66 Correct 4 ms 4940 KB Output is correct
67 Correct 5 ms 4940 KB Output is correct
68 Correct 4 ms 4996 KB Output is correct
69 Correct 4 ms 4940 KB Output is correct
70 Correct 5 ms 4924 KB Output is correct
71 Correct 203 ms 22340 KB Output is correct
72 Correct 157 ms 17720 KB Output is correct
73 Correct 193 ms 21860 KB Output is correct
74 Correct 106 ms 13952 KB Output is correct
75 Correct 132 ms 15612 KB Output is correct
76 Correct 313 ms 31688 KB Output is correct
77 Correct 285 ms 29464 KB Output is correct
78 Correct 245 ms 25784 KB Output is correct
79 Correct 246 ms 26164 KB Output is correct
80 Correct 4 ms 4988 KB Output is correct
81 Correct 4 ms 4992 KB Output is correct
82 Correct 5 ms 5068 KB Output is correct
83 Correct 31 ms 7420 KB Output is correct
84 Correct 40 ms 8340 KB Output is correct
85 Correct 13 ms 5704 KB Output is correct
86 Correct 5 ms 4940 KB Output is correct
87 Correct 44 ms 8640 KB Output is correct
88 Correct 4 ms 4940 KB Output is correct
89 Correct 4 ms 4900 KB Output is correct
90 Correct 4 ms 4940 KB Output is correct
91 Correct 14 ms 5888 KB Output is correct
92 Correct 50 ms 8768 KB Output is correct
93 Correct 1128 ms 95096 KB Output is correct
94 Correct 647 ms 55748 KB Output is correct
95 Correct 726 ms 67184 KB Output is correct
96 Correct 627 ms 57368 KB Output is correct
97 Correct 585 ms 53868 KB Output is correct
98 Correct 1293 ms 108892 KB Output is correct
99 Correct 1347 ms 114496 KB Output is correct
100 Correct 1283 ms 106892 KB Output is correct
101 Correct 1196 ms 103260 KB Output is correct
102 Correct 1041 ms 91056 KB Output is correct
103 Correct 871 ms 74580 KB Output is correct
104 Correct 4 ms 5000 KB Output is correct
105 Correct 4 ms 4996 KB Output is correct
106 Correct 7 ms 5324 KB Output is correct
107 Correct 91 ms 12640 KB Output is correct
108 Correct 226 ms 24004 KB Output is correct
109 Correct 22 ms 6784 KB Output is correct
110 Correct 4 ms 4940 KB Output is correct
111 Correct 112 ms 14724 KB Output is correct
112 Correct 4 ms 4940 KB Output is correct
113 Correct 4 ms 4940 KB Output is correct
114 Correct 7 ms 5196 KB Output is correct
115 Correct 4 ms 4940 KB Output is correct
116 Correct 11 ms 5700 KB Output is correct
117 Correct 219 ms 22172 KB Output is correct