답안 #826135

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
826135 2023-08-15T10:35:45 Z dxz05 Toys (CEOI18_toy) C++17
100 / 100
631 ms 20388 KB
//#pragma GCC optimize("Ofast,O3,unroll-loops")
//#pragma GCC target("avx,avx2")

#include <bits/stdc++.h>
 
using namespace std;

#define all(x) (x).begin(), (x).end()

vector<pair<int, int>> dp[1500];

int main(){
	ios_base::sync_with_stdio(false);
	
	int n;
	cin >> n;
	
	vector<int> divisors;
	for (int d = 1; d * d <= n; d++){
		if (n % d == 0){
			divisors.push_back(d);
			if (n != d * d) divisors.push_back(n / d);
		}
	}
	
	sort(all(divisors));
	
	int m = (int) divisors.size();
	
	dp[0].emplace_back(0, 0);
	
	for (int i = 1; i < m; i++){
		int d = divisors[i];
		
		vector<pair<int, int>> v;
		
		int k = m - 1;
		for (int j = 1; j <= i; j++){
			int x = divisors[j];
			if (d % x) continue;
			
			int _d = d / x;
			while (divisors[k] > _d) k--;
			
			for (auto [l, r] : dp[k]){
				v.emplace_back(l + x - 1, r + x - 1);
			}
		}
		
		sort(all(v));
		
		int m = (int) v.size();
		for (int j = 0; j < m;){
			int l = v[j].first, r = v[j].second;
			int k = j;
			while (k < m && v[k].first <= r + 1){
				l = min(l, v[k].first);
				r = max(r, v[k].second);
				k++;
			}
			dp[i].emplace_back(l, r);
			j = k;
		}
		
	}
	
	int ans = 0;
	for (auto [l, r] : dp[m - 1]){
		ans += r - l + 1;
	}
	
	cout << ans << endl;
	for (auto [l, r] : dp[m - 1]){
		while (l <= r){
			cout << l << ' ';
			l++;
		}
	}
	cout << endl;
	
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 360 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 356 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 352 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 468 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 356 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 0 ms 360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 360 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 356 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 352 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 468 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 356 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 0 ms 360 KB Output is correct
26 Correct 1 ms 356 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 1 ms 356 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 0 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 0 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 0 ms 352 KB Output is correct
45 Correct 0 ms 340 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 0 ms 340 KB Output is correct
48 Correct 0 ms 340 KB Output is correct
49 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 360 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 356 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 352 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 468 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 356 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 0 ms 360 KB Output is correct
26 Correct 1 ms 356 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 1 ms 356 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 0 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 0 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 0 ms 352 KB Output is correct
45 Correct 0 ms 340 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 0 ms 340 KB Output is correct
48 Correct 0 ms 340 KB Output is correct
49 Correct 0 ms 340 KB Output is correct
50 Correct 1 ms 360 KB Output is correct
51 Correct 1 ms 356 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 2 ms 340 KB Output is correct
56 Correct 2 ms 340 KB Output is correct
57 Correct 2 ms 340 KB Output is correct
58 Correct 0 ms 356 KB Output is correct
59 Correct 0 ms 340 KB Output is correct
60 Correct 0 ms 340 KB Output is correct
61 Correct 1 ms 340 KB Output is correct
62 Correct 1 ms 340 KB Output is correct
63 Correct 1 ms 340 KB Output is correct
64 Correct 0 ms 340 KB Output is correct
65 Correct 1 ms 356 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 0 ms 352 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 1 ms 356 KB Output is correct
70 Correct 1 ms 352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 360 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 356 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 352 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 468 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 356 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 0 ms 360 KB Output is correct
26 Correct 1 ms 356 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 1 ms 356 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 0 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 0 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 0 ms 352 KB Output is correct
45 Correct 0 ms 340 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 0 ms 340 KB Output is correct
48 Correct 0 ms 340 KB Output is correct
49 Correct 0 ms 340 KB Output is correct
50 Correct 1 ms 360 KB Output is correct
51 Correct 1 ms 356 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 2 ms 340 KB Output is correct
56 Correct 2 ms 340 KB Output is correct
57 Correct 2 ms 340 KB Output is correct
58 Correct 0 ms 356 KB Output is correct
59 Correct 0 ms 340 KB Output is correct
60 Correct 0 ms 340 KB Output is correct
61 Correct 1 ms 340 KB Output is correct
62 Correct 1 ms 340 KB Output is correct
63 Correct 1 ms 340 KB Output is correct
64 Correct 0 ms 340 KB Output is correct
65 Correct 1 ms 356 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 0 ms 352 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 1 ms 356 KB Output is correct
70 Correct 1 ms 352 KB Output is correct
71 Correct 108 ms 5196 KB Output is correct
72 Correct 83 ms 3956 KB Output is correct
73 Correct 93 ms 3760 KB Output is correct
74 Correct 62 ms 2912 KB Output is correct
75 Correct 74 ms 3024 KB Output is correct
76 Correct 146 ms 5724 KB Output is correct
77 Correct 115 ms 5044 KB Output is correct
78 Correct 117 ms 5164 KB Output is correct
79 Correct 101 ms 3884 KB Output is correct
80 Correct 0 ms 340 KB Output is correct
81 Correct 0 ms 340 KB Output is correct
82 Correct 1 ms 340 KB Output is correct
83 Correct 10 ms 924 KB Output is correct
84 Correct 18 ms 1140 KB Output is correct
85 Correct 4 ms 596 KB Output is correct
86 Correct 1 ms 340 KB Output is correct
87 Correct 18 ms 1524 KB Output is correct
88 Correct 1 ms 360 KB Output is correct
89 Correct 1 ms 340 KB Output is correct
90 Correct 1 ms 356 KB Output is correct
91 Correct 7 ms 1016 KB Output is correct
92 Correct 37 ms 2876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 360 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 356 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 352 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 468 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 356 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 0 ms 360 KB Output is correct
26 Correct 1 ms 356 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 1 ms 356 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 0 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 0 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 0 ms 352 KB Output is correct
45 Correct 0 ms 340 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 0 ms 340 KB Output is correct
48 Correct 0 ms 340 KB Output is correct
49 Correct 0 ms 340 KB Output is correct
50 Correct 1 ms 360 KB Output is correct
51 Correct 1 ms 356 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 2 ms 340 KB Output is correct
56 Correct 2 ms 340 KB Output is correct
57 Correct 2 ms 340 KB Output is correct
58 Correct 0 ms 356 KB Output is correct
59 Correct 0 ms 340 KB Output is correct
60 Correct 0 ms 340 KB Output is correct
61 Correct 1 ms 340 KB Output is correct
62 Correct 1 ms 340 KB Output is correct
63 Correct 1 ms 340 KB Output is correct
64 Correct 0 ms 340 KB Output is correct
65 Correct 1 ms 356 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 0 ms 352 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 1 ms 356 KB Output is correct
70 Correct 1 ms 352 KB Output is correct
71 Correct 108 ms 5196 KB Output is correct
72 Correct 83 ms 3956 KB Output is correct
73 Correct 93 ms 3760 KB Output is correct
74 Correct 62 ms 2912 KB Output is correct
75 Correct 74 ms 3024 KB Output is correct
76 Correct 146 ms 5724 KB Output is correct
77 Correct 115 ms 5044 KB Output is correct
78 Correct 117 ms 5164 KB Output is correct
79 Correct 101 ms 3884 KB Output is correct
80 Correct 0 ms 340 KB Output is correct
81 Correct 0 ms 340 KB Output is correct
82 Correct 1 ms 340 KB Output is correct
83 Correct 10 ms 924 KB Output is correct
84 Correct 18 ms 1140 KB Output is correct
85 Correct 4 ms 596 KB Output is correct
86 Correct 1 ms 340 KB Output is correct
87 Correct 18 ms 1524 KB Output is correct
88 Correct 1 ms 360 KB Output is correct
89 Correct 1 ms 340 KB Output is correct
90 Correct 1 ms 356 KB Output is correct
91 Correct 7 ms 1016 KB Output is correct
92 Correct 37 ms 2876 KB Output is correct
93 Correct 551 ms 19568 KB Output is correct
94 Correct 361 ms 13904 KB Output is correct
95 Correct 416 ms 13984 KB Output is correct
96 Correct 338 ms 12044 KB Output is correct
97 Correct 273 ms 10444 KB Output is correct
98 Correct 564 ms 19740 KB Output is correct
99 Correct 631 ms 20388 KB Output is correct
100 Correct 557 ms 19488 KB Output is correct
101 Correct 477 ms 14140 KB Output is correct
102 Correct 409 ms 13076 KB Output is correct
103 Correct 398 ms 13632 KB Output is correct
104 Correct 1 ms 356 KB Output is correct
105 Correct 1 ms 340 KB Output is correct
106 Correct 1 ms 352 KB Output is correct
107 Correct 28 ms 1760 KB Output is correct
108 Correct 98 ms 5012 KB Output is correct
109 Correct 9 ms 992 KB Output is correct
110 Correct 1 ms 340 KB Output is correct
111 Correct 47 ms 2900 KB Output is correct
112 Correct 1 ms 340 KB Output is correct
113 Correct 1 ms 340 KB Output is correct
114 Correct 3 ms 704 KB Output is correct
115 Correct 1 ms 340 KB Output is correct
116 Correct 5 ms 784 KB Output is correct
117 Correct 155 ms 9988 KB Output is correct