답안 #699266

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
699266 2023-02-16T10:00:30 Z dattranxxx Toys (CEOI18_toy) C++11
100 / 100
1246 ms 129764 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);
  
  set<int> ans;
  
  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]) {
      ans.insert(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);
      }
    }
  }
  
  cout << ans.size() << '\n';
  for (int x : ans) {
    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) {
      |                   ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7252 KB Output is correct
2 Correct 4 ms 7252 KB Output is correct
3 Correct 3 ms 7252 KB Output is correct
4 Correct 3 ms 7252 KB Output is correct
5 Correct 5 ms 7252 KB Output is correct
6 Correct 3 ms 7252 KB Output is correct
7 Correct 4 ms 7328 KB Output is correct
8 Correct 5 ms 7280 KB Output is correct
9 Correct 5 ms 7252 KB Output is correct
10 Correct 4 ms 7252 KB Output is correct
11 Correct 3 ms 7252 KB Output is correct
12 Correct 4 ms 7252 KB Output is correct
13 Correct 4 ms 7252 KB Output is correct
14 Correct 4 ms 7252 KB Output is correct
15 Correct 4 ms 7252 KB Output is correct
16 Correct 5 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 5 ms 7252 KB Output is correct
20 Correct 4 ms 7252 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
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7252 KB Output is correct
2 Correct 4 ms 7252 KB Output is correct
3 Correct 3 ms 7252 KB Output is correct
4 Correct 3 ms 7252 KB Output is correct
5 Correct 5 ms 7252 KB Output is correct
6 Correct 3 ms 7252 KB Output is correct
7 Correct 4 ms 7328 KB Output is correct
8 Correct 5 ms 7280 KB Output is correct
9 Correct 5 ms 7252 KB Output is correct
10 Correct 4 ms 7252 KB Output is correct
11 Correct 3 ms 7252 KB Output is correct
12 Correct 4 ms 7252 KB Output is correct
13 Correct 4 ms 7252 KB Output is correct
14 Correct 4 ms 7252 KB Output is correct
15 Correct 4 ms 7252 KB Output is correct
16 Correct 5 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 5 ms 7252 KB Output is correct
20 Correct 4 ms 7252 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 3 ms 7380 KB Output is correct
31 Correct 4 ms 7380 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 5 ms 7312 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 4 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 3 ms 7348 KB Output is correct
47 Correct 4 ms 7380 KB Output is correct
48 Correct 4 ms 7252 KB Output is correct
49 Correct 4 ms 7272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7252 KB Output is correct
2 Correct 4 ms 7252 KB Output is correct
3 Correct 3 ms 7252 KB Output is correct
4 Correct 3 ms 7252 KB Output is correct
5 Correct 5 ms 7252 KB Output is correct
6 Correct 3 ms 7252 KB Output is correct
7 Correct 4 ms 7328 KB Output is correct
8 Correct 5 ms 7280 KB Output is correct
9 Correct 5 ms 7252 KB Output is correct
10 Correct 4 ms 7252 KB Output is correct
11 Correct 3 ms 7252 KB Output is correct
12 Correct 4 ms 7252 KB Output is correct
13 Correct 4 ms 7252 KB Output is correct
14 Correct 4 ms 7252 KB Output is correct
15 Correct 4 ms 7252 KB Output is correct
16 Correct 5 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 5 ms 7252 KB Output is correct
20 Correct 4 ms 7252 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 3 ms 7380 KB Output is correct
31 Correct 4 ms 7380 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 5 ms 7312 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 4 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 3 ms 7348 KB Output is correct
47 Correct 4 ms 7380 KB Output is correct
48 Correct 4 ms 7252 KB Output is correct
49 Correct 4 ms 7272 KB Output is correct
50 Correct 5 ms 7508 KB Output is correct
51 Correct 5 ms 7508 KB Output is correct
52 Correct 6 ms 7508 KB Output is correct
53 Correct 6 ms 7508 KB Output is correct
54 Correct 5 ms 7380 KB Output is correct
55 Correct 7 ms 7636 KB Output is correct
56 Correct 5 ms 7636 KB Output is correct
57 Correct 5 ms 7636 KB Output is correct
58 Correct 4 ms 7348 KB Output is correct
59 Correct 4 ms 7252 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 7 ms 7500 KB Output is correct
66 Correct 5 ms 7340 KB Output is correct
67 Correct 5 ms 7252 KB Output is correct
68 Correct 4 ms 7252 KB Output is correct
69 Correct 4 ms 7380 KB Output is correct
70 Correct 4 ms 7380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7252 KB Output is correct
2 Correct 4 ms 7252 KB Output is correct
3 Correct 3 ms 7252 KB Output is correct
4 Correct 3 ms 7252 KB Output is correct
5 Correct 5 ms 7252 KB Output is correct
6 Correct 3 ms 7252 KB Output is correct
7 Correct 4 ms 7328 KB Output is correct
8 Correct 5 ms 7280 KB Output is correct
9 Correct 5 ms 7252 KB Output is correct
10 Correct 4 ms 7252 KB Output is correct
11 Correct 3 ms 7252 KB Output is correct
12 Correct 4 ms 7252 KB Output is correct
13 Correct 4 ms 7252 KB Output is correct
14 Correct 4 ms 7252 KB Output is correct
15 Correct 4 ms 7252 KB Output is correct
16 Correct 5 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 5 ms 7252 KB Output is correct
20 Correct 4 ms 7252 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 3 ms 7380 KB Output is correct
31 Correct 4 ms 7380 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 5 ms 7312 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 4 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 3 ms 7348 KB Output is correct
47 Correct 4 ms 7380 KB Output is correct
48 Correct 4 ms 7252 KB Output is correct
49 Correct 4 ms 7272 KB Output is correct
50 Correct 5 ms 7508 KB Output is correct
51 Correct 5 ms 7508 KB Output is correct
52 Correct 6 ms 7508 KB Output is correct
53 Correct 6 ms 7508 KB Output is correct
54 Correct 5 ms 7380 KB Output is correct
55 Correct 7 ms 7636 KB Output is correct
56 Correct 5 ms 7636 KB Output is correct
57 Correct 5 ms 7636 KB Output is correct
58 Correct 4 ms 7348 KB Output is correct
59 Correct 4 ms 7252 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 7 ms 7500 KB Output is correct
66 Correct 5 ms 7340 KB Output is correct
67 Correct 5 ms 7252 KB Output is correct
68 Correct 4 ms 7252 KB Output is correct
69 Correct 4 ms 7380 KB Output is correct
70 Correct 4 ms 7380 KB Output is correct
71 Correct 186 ms 26228 KB Output is correct
72 Correct 127 ms 19992 KB Output is correct
73 Correct 183 ms 24936 KB Output is correct
74 Correct 101 ms 17512 KB Output is correct
75 Correct 119 ms 18944 KB Output is correct
76 Correct 289 ms 36648 KB Output is correct
77 Correct 264 ms 34224 KB Output is correct
78 Correct 230 ms 30500 KB Output is correct
79 Correct 222 ms 31724 KB Output is correct
80 Correct 4 ms 7252 KB Output is correct
81 Correct 5 ms 7252 KB Output is correct
82 Correct 6 ms 7508 KB Output is correct
83 Correct 29 ms 10392 KB Output is correct
84 Correct 37 ms 11008 KB Output is correct
85 Correct 10 ms 8148 KB Output is correct
86 Correct 4 ms 7380 KB Output is correct
87 Correct 40 ms 11260 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 7380 KB Output is correct
91 Correct 14 ms 8488 KB Output is correct
92 Correct 51 ms 12028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7252 KB Output is correct
2 Correct 4 ms 7252 KB Output is correct
3 Correct 3 ms 7252 KB Output is correct
4 Correct 3 ms 7252 KB Output is correct
5 Correct 5 ms 7252 KB Output is correct
6 Correct 3 ms 7252 KB Output is correct
7 Correct 4 ms 7328 KB Output is correct
8 Correct 5 ms 7280 KB Output is correct
9 Correct 5 ms 7252 KB Output is correct
10 Correct 4 ms 7252 KB Output is correct
11 Correct 3 ms 7252 KB Output is correct
12 Correct 4 ms 7252 KB Output is correct
13 Correct 4 ms 7252 KB Output is correct
14 Correct 4 ms 7252 KB Output is correct
15 Correct 4 ms 7252 KB Output is correct
16 Correct 5 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 5 ms 7252 KB Output is correct
20 Correct 4 ms 7252 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 3 ms 7380 KB Output is correct
31 Correct 4 ms 7380 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 5 ms 7312 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 4 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 3 ms 7348 KB Output is correct
47 Correct 4 ms 7380 KB Output is correct
48 Correct 4 ms 7252 KB Output is correct
49 Correct 4 ms 7272 KB Output is correct
50 Correct 5 ms 7508 KB Output is correct
51 Correct 5 ms 7508 KB Output is correct
52 Correct 6 ms 7508 KB Output is correct
53 Correct 6 ms 7508 KB Output is correct
54 Correct 5 ms 7380 KB Output is correct
55 Correct 7 ms 7636 KB Output is correct
56 Correct 5 ms 7636 KB Output is correct
57 Correct 5 ms 7636 KB Output is correct
58 Correct 4 ms 7348 KB Output is correct
59 Correct 4 ms 7252 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 7 ms 7500 KB Output is correct
66 Correct 5 ms 7340 KB Output is correct
67 Correct 5 ms 7252 KB Output is correct
68 Correct 4 ms 7252 KB Output is correct
69 Correct 4 ms 7380 KB Output is correct
70 Correct 4 ms 7380 KB Output is correct
71 Correct 186 ms 26228 KB Output is correct
72 Correct 127 ms 19992 KB Output is correct
73 Correct 183 ms 24936 KB Output is correct
74 Correct 101 ms 17512 KB Output is correct
75 Correct 119 ms 18944 KB Output is correct
76 Correct 289 ms 36648 KB Output is correct
77 Correct 264 ms 34224 KB Output is correct
78 Correct 230 ms 30500 KB Output is correct
79 Correct 222 ms 31724 KB Output is correct
80 Correct 4 ms 7252 KB Output is correct
81 Correct 5 ms 7252 KB Output is correct
82 Correct 6 ms 7508 KB Output is correct
83 Correct 29 ms 10392 KB Output is correct
84 Correct 37 ms 11008 KB Output is correct
85 Correct 10 ms 8148 KB Output is correct
86 Correct 4 ms 7380 KB Output is correct
87 Correct 40 ms 11260 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 7380 KB Output is correct
91 Correct 14 ms 8488 KB Output is correct
92 Correct 51 ms 12028 KB Output is correct
93 Correct 1010 ms 107992 KB Output is correct
94 Correct 581 ms 59796 KB Output is correct
95 Correct 695 ms 69916 KB Output is correct
96 Correct 618 ms 65128 KB Output is correct
97 Correct 546 ms 62320 KB Output is correct
98 Correct 1158 ms 125956 KB Output is correct
99 Correct 1246 ms 129764 KB Output is correct
100 Correct 1158 ms 123700 KB Output is correct
101 Correct 1079 ms 118772 KB Output is correct
102 Correct 956 ms 103548 KB Output is correct
103 Correct 747 ms 80192 KB Output is correct
104 Correct 6 ms 7252 KB Output is correct
105 Correct 4 ms 7252 KB Output is correct
106 Correct 9 ms 7764 KB Output is correct
107 Correct 81 ms 15468 KB Output is correct
108 Correct 201 ms 27020 KB Output is correct
109 Correct 21 ms 9428 KB Output is correct
110 Correct 4 ms 7252 KB Output is correct
111 Correct 111 ms 17484 KB Output is correct
112 Correct 5 ms 7252 KB Output is correct
113 Correct 4 ms 7252 KB Output is correct
114 Correct 7 ms 7636 KB Output is correct
115 Correct 4 ms 7252 KB Output is correct
116 Correct 10 ms 8192 KB Output is correct
117 Correct 202 ms 25904 KB Output is correct