Submission #94238

# Submission time Handle Problem Language Result Execution time Memory
94238 2019-01-17T01:54:26 Z jasony123123 Toys (CEOI18_toy) C++11
100 / 100
2991 ms 88460 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<set<int>> sums;

void combine(set<int> &scur, set<int> &sold, int add) {
	for (auto x : sold)
		scur.insert(x + add);
}

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].insert(0);

	FOR(i, 1, sums.size())
		FOR(j, 1, nex[i].size())
		if (nex[i][j] != i)
			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";
	}*/
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 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 376 KB Output is correct
10 Correct 2 ms 376 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 256 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 376 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 376 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 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 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 376 KB Output is correct
10 Correct 2 ms 376 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 256 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 376 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 376 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 348 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 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 504 KB Output is correct
32 Correct 2 ms 376 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 376 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 376 KB Output is correct
49 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 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 376 KB Output is correct
10 Correct 2 ms 376 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 256 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 376 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 376 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 348 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 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 504 KB Output is correct
32 Correct 2 ms 376 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 376 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 376 KB Output is correct
49 Correct 2 ms 376 KB Output is correct
50 Correct 4 ms 632 KB Output is correct
51 Correct 4 ms 604 KB Output is correct
52 Correct 4 ms 632 KB Output is correct
53 Correct 4 ms 632 KB Output is correct
54 Correct 3 ms 504 KB Output is correct
55 Correct 6 ms 760 KB Output is correct
56 Correct 5 ms 760 KB Output is correct
57 Correct 5 ms 760 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 3 ms 504 KB Output is correct
62 Correct 2 ms 376 KB Output is correct
63 Correct 2 ms 380 KB Output is correct
64 Correct 2 ms 376 KB Output is correct
65 Correct 3 ms 504 KB Output is correct
66 Correct 2 ms 376 KB Output is correct
67 Correct 2 ms 376 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 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 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 376 KB Output is correct
10 Correct 2 ms 376 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 256 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 376 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 376 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 348 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 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 504 KB Output is correct
32 Correct 2 ms 376 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 376 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 376 KB Output is correct
49 Correct 2 ms 376 KB Output is correct
50 Correct 4 ms 632 KB Output is correct
51 Correct 4 ms 604 KB Output is correct
52 Correct 4 ms 632 KB Output is correct
53 Correct 4 ms 632 KB Output is correct
54 Correct 3 ms 504 KB Output is correct
55 Correct 6 ms 760 KB Output is correct
56 Correct 5 ms 760 KB Output is correct
57 Correct 5 ms 760 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 3 ms 504 KB Output is correct
62 Correct 2 ms 376 KB Output is correct
63 Correct 2 ms 380 KB Output is correct
64 Correct 2 ms 376 KB Output is correct
65 Correct 3 ms 504 KB Output is correct
66 Correct 2 ms 376 KB Output is correct
67 Correct 2 ms 376 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 504 KB Output is correct
71 Correct 423 ms 19292 KB Output is correct
72 Correct 282 ms 14584 KB Output is correct
73 Correct 405 ms 17064 KB Output is correct
74 Correct 205 ms 11512 KB Output is correct
75 Correct 232 ms 12260 KB Output is correct
76 Correct 644 ms 25672 KB Output is correct
77 Correct 621 ms 22520 KB Output is correct
78 Correct 512 ms 21212 KB Output is correct
79 Correct 522 ms 20712 KB Output is correct
80 Correct 2 ms 376 KB Output is correct
81 Correct 2 ms 376 KB Output is correct
82 Correct 4 ms 632 KB Output is correct
83 Correct 54 ms 3708 KB Output is correct
84 Correct 66 ms 4572 KB Output is correct
85 Correct 14 ms 1528 KB Output is correct
86 Correct 2 ms 376 KB Output is correct
87 Correct 75 ms 5112 KB Output is correct
88 Correct 2 ms 376 KB Output is correct
89 Correct 8 ms 376 KB Output is correct
90 Correct 2 ms 376 KB Output is correct
91 Correct 19 ms 2168 KB Output is correct
92 Correct 91 ms 6988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 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 376 KB Output is correct
10 Correct 2 ms 376 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 256 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 376 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 376 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 348 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 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 504 KB Output is correct
32 Correct 2 ms 376 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 376 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 376 KB Output is correct
49 Correct 2 ms 376 KB Output is correct
50 Correct 4 ms 632 KB Output is correct
51 Correct 4 ms 604 KB Output is correct
52 Correct 4 ms 632 KB Output is correct
53 Correct 4 ms 632 KB Output is correct
54 Correct 3 ms 504 KB Output is correct
55 Correct 6 ms 760 KB Output is correct
56 Correct 5 ms 760 KB Output is correct
57 Correct 5 ms 760 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 3 ms 504 KB Output is correct
62 Correct 2 ms 376 KB Output is correct
63 Correct 2 ms 380 KB Output is correct
64 Correct 2 ms 376 KB Output is correct
65 Correct 3 ms 504 KB Output is correct
66 Correct 2 ms 376 KB Output is correct
67 Correct 2 ms 376 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 504 KB Output is correct
71 Correct 423 ms 19292 KB Output is correct
72 Correct 282 ms 14584 KB Output is correct
73 Correct 405 ms 17064 KB Output is correct
74 Correct 205 ms 11512 KB Output is correct
75 Correct 232 ms 12260 KB Output is correct
76 Correct 644 ms 25672 KB Output is correct
77 Correct 621 ms 22520 KB Output is correct
78 Correct 512 ms 21212 KB Output is correct
79 Correct 522 ms 20712 KB Output is correct
80 Correct 2 ms 376 KB Output is correct
81 Correct 2 ms 376 KB Output is correct
82 Correct 4 ms 632 KB Output is correct
83 Correct 54 ms 3708 KB Output is correct
84 Correct 66 ms 4572 KB Output is correct
85 Correct 14 ms 1528 KB Output is correct
86 Correct 2 ms 376 KB Output is correct
87 Correct 75 ms 5112 KB Output is correct
88 Correct 2 ms 376 KB Output is correct
89 Correct 8 ms 376 KB Output is correct
90 Correct 2 ms 376 KB Output is correct
91 Correct 19 ms 2168 KB Output is correct
92 Correct 91 ms 6988 KB Output is correct
93 Correct 2561 ms 79048 KB Output is correct
94 Correct 1448 ms 53444 KB Output is correct
95 Correct 1552 ms 55964 KB Output is correct
96 Correct 1407 ms 50156 KB Output is correct
97 Correct 1364 ms 45432 KB Output is correct
98 Correct 2948 ms 86860 KB Output is correct
99 Correct 2991 ms 88460 KB Output is correct
100 Correct 2699 ms 84984 KB Output is correct
101 Correct 2534 ms 78484 KB Output is correct
102 Correct 2204 ms 70648 KB Output is correct
103 Correct 1772 ms 63668 KB Output is correct
104 Correct 2 ms 252 KB Output is correct
105 Correct 2 ms 376 KB Output is correct
106 Correct 7 ms 1016 KB Output is correct
107 Correct 177 ms 9828 KB Output is correct
108 Correct 431 ms 20672 KB Output is correct
109 Correct 35 ms 3320 KB Output is correct
110 Correct 2 ms 376 KB Output is correct
111 Correct 241 ms 12336 KB Output is correct
112 Correct 2 ms 376 KB Output is correct
113 Correct 2 ms 376 KB Output is correct
114 Correct 7 ms 1016 KB Output is correct
115 Correct 2 ms 252 KB Output is correct
116 Correct 14 ms 1784 KB Output is correct
117 Correct 618 ms 25308 KB Output is correct