답안 #94236

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
94236 2019-01-17T01:49:35 Z jasony123123 Toys (CEOI18_toy) C++11
79 / 100
5000 ms 7976 KB
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <array>
#include <unordered_map>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;

#define FOR(i,start,end) for(int i=start;i<(int)(end);i++)
#define FORE(i,start,end) for(int i=start;i<=(int)end;i++)
#define RFOR(i,start,end) for(int i = start; i>end; i--)
#define RFORE(i,start,end) for(int i = start; i>=end; i--)
#define all(a) a.begin(), a.end()
#define mt make_tuple
#define mp make_pair
#define v vector
#define sf scanf
#define pf printf
#define dvar(x) cout << #x << " := " << x << "\n"
#define darr(x,n) FOR(i,0,n) cout << #x << "[" << i << "]" << " := " << x[i] << "\n"

typedef long long ll;
typedef long double ld;
typedef pair<int, int > pii;
typedef pair<ll, ll> pll;
//template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T> void minn(T &a, T b) { a = min(a, b); }
template<class T> void maxx(T &a, T b) { a = max(a, b); }

void io() {
#ifdef LOCAL_PROJECT 
	freopen("input.in", "r", stdin); freopen("output.out", "w", stdout);
#else 
	/* online submission */

#endif 
	ios_base::sync_with_stdio(false); cin.tie(NULL);
}

/*************************CEOI 2018 Day 2 P2 - Toy *************************/

v<int> fac;
v<v<int>> ff;
v<v<int>> nex;
v<v<int>> sums;

void combine(v<int> &scur, v<int> &sold, int add) {
	for (auto x : sold)
		scur.push_back(x + add);
	sort(all(scur));
	scur.resize(unique(all(scur)) - scur.begin());
}

int main() {
	io();
	int n; cin >> n;
	for (int i = 1; i*i <= n; i++)
		if (n%i == 0) {
			fac.push_back(i);
			if (i*i != n) fac.push_back(n / i);
		}
	sort(all(fac));

	ff.resize(fac.size());
	ff[0] = {}, ff[fac.size() - 1] = fac;
	FOR(f, 1, fac.size() - 1) {
		for (auto j : fac) {
			if (j*j > fac[f]) break;
			if (fac[f] % j == 0) {
				ff[f].push_back(j);
				if (j*j != fac[f]) ff[f].push_back(fac[f] / j);
			}
		}
		sort(all(ff[f]));
	}

	nex.resize(fac.size());
	FOR(i, 0, ff.size()) {
		for (auto f : ff[i])
			nex[i].push_back(lower_bound(all(fac), fac[i] / f) - fac.begin());
	}

	sums.resize(fac.size());
	sums[0].push_back(0);

	FOR(i, 1, sums.size())
		FOR(j, 1, nex[i].size())
		combine(sums[i], sums[nex[i][j]], ff[i][j] - 1);

	cout << sums.back().size() << "\n";
	for (auto x : sums.back()) cout << x << " ";
	cout << "\n";

/*	darr(fac, fac.size());
	FOR(i, 0, ff.size()) {
		cout << i << " factors: ";
		for (auto f : ff[i]) cout << f << ", ";
		cout << "\n";
	}
	FOR(i, 0, nex.size()) {
		cout << i << " nex idx: ";
		for (auto j : nex[i]) cout << j << ", ";
		cout << "\n";
	}*/
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 292 KB Output is correct
10 Correct 2 ms 252 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 292 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 292 KB Output is correct
10 Correct 2 ms 252 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 292 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 380 KB Output is correct
29 Correct 2 ms 420 KB Output is correct
30 Correct 2 ms 380 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 400 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2 ms 376 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 2 ms 376 KB Output is correct
38 Correct 2 ms 376 KB Output is correct
39 Correct 2 ms 376 KB Output is correct
40 Correct 2 ms 380 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 2 ms 376 KB Output is correct
43 Correct 2 ms 376 KB Output is correct
44 Correct 2 ms 376 KB Output is correct
45 Correct 2 ms 376 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 2 ms 376 KB Output is correct
48 Correct 2 ms 380 KB Output is correct
49 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 292 KB Output is correct
10 Correct 2 ms 252 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 292 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 380 KB Output is correct
29 Correct 2 ms 420 KB Output is correct
30 Correct 2 ms 380 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 400 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2 ms 376 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 2 ms 376 KB Output is correct
38 Correct 2 ms 376 KB Output is correct
39 Correct 2 ms 376 KB Output is correct
40 Correct 2 ms 380 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 2 ms 376 KB Output is correct
43 Correct 2 ms 376 KB Output is correct
44 Correct 2 ms 376 KB Output is correct
45 Correct 2 ms 376 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 2 ms 376 KB Output is correct
48 Correct 2 ms 380 KB Output is correct
49 Correct 2 ms 376 KB Output is correct
50 Correct 7 ms 376 KB Output is correct
51 Correct 6 ms 376 KB Output is correct
52 Correct 6 ms 376 KB Output is correct
53 Correct 5 ms 376 KB Output is correct
54 Correct 4 ms 376 KB Output is correct
55 Correct 9 ms 504 KB Output is correct
56 Correct 8 ms 376 KB Output is correct
57 Correct 8 ms 504 KB Output is correct
58 Correct 2 ms 376 KB Output is correct
59 Correct 2 ms 376 KB Output is correct
60 Correct 2 ms 376 KB Output is correct
61 Correct 4 ms 376 KB Output is correct
62 Correct 3 ms 376 KB Output is correct
63 Correct 2 ms 376 KB Output is correct
64 Correct 2 ms 376 KB Output is correct
65 Correct 4 ms 376 KB Output is correct
66 Correct 2 ms 252 KB Output is correct
67 Correct 2 ms 252 KB Output is correct
68 Correct 2 ms 376 KB Output is correct
69 Correct 2 ms 376 KB Output is correct
70 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 292 KB Output is correct
10 Correct 2 ms 252 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 292 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 380 KB Output is correct
29 Correct 2 ms 420 KB Output is correct
30 Correct 2 ms 380 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 400 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2 ms 376 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 2 ms 376 KB Output is correct
38 Correct 2 ms 376 KB Output is correct
39 Correct 2 ms 376 KB Output is correct
40 Correct 2 ms 380 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 2 ms 376 KB Output is correct
43 Correct 2 ms 376 KB Output is correct
44 Correct 2 ms 376 KB Output is correct
45 Correct 2 ms 376 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 2 ms 376 KB Output is correct
48 Correct 2 ms 380 KB Output is correct
49 Correct 2 ms 376 KB Output is correct
50 Correct 7 ms 376 KB Output is correct
51 Correct 6 ms 376 KB Output is correct
52 Correct 6 ms 376 KB Output is correct
53 Correct 5 ms 376 KB Output is correct
54 Correct 4 ms 376 KB Output is correct
55 Correct 9 ms 504 KB Output is correct
56 Correct 8 ms 376 KB Output is correct
57 Correct 8 ms 504 KB Output is correct
58 Correct 2 ms 376 KB Output is correct
59 Correct 2 ms 376 KB Output is correct
60 Correct 2 ms 376 KB Output is correct
61 Correct 4 ms 376 KB Output is correct
62 Correct 3 ms 376 KB Output is correct
63 Correct 2 ms 376 KB Output is correct
64 Correct 2 ms 376 KB Output is correct
65 Correct 4 ms 376 KB Output is correct
66 Correct 2 ms 252 KB Output is correct
67 Correct 2 ms 252 KB Output is correct
68 Correct 2 ms 376 KB Output is correct
69 Correct 2 ms 376 KB Output is correct
70 Correct 3 ms 376 KB Output is correct
71 Correct 2438 ms 3604 KB Output is correct
72 Correct 1641 ms 3200 KB Output is correct
73 Correct 2023 ms 3448 KB Output is correct
74 Correct 1111 ms 2432 KB Output is correct
75 Correct 1242 ms 2688 KB Output is correct
76 Correct 3726 ms 4856 KB Output is correct
77 Correct 2856 ms 4052 KB Output is correct
78 Correct 2747 ms 3832 KB Output is correct
79 Correct 2531 ms 3760 KB Output is correct
80 Correct 2 ms 380 KB Output is correct
81 Correct 2 ms 376 KB Output is correct
82 Correct 5 ms 376 KB Output is correct
83 Correct 119 ms 1144 KB Output is correct
84 Correct 214 ms 1144 KB Output is correct
85 Correct 27 ms 632 KB Output is correct
86 Correct 2 ms 376 KB Output is correct
87 Correct 216 ms 1276 KB Output is correct
88 Correct 2 ms 376 KB Output is correct
89 Correct 2 ms 376 KB Output is correct
90 Correct 2 ms 376 KB Output is correct
91 Correct 74 ms 760 KB Output is correct
92 Correct 519 ms 1760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 292 KB Output is correct
10 Correct 2 ms 252 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 292 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 380 KB Output is correct
29 Correct 2 ms 420 KB Output is correct
30 Correct 2 ms 380 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 400 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2 ms 376 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 2 ms 376 KB Output is correct
38 Correct 2 ms 376 KB Output is correct
39 Correct 2 ms 376 KB Output is correct
40 Correct 2 ms 380 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 2 ms 376 KB Output is correct
43 Correct 2 ms 376 KB Output is correct
44 Correct 2 ms 376 KB Output is correct
45 Correct 2 ms 376 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 2 ms 376 KB Output is correct
48 Correct 2 ms 380 KB Output is correct
49 Correct 2 ms 376 KB Output is correct
50 Correct 7 ms 376 KB Output is correct
51 Correct 6 ms 376 KB Output is correct
52 Correct 6 ms 376 KB Output is correct
53 Correct 5 ms 376 KB Output is correct
54 Correct 4 ms 376 KB Output is correct
55 Correct 9 ms 504 KB Output is correct
56 Correct 8 ms 376 KB Output is correct
57 Correct 8 ms 504 KB Output is correct
58 Correct 2 ms 376 KB Output is correct
59 Correct 2 ms 376 KB Output is correct
60 Correct 2 ms 376 KB Output is correct
61 Correct 4 ms 376 KB Output is correct
62 Correct 3 ms 376 KB Output is correct
63 Correct 2 ms 376 KB Output is correct
64 Correct 2 ms 376 KB Output is correct
65 Correct 4 ms 376 KB Output is correct
66 Correct 2 ms 252 KB Output is correct
67 Correct 2 ms 252 KB Output is correct
68 Correct 2 ms 376 KB Output is correct
69 Correct 2 ms 376 KB Output is correct
70 Correct 3 ms 376 KB Output is correct
71 Correct 2438 ms 3604 KB Output is correct
72 Correct 1641 ms 3200 KB Output is correct
73 Correct 2023 ms 3448 KB Output is correct
74 Correct 1111 ms 2432 KB Output is correct
75 Correct 1242 ms 2688 KB Output is correct
76 Correct 3726 ms 4856 KB Output is correct
77 Correct 2856 ms 4052 KB Output is correct
78 Correct 2747 ms 3832 KB Output is correct
79 Correct 2531 ms 3760 KB Output is correct
80 Correct 2 ms 380 KB Output is correct
81 Correct 2 ms 376 KB Output is correct
82 Correct 5 ms 376 KB Output is correct
83 Correct 119 ms 1144 KB Output is correct
84 Correct 214 ms 1144 KB Output is correct
85 Correct 27 ms 632 KB Output is correct
86 Correct 2 ms 376 KB Output is correct
87 Correct 216 ms 1276 KB Output is correct
88 Correct 2 ms 376 KB Output is correct
89 Correct 2 ms 376 KB Output is correct
90 Correct 2 ms 376 KB Output is correct
91 Correct 74 ms 760 KB Output is correct
92 Correct 519 ms 1760 KB Output is correct
93 Execution timed out 5026 ms 7976 KB Time limit exceeded
94 Halted 0 ms 0 KB -