Submission #699265

# Submission time Handle Problem Language Result Execution time Memory
699265 2023-02-16T09:58:02 Z dattranxxx Toys (CEOI18_toy) C++11
100 / 100
1138 ms 138984 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

const int N = 1e5 + 5;

int n;
vector<int> divi[N], dp[N];

vector<pair<int, int>> adj[N];

int main() {
  cin.tie(0)->sync_with_stdio(0); cout.tie(0);
  cin >> n;
  
  vector<int> d;
  for (int i = 2; i * i <= n; ++i) if (n % i == 0) {
    d.emplace_back(i);
    if (i * i != n) d.emplace_back(n / i);
  }
  d.emplace_back(n);
  sort(d.begin(), d.end());
  
  for (int i = 0; i < d.size(); ++i) {
    for (int j = 0; j < i; ++j) if (d[i] % d[j] == 0) {
      int k = lower_bound(d.begin(), d.end(), d[i] / d[j]) - d.begin();
      adj[i].emplace_back(j, k);
    }
  }

  dp[d.size() - 1].emplace_back(0);
  
  for (int i = d.size() - 1; ~i; --i) {
    sort(dp[i].begin(), dp[i].end());
    dp[i].erase(unique(dp[i].begin(), dp[i].end()), dp[i].end());
    
    for (int s : dp[i]) {
      dp[d.size()].emplace_back(s + d[i] - 1);
    }
    
    for (auto& p : adj[i]) {
      int j, k; tie(j, k) = p;
      for (int s : dp[i]) {
        dp[k].emplace_back(s + d[j] - 1);
      }
    }
  }
  
  sort(dp[d.size()].begin(), dp[d.size()].end());
  dp[d.size()].erase(unique(dp[d.size()].begin(), dp[d.size()].end()), dp[d.size()].end());
  
  cout << dp[d.size()].size() << '\n';
  for (auto& x : dp[d.size()]) {
    cout << x << ' ';
  }
  
  
  
	return 0;
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:24:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   for (int i = 0; i < d.size(); ++i) {
      |                   ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 7252 KB Output is correct
2 Correct 4 ms 7252 KB Output is correct
3 Correct 5 ms 7252 KB Output is correct
4 Correct 4 ms 7252 KB Output is correct
5 Correct 3 ms 7252 KB Output is correct
6 Correct 4 ms 7320 KB Output is correct
7 Correct 3 ms 7252 KB Output is correct
8 Correct 4 ms 7252 KB Output is correct
9 Correct 4 ms 7252 KB Output is correct
10 Correct 4 ms 7252 KB Output is correct
11 Correct 4 ms 7252 KB Output is correct
12 Correct 3 ms 7360 KB Output is correct
13 Correct 4 ms 7252 KB Output is correct
14 Correct 3 ms 7252 KB Output is correct
15 Correct 3 ms 7252 KB Output is correct
16 Correct 3 ms 7252 KB Output is correct
17 Correct 4 ms 7252 KB Output is correct
18 Correct 4 ms 7252 KB Output is correct
19 Correct 4 ms 7360 KB Output is correct
20 Correct 4 ms 7272 KB Output is correct
21 Correct 4 ms 7252 KB Output is correct
22 Correct 4 ms 7252 KB Output is correct
23 Correct 4 ms 7252 KB Output is correct
24 Correct 4 ms 7252 KB Output is correct
25 Correct 4 ms 7252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 7252 KB Output is correct
2 Correct 4 ms 7252 KB Output is correct
3 Correct 5 ms 7252 KB Output is correct
4 Correct 4 ms 7252 KB Output is correct
5 Correct 3 ms 7252 KB Output is correct
6 Correct 4 ms 7320 KB Output is correct
7 Correct 3 ms 7252 KB Output is correct
8 Correct 4 ms 7252 KB Output is correct
9 Correct 4 ms 7252 KB Output is correct
10 Correct 4 ms 7252 KB Output is correct
11 Correct 4 ms 7252 KB Output is correct
12 Correct 3 ms 7360 KB Output is correct
13 Correct 4 ms 7252 KB Output is correct
14 Correct 3 ms 7252 KB Output is correct
15 Correct 3 ms 7252 KB Output is correct
16 Correct 3 ms 7252 KB Output is correct
17 Correct 4 ms 7252 KB Output is correct
18 Correct 4 ms 7252 KB Output is correct
19 Correct 4 ms 7360 KB Output is correct
20 Correct 4 ms 7272 KB Output is correct
21 Correct 4 ms 7252 KB Output is correct
22 Correct 4 ms 7252 KB Output is correct
23 Correct 4 ms 7252 KB Output is correct
24 Correct 4 ms 7252 KB Output is correct
25 Correct 4 ms 7252 KB Output is correct
26 Correct 4 ms 7380 KB Output is correct
27 Correct 4 ms 7380 KB Output is correct
28 Correct 4 ms 7380 KB Output is correct
29 Correct 4 ms 7380 KB Output is correct
30 Correct 4 ms 7252 KB Output is correct
31 Correct 4 ms 7404 KB Output is correct
32 Correct 4 ms 7380 KB Output is correct
33 Correct 4 ms 7380 KB Output is correct
34 Correct 4 ms 7252 KB Output is correct
35 Correct 4 ms 7252 KB Output is correct
36 Correct 4 ms 7252 KB Output is correct
37 Correct 4 ms 7380 KB Output is correct
38 Correct 4 ms 7252 KB Output is correct
39 Correct 4 ms 7252 KB Output is correct
40 Correct 4 ms 7380 KB Output is correct
41 Correct 4 ms 7252 KB Output is correct
42 Correct 4 ms 7252 KB Output is correct
43 Correct 3 ms 7252 KB Output is correct
44 Correct 4 ms 7252 KB Output is correct
45 Correct 4 ms 7252 KB Output is correct
46 Correct 4 ms 7252 KB Output is correct
47 Correct 4 ms 7380 KB Output is correct
48 Correct 3 ms 7252 KB Output is correct
49 Correct 3 ms 7252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 7252 KB Output is correct
2 Correct 4 ms 7252 KB Output is correct
3 Correct 5 ms 7252 KB Output is correct
4 Correct 4 ms 7252 KB Output is correct
5 Correct 3 ms 7252 KB Output is correct
6 Correct 4 ms 7320 KB Output is correct
7 Correct 3 ms 7252 KB Output is correct
8 Correct 4 ms 7252 KB Output is correct
9 Correct 4 ms 7252 KB Output is correct
10 Correct 4 ms 7252 KB Output is correct
11 Correct 4 ms 7252 KB Output is correct
12 Correct 3 ms 7360 KB Output is correct
13 Correct 4 ms 7252 KB Output is correct
14 Correct 3 ms 7252 KB Output is correct
15 Correct 3 ms 7252 KB Output is correct
16 Correct 3 ms 7252 KB Output is correct
17 Correct 4 ms 7252 KB Output is correct
18 Correct 4 ms 7252 KB Output is correct
19 Correct 4 ms 7360 KB Output is correct
20 Correct 4 ms 7272 KB Output is correct
21 Correct 4 ms 7252 KB Output is correct
22 Correct 4 ms 7252 KB Output is correct
23 Correct 4 ms 7252 KB Output is correct
24 Correct 4 ms 7252 KB Output is correct
25 Correct 4 ms 7252 KB Output is correct
26 Correct 4 ms 7380 KB Output is correct
27 Correct 4 ms 7380 KB Output is correct
28 Correct 4 ms 7380 KB Output is correct
29 Correct 4 ms 7380 KB Output is correct
30 Correct 4 ms 7252 KB Output is correct
31 Correct 4 ms 7404 KB Output is correct
32 Correct 4 ms 7380 KB Output is correct
33 Correct 4 ms 7380 KB Output is correct
34 Correct 4 ms 7252 KB Output is correct
35 Correct 4 ms 7252 KB Output is correct
36 Correct 4 ms 7252 KB Output is correct
37 Correct 4 ms 7380 KB Output is correct
38 Correct 4 ms 7252 KB Output is correct
39 Correct 4 ms 7252 KB Output is correct
40 Correct 4 ms 7380 KB Output is correct
41 Correct 4 ms 7252 KB Output is correct
42 Correct 4 ms 7252 KB Output is correct
43 Correct 3 ms 7252 KB Output is correct
44 Correct 4 ms 7252 KB Output is correct
45 Correct 4 ms 7252 KB Output is correct
46 Correct 4 ms 7252 KB Output is correct
47 Correct 4 ms 7380 KB Output is correct
48 Correct 3 ms 7252 KB Output is correct
49 Correct 3 ms 7252 KB Output is correct
50 Correct 5 ms 7636 KB Output is correct
51 Correct 5 ms 7584 KB Output is correct
52 Correct 5 ms 7508 KB Output is correct
53 Correct 5 ms 7508 KB Output is correct
54 Correct 5 ms 7380 KB Output is correct
55 Correct 6 ms 7636 KB Output is correct
56 Correct 5 ms 7636 KB Output is correct
57 Correct 6 ms 7636 KB Output is correct
58 Correct 4 ms 7252 KB Output is correct
59 Correct 5 ms 7380 KB Output is correct
60 Correct 4 ms 7380 KB Output is correct
61 Correct 5 ms 7508 KB Output is correct
62 Correct 4 ms 7380 KB Output is correct
63 Correct 4 ms 7380 KB Output is correct
64 Correct 4 ms 7252 KB Output is correct
65 Correct 4 ms 7508 KB Output is correct
66 Correct 3 ms 7252 KB Output is correct
67 Correct 4 ms 7252 KB Output is correct
68 Correct 3 ms 7252 KB Output is correct
69 Correct 5 ms 7380 KB Output is correct
70 Correct 5 ms 7392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 7252 KB Output is correct
2 Correct 4 ms 7252 KB Output is correct
3 Correct 5 ms 7252 KB Output is correct
4 Correct 4 ms 7252 KB Output is correct
5 Correct 3 ms 7252 KB Output is correct
6 Correct 4 ms 7320 KB Output is correct
7 Correct 3 ms 7252 KB Output is correct
8 Correct 4 ms 7252 KB Output is correct
9 Correct 4 ms 7252 KB Output is correct
10 Correct 4 ms 7252 KB Output is correct
11 Correct 4 ms 7252 KB Output is correct
12 Correct 3 ms 7360 KB Output is correct
13 Correct 4 ms 7252 KB Output is correct
14 Correct 3 ms 7252 KB Output is correct
15 Correct 3 ms 7252 KB Output is correct
16 Correct 3 ms 7252 KB Output is correct
17 Correct 4 ms 7252 KB Output is correct
18 Correct 4 ms 7252 KB Output is correct
19 Correct 4 ms 7360 KB Output is correct
20 Correct 4 ms 7272 KB Output is correct
21 Correct 4 ms 7252 KB Output is correct
22 Correct 4 ms 7252 KB Output is correct
23 Correct 4 ms 7252 KB Output is correct
24 Correct 4 ms 7252 KB Output is correct
25 Correct 4 ms 7252 KB Output is correct
26 Correct 4 ms 7380 KB Output is correct
27 Correct 4 ms 7380 KB Output is correct
28 Correct 4 ms 7380 KB Output is correct
29 Correct 4 ms 7380 KB Output is correct
30 Correct 4 ms 7252 KB Output is correct
31 Correct 4 ms 7404 KB Output is correct
32 Correct 4 ms 7380 KB Output is correct
33 Correct 4 ms 7380 KB Output is correct
34 Correct 4 ms 7252 KB Output is correct
35 Correct 4 ms 7252 KB Output is correct
36 Correct 4 ms 7252 KB Output is correct
37 Correct 4 ms 7380 KB Output is correct
38 Correct 4 ms 7252 KB Output is correct
39 Correct 4 ms 7252 KB Output is correct
40 Correct 4 ms 7380 KB Output is correct
41 Correct 4 ms 7252 KB Output is correct
42 Correct 4 ms 7252 KB Output is correct
43 Correct 3 ms 7252 KB Output is correct
44 Correct 4 ms 7252 KB Output is correct
45 Correct 4 ms 7252 KB Output is correct
46 Correct 4 ms 7252 KB Output is correct
47 Correct 4 ms 7380 KB Output is correct
48 Correct 3 ms 7252 KB Output is correct
49 Correct 3 ms 7252 KB Output is correct
50 Correct 5 ms 7636 KB Output is correct
51 Correct 5 ms 7584 KB Output is correct
52 Correct 5 ms 7508 KB Output is correct
53 Correct 5 ms 7508 KB Output is correct
54 Correct 5 ms 7380 KB Output is correct
55 Correct 6 ms 7636 KB Output is correct
56 Correct 5 ms 7636 KB Output is correct
57 Correct 6 ms 7636 KB Output is correct
58 Correct 4 ms 7252 KB Output is correct
59 Correct 5 ms 7380 KB Output is correct
60 Correct 4 ms 7380 KB Output is correct
61 Correct 5 ms 7508 KB Output is correct
62 Correct 4 ms 7380 KB Output is correct
63 Correct 4 ms 7380 KB Output is correct
64 Correct 4 ms 7252 KB Output is correct
65 Correct 4 ms 7508 KB Output is correct
66 Correct 3 ms 7252 KB Output is correct
67 Correct 4 ms 7252 KB Output is correct
68 Correct 3 ms 7252 KB Output is correct
69 Correct 5 ms 7380 KB Output is correct
70 Correct 5 ms 7392 KB Output is correct
71 Correct 174 ms 28508 KB Output is correct
72 Correct 125 ms 21708 KB Output is correct
73 Correct 164 ms 26688 KB Output is correct
74 Correct 94 ms 17896 KB Output is correct
75 Correct 107 ms 19736 KB Output is correct
76 Correct 276 ms 38628 KB Output is correct
77 Correct 247 ms 36312 KB Output is correct
78 Correct 213 ms 32544 KB Output is correct
79 Correct 211 ms 32764 KB Output is correct
80 Correct 3 ms 7252 KB Output is correct
81 Correct 4 ms 7360 KB Output is correct
82 Correct 5 ms 7508 KB Output is correct
83 Correct 27 ms 10572 KB Output is correct
84 Correct 34 ms 11136 KB Output is correct
85 Correct 9 ms 8148 KB Output is correct
86 Correct 4 ms 7380 KB Output is correct
87 Correct 36 ms 11292 KB Output is correct
88 Correct 4 ms 7252 KB Output is correct
89 Correct 4 ms 7252 KB Output is correct
90 Correct 4 ms 7252 KB Output is correct
91 Correct 12 ms 8404 KB Output is correct
92 Correct 45 ms 12296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 7252 KB Output is correct
2 Correct 4 ms 7252 KB Output is correct
3 Correct 5 ms 7252 KB Output is correct
4 Correct 4 ms 7252 KB Output is correct
5 Correct 3 ms 7252 KB Output is correct
6 Correct 4 ms 7320 KB Output is correct
7 Correct 3 ms 7252 KB Output is correct
8 Correct 4 ms 7252 KB Output is correct
9 Correct 4 ms 7252 KB Output is correct
10 Correct 4 ms 7252 KB Output is correct
11 Correct 4 ms 7252 KB Output is correct
12 Correct 3 ms 7360 KB Output is correct
13 Correct 4 ms 7252 KB Output is correct
14 Correct 3 ms 7252 KB Output is correct
15 Correct 3 ms 7252 KB Output is correct
16 Correct 3 ms 7252 KB Output is correct
17 Correct 4 ms 7252 KB Output is correct
18 Correct 4 ms 7252 KB Output is correct
19 Correct 4 ms 7360 KB Output is correct
20 Correct 4 ms 7272 KB Output is correct
21 Correct 4 ms 7252 KB Output is correct
22 Correct 4 ms 7252 KB Output is correct
23 Correct 4 ms 7252 KB Output is correct
24 Correct 4 ms 7252 KB Output is correct
25 Correct 4 ms 7252 KB Output is correct
26 Correct 4 ms 7380 KB Output is correct
27 Correct 4 ms 7380 KB Output is correct
28 Correct 4 ms 7380 KB Output is correct
29 Correct 4 ms 7380 KB Output is correct
30 Correct 4 ms 7252 KB Output is correct
31 Correct 4 ms 7404 KB Output is correct
32 Correct 4 ms 7380 KB Output is correct
33 Correct 4 ms 7380 KB Output is correct
34 Correct 4 ms 7252 KB Output is correct
35 Correct 4 ms 7252 KB Output is correct
36 Correct 4 ms 7252 KB Output is correct
37 Correct 4 ms 7380 KB Output is correct
38 Correct 4 ms 7252 KB Output is correct
39 Correct 4 ms 7252 KB Output is correct
40 Correct 4 ms 7380 KB Output is correct
41 Correct 4 ms 7252 KB Output is correct
42 Correct 4 ms 7252 KB Output is correct
43 Correct 3 ms 7252 KB Output is correct
44 Correct 4 ms 7252 KB Output is correct
45 Correct 4 ms 7252 KB Output is correct
46 Correct 4 ms 7252 KB Output is correct
47 Correct 4 ms 7380 KB Output is correct
48 Correct 3 ms 7252 KB Output is correct
49 Correct 3 ms 7252 KB Output is correct
50 Correct 5 ms 7636 KB Output is correct
51 Correct 5 ms 7584 KB Output is correct
52 Correct 5 ms 7508 KB Output is correct
53 Correct 5 ms 7508 KB Output is correct
54 Correct 5 ms 7380 KB Output is correct
55 Correct 6 ms 7636 KB Output is correct
56 Correct 5 ms 7636 KB Output is correct
57 Correct 6 ms 7636 KB Output is correct
58 Correct 4 ms 7252 KB Output is correct
59 Correct 5 ms 7380 KB Output is correct
60 Correct 4 ms 7380 KB Output is correct
61 Correct 5 ms 7508 KB Output is correct
62 Correct 4 ms 7380 KB Output is correct
63 Correct 4 ms 7380 KB Output is correct
64 Correct 4 ms 7252 KB Output is correct
65 Correct 4 ms 7508 KB Output is correct
66 Correct 3 ms 7252 KB Output is correct
67 Correct 4 ms 7252 KB Output is correct
68 Correct 3 ms 7252 KB Output is correct
69 Correct 5 ms 7380 KB Output is correct
70 Correct 5 ms 7392 KB Output is correct
71 Correct 174 ms 28508 KB Output is correct
72 Correct 125 ms 21708 KB Output is correct
73 Correct 164 ms 26688 KB Output is correct
74 Correct 94 ms 17896 KB Output is correct
75 Correct 107 ms 19736 KB Output is correct
76 Correct 276 ms 38628 KB Output is correct
77 Correct 247 ms 36312 KB Output is correct
78 Correct 213 ms 32544 KB Output is correct
79 Correct 211 ms 32764 KB Output is correct
80 Correct 3 ms 7252 KB Output is correct
81 Correct 4 ms 7360 KB Output is correct
82 Correct 5 ms 7508 KB Output is correct
83 Correct 27 ms 10572 KB Output is correct
84 Correct 34 ms 11136 KB Output is correct
85 Correct 9 ms 8148 KB Output is correct
86 Correct 4 ms 7380 KB Output is correct
87 Correct 36 ms 11292 KB Output is correct
88 Correct 4 ms 7252 KB Output is correct
89 Correct 4 ms 7252 KB Output is correct
90 Correct 4 ms 7252 KB Output is correct
91 Correct 12 ms 8404 KB Output is correct
92 Correct 45 ms 12296 KB Output is correct
93 Correct 954 ms 118864 KB Output is correct
94 Correct 528 ms 64252 KB Output is correct
95 Correct 610 ms 80984 KB Output is correct
96 Correct 552 ms 71436 KB Output is correct
97 Correct 504 ms 66548 KB Output is correct
98 Correct 1086 ms 134944 KB Output is correct
99 Correct 1138 ms 138984 KB Output is correct
100 Correct 1057 ms 132644 KB Output is correct
101 Correct 1004 ms 125700 KB Output is correct
102 Correct 892 ms 114308 KB Output is correct
103 Correct 717 ms 92944 KB Output is correct
104 Correct 4 ms 7252 KB Output is correct
105 Correct 4 ms 7368 KB Output is correct
106 Correct 6 ms 7764 KB Output is correct
107 Correct 81 ms 15960 KB Output is correct
108 Correct 206 ms 28188 KB Output is correct
109 Correct 20 ms 9424 KB Output is correct
110 Correct 5 ms 7252 KB Output is correct
111 Correct 98 ms 17644 KB Output is correct
112 Correct 4 ms 7252 KB Output is correct
113 Correct 4 ms 7372 KB Output is correct
114 Correct 6 ms 7636 KB Output is correct
115 Correct 4 ms 7252 KB Output is correct
116 Correct 9 ms 8140 KB Output is correct
117 Correct 185 ms 27636 KB Output is correct