답안 #825315

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
825315 2023-08-14T17:32:47 Z alex_2008 Toys (CEOI18_toy) C++14
79 / 100
5000 ms 70120 KB
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
const int NN = 2e3 + 10;
int main() {
	int n;
	cin >> n;
	if (n == 1) {
		cout << "1\n";
		cout << "0\n";
		return 0;
	}
	vector <int> v;
	int j;
	for (int i = 1; i * i <= n; i++) {
		if (n % i == 0) v.push_back(i);
		if (i * i < n) j = i;
	} 
	for (int i = j; i >= 1; i--) {
		if (n % i == 0) {
			v.push_back(n / i);
		}
	}
	unordered_map <int, int> mp, yp;
	int N = (int)v.size();
	for (int i = 1; i <= (int)v.size(); i++) {
		mp[i] = v[i - 1];
		yp[v[i - 1]] = i;
	}
	vector<unordered_set<int>> ans(N + 1);
	ans[1] = {0};
	for (int i = 1; i < N; i++) {
		for (auto it : ans[i]) {
			for (int j = 2; j <= N - i + 1; j++) {
				if (yp[mp[i] * mp[j]]) {
					ans[yp[mp[i] * mp[j]]].insert(it + mp[j] - 1);
				}
			}
		}
	}
	vector <int> vv(ans[N].begin(), ans[N].end()); 
	sort(vv.begin(), vv.end());
	cout << (int)vv.size() << "\n";
	for (auto it : vv) {
		cout << it << " ";
	}
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:18:6: warning: 'j' may be used uninitialized in this function [-Wmaybe-uninitialized]
   18 |  int j;
      |      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 300 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 300 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 296 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 296 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 300 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 300 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 296 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 296 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 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 304 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 300 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 300 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 296 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 296 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 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 304 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 4 ms 596 KB Output is correct
51 Correct 4 ms 556 KB Output is correct
52 Correct 3 ms 468 KB Output is correct
53 Correct 3 ms 468 KB Output is correct
54 Correct 2 ms 468 KB Output is correct
55 Correct 5 ms 680 KB Output is correct
56 Correct 5 ms 596 KB Output is correct
57 Correct 5 ms 596 KB Output is correct
58 Correct 0 ms 300 KB Output is correct
59 Correct 0 ms 212 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 3 ms 468 KB Output is correct
62 Correct 1 ms 340 KB Output is correct
63 Correct 1 ms 296 KB Output is correct
64 Correct 0 ms 212 KB Output is correct
65 Correct 2 ms 468 KB Output is correct
66 Correct 0 ms 212 KB Output is correct
67 Correct 0 ms 212 KB Output is correct
68 Correct 0 ms 212 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 2 ms 432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 300 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 300 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 296 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 296 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 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 304 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 4 ms 596 KB Output is correct
51 Correct 4 ms 556 KB Output is correct
52 Correct 3 ms 468 KB Output is correct
53 Correct 3 ms 468 KB Output is correct
54 Correct 2 ms 468 KB Output is correct
55 Correct 5 ms 680 KB Output is correct
56 Correct 5 ms 596 KB Output is correct
57 Correct 5 ms 596 KB Output is correct
58 Correct 0 ms 300 KB Output is correct
59 Correct 0 ms 212 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 3 ms 468 KB Output is correct
62 Correct 1 ms 340 KB Output is correct
63 Correct 1 ms 296 KB Output is correct
64 Correct 0 ms 212 KB Output is correct
65 Correct 2 ms 468 KB Output is correct
66 Correct 0 ms 212 KB Output is correct
67 Correct 0 ms 212 KB Output is correct
68 Correct 0 ms 212 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 2 ms 432 KB Output is correct
71 Correct 1207 ms 17512 KB Output is correct
72 Correct 827 ms 13268 KB Output is correct
73 Correct 939 ms 15460 KB Output is correct
74 Correct 565 ms 10556 KB Output is correct
75 Correct 565 ms 11288 KB Output is correct
76 Correct 1741 ms 23216 KB Output is correct
77 Correct 1346 ms 20484 KB Output is correct
78 Correct 1243 ms 19312 KB Output is correct
79 Correct 1148 ms 18716 KB Output is correct
80 Correct 1 ms 212 KB Output is correct
81 Correct 1 ms 300 KB Output is correct
82 Correct 3 ms 596 KB Output is correct
83 Correct 52 ms 3268 KB Output is correct
84 Correct 88 ms 3988 KB Output is correct
85 Correct 13 ms 1364 KB Output is correct
86 Correct 1 ms 340 KB Output is correct
87 Correct 106 ms 4628 KB Output is correct
88 Correct 1 ms 212 KB Output is correct
89 Correct 1 ms 212 KB Output is correct
90 Correct 1 ms 304 KB Output is correct
91 Correct 36 ms 2080 KB Output is correct
92 Correct 272 ms 6456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 300 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 300 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 296 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 296 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 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 304 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 4 ms 596 KB Output is correct
51 Correct 4 ms 556 KB Output is correct
52 Correct 3 ms 468 KB Output is correct
53 Correct 3 ms 468 KB Output is correct
54 Correct 2 ms 468 KB Output is correct
55 Correct 5 ms 680 KB Output is correct
56 Correct 5 ms 596 KB Output is correct
57 Correct 5 ms 596 KB Output is correct
58 Correct 0 ms 300 KB Output is correct
59 Correct 0 ms 212 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 3 ms 468 KB Output is correct
62 Correct 1 ms 340 KB Output is correct
63 Correct 1 ms 296 KB Output is correct
64 Correct 0 ms 212 KB Output is correct
65 Correct 2 ms 468 KB Output is correct
66 Correct 0 ms 212 KB Output is correct
67 Correct 0 ms 212 KB Output is correct
68 Correct 0 ms 212 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 2 ms 432 KB Output is correct
71 Correct 1207 ms 17512 KB Output is correct
72 Correct 827 ms 13268 KB Output is correct
73 Correct 939 ms 15460 KB Output is correct
74 Correct 565 ms 10556 KB Output is correct
75 Correct 565 ms 11288 KB Output is correct
76 Correct 1741 ms 23216 KB Output is correct
77 Correct 1346 ms 20484 KB Output is correct
78 Correct 1243 ms 19312 KB Output is correct
79 Correct 1148 ms 18716 KB Output is correct
80 Correct 1 ms 212 KB Output is correct
81 Correct 1 ms 300 KB Output is correct
82 Correct 3 ms 596 KB Output is correct
83 Correct 52 ms 3268 KB Output is correct
84 Correct 88 ms 3988 KB Output is correct
85 Correct 13 ms 1364 KB Output is correct
86 Correct 1 ms 340 KB Output is correct
87 Correct 106 ms 4628 KB Output is correct
88 Correct 1 ms 212 KB Output is correct
89 Correct 1 ms 212 KB Output is correct
90 Correct 1 ms 304 KB Output is correct
91 Correct 36 ms 2080 KB Output is correct
92 Correct 272 ms 6456 KB Output is correct
93 Execution timed out 5070 ms 70120 KB Time limit exceeded
94 Halted 0 ms 0 KB -