Submission #405823

# Submission time Handle Problem Language Result Execution time Memory
405823 2021-05-16T23:26:49 Z abdzag Toys (CEOI18_toy) C++17
59 / 100
5000 ms 201032 KB
#include<bits/stdc++.h>
#include<unordered_map>
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define rrep(i,a,b) for(int i=int(a);i>int(b);i--)
#define all(v) v.begin(),v.end()
#define trav(a,v) for(auto&a:v)
#define  sz(a) a.size()
typedef long double ld;
using namespace std;
const long long inf = 1e15;
typedef long long ll;
typedef unsigned long long ull;
vector<multiset<ll>> res;
int main() {
	cin.sync_with_stdio(false);
	vector<ll> primes;
	map<ll, bool> is_prime;
	primes.push_back(2);
	rep(i, 3, 1e6) {
		ll val = sqrt(i);
		val++;
		ll ind = upper_bound(all(primes), val) - primes.begin();
		bool done = true;
		rep(j, 0, ind) {
			if (i % primes[j] == 0) {
				done = false;
				break;
			}
		}
		if (done) {
			is_prime[i] = 1;
			primes.push_back(i);
		}
	}
	ll n;
	cin >> n;
	ll cur = n;
	vector<ll> v;
	rep(i, 0, primes.size()) {
		if (cur % primes[i] == 0) {
			v.push_back(primes[i]);
			cur /= primes[i];
			i--;
		}
	}
	if (cur != 1)v.push_back(cur);
	vector<ll> pr;
	map<multiset<ll>, bool> visited;
	queue<pair<multiset<ll>, multiset<ll>>> q;
	multiset<ll>node;
	multiset<ll> v2;
	trav(a, v)v2.insert(a);
	q.emplace(v2, node);
	while (!q.empty()) {
		pair<multiset<ll>, multiset<ll>> cur = q.front();
		q.pop();
		ll counter = 0;
		if (cur.first.size() == 0)res.push_back(cur.second);

		trav(a, cur.first) {

			multiset<ll> ny = cur.first;
			multiset<ll> ny2;
			vector<ll> ny20;
			trav(a, cur.second)ny20.push_back(a);
			ny.erase(ny.find(a));
			rep(j, 0, cur.second.size()) {
				ny2.clear();
				rep(z, 0, cur.second.size()) {
					if (z == j) {
						ny2.insert(a * ny20[z]);
					}
					else ny2.insert(ny20[z]);
				}
				if (!visited[ny2]) {
					visited[ny2] = 1;
					q.emplace(make_pair(ny, ny2));
				}
			}
			ny2 = cur.second;
			ny2.insert(a);
			if (!visited[ny2]) {
				visited[ny2] = 1;
				q.emplace(make_pair(ny, ny2));
			}
		}
	}
	set<ll> ans;
	rep(i, 0, res.size()) {
		ll val = 0;
		trav(a, res[i]) {
			val += a - 1;
		}
		ans.insert(val);
	}
	cout << ans.size() << endl;
	trav(a, ans)cout << a << " ";
	return 0;
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:57:6: warning: unused variable 'counter' [-Wunused-variable]
   57 |   ll counter = 0;
      |      ^~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 139 ms 5796 KB Output is correct
2 Correct 140 ms 5724 KB Output is correct
3 Correct 139 ms 5724 KB Output is correct
4 Correct 140 ms 5816 KB Output is correct
5 Correct 139 ms 5880 KB Output is correct
6 Correct 139 ms 5752 KB Output is correct
7 Correct 139 ms 5820 KB Output is correct
8 Correct 138 ms 5740 KB Output is correct
9 Correct 139 ms 5924 KB Output is correct
10 Correct 141 ms 5760 KB Output is correct
11 Correct 141 ms 5816 KB Output is correct
12 Correct 140 ms 5828 KB Output is correct
13 Correct 139 ms 5916 KB Output is correct
14 Correct 138 ms 5820 KB Output is correct
15 Correct 138 ms 5824 KB Output is correct
16 Correct 140 ms 5844 KB Output is correct
17 Correct 140 ms 5820 KB Output is correct
18 Correct 140 ms 5780 KB Output is correct
19 Correct 140 ms 5772 KB Output is correct
20 Correct 141 ms 5812 KB Output is correct
21 Correct 139 ms 5780 KB Output is correct
22 Correct 139 ms 5764 KB Output is correct
23 Correct 140 ms 5784 KB Output is correct
24 Correct 141 ms 5832 KB Output is correct
25 Correct 142 ms 5792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 139 ms 5796 KB Output is correct
2 Correct 140 ms 5724 KB Output is correct
3 Correct 139 ms 5724 KB Output is correct
4 Correct 140 ms 5816 KB Output is correct
5 Correct 139 ms 5880 KB Output is correct
6 Correct 139 ms 5752 KB Output is correct
7 Correct 139 ms 5820 KB Output is correct
8 Correct 138 ms 5740 KB Output is correct
9 Correct 139 ms 5924 KB Output is correct
10 Correct 141 ms 5760 KB Output is correct
11 Correct 141 ms 5816 KB Output is correct
12 Correct 140 ms 5828 KB Output is correct
13 Correct 139 ms 5916 KB Output is correct
14 Correct 138 ms 5820 KB Output is correct
15 Correct 138 ms 5824 KB Output is correct
16 Correct 140 ms 5844 KB Output is correct
17 Correct 140 ms 5820 KB Output is correct
18 Correct 140 ms 5780 KB Output is correct
19 Correct 140 ms 5772 KB Output is correct
20 Correct 141 ms 5812 KB Output is correct
21 Correct 139 ms 5780 KB Output is correct
22 Correct 139 ms 5764 KB Output is correct
23 Correct 140 ms 5784 KB Output is correct
24 Correct 141 ms 5832 KB Output is correct
25 Correct 142 ms 5792 KB Output is correct
26 Correct 151 ms 6608 KB Output is correct
27 Correct 149 ms 6456 KB Output is correct
28 Correct 142 ms 6028 KB Output is correct
29 Correct 143 ms 6064 KB Output is correct
30 Correct 143 ms 5856 KB Output is correct
31 Correct 162 ms 6988 KB Output is correct
32 Correct 156 ms 6552 KB Output is correct
33 Correct 150 ms 6456 KB Output is correct
34 Correct 139 ms 5772 KB Output is correct
35 Correct 140 ms 5816 KB Output is correct
36 Correct 146 ms 5940 KB Output is correct
37 Correct 152 ms 6424 KB Output is correct
38 Correct 141 ms 5944 KB Output is correct
39 Correct 138 ms 5852 KB Output is correct
40 Correct 148 ms 6328 KB Output is correct
41 Correct 142 ms 5796 KB Output is correct
42 Correct 143 ms 5788 KB Output is correct
43 Correct 141 ms 5828 KB Output is correct
44 Correct 141 ms 5940 KB Output is correct
45 Correct 144 ms 5924 KB Output is correct
46 Correct 139 ms 5852 KB Output is correct
47 Correct 152 ms 6160 KB Output is correct
48 Correct 144 ms 5800 KB Output is correct
49 Correct 143 ms 5836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 139 ms 5796 KB Output is correct
2 Correct 140 ms 5724 KB Output is correct
3 Correct 139 ms 5724 KB Output is correct
4 Correct 140 ms 5816 KB Output is correct
5 Correct 139 ms 5880 KB Output is correct
6 Correct 139 ms 5752 KB Output is correct
7 Correct 139 ms 5820 KB Output is correct
8 Correct 138 ms 5740 KB Output is correct
9 Correct 139 ms 5924 KB Output is correct
10 Correct 141 ms 5760 KB Output is correct
11 Correct 141 ms 5816 KB Output is correct
12 Correct 140 ms 5828 KB Output is correct
13 Correct 139 ms 5916 KB Output is correct
14 Correct 138 ms 5820 KB Output is correct
15 Correct 138 ms 5824 KB Output is correct
16 Correct 140 ms 5844 KB Output is correct
17 Correct 140 ms 5820 KB Output is correct
18 Correct 140 ms 5780 KB Output is correct
19 Correct 140 ms 5772 KB Output is correct
20 Correct 141 ms 5812 KB Output is correct
21 Correct 139 ms 5780 KB Output is correct
22 Correct 139 ms 5764 KB Output is correct
23 Correct 140 ms 5784 KB Output is correct
24 Correct 141 ms 5832 KB Output is correct
25 Correct 142 ms 5792 KB Output is correct
26 Correct 151 ms 6608 KB Output is correct
27 Correct 149 ms 6456 KB Output is correct
28 Correct 142 ms 6028 KB Output is correct
29 Correct 143 ms 6064 KB Output is correct
30 Correct 143 ms 5856 KB Output is correct
31 Correct 162 ms 6988 KB Output is correct
32 Correct 156 ms 6552 KB Output is correct
33 Correct 150 ms 6456 KB Output is correct
34 Correct 139 ms 5772 KB Output is correct
35 Correct 140 ms 5816 KB Output is correct
36 Correct 146 ms 5940 KB Output is correct
37 Correct 152 ms 6424 KB Output is correct
38 Correct 141 ms 5944 KB Output is correct
39 Correct 138 ms 5852 KB Output is correct
40 Correct 148 ms 6328 KB Output is correct
41 Correct 142 ms 5796 KB Output is correct
42 Correct 143 ms 5788 KB Output is correct
43 Correct 141 ms 5828 KB Output is correct
44 Correct 141 ms 5940 KB Output is correct
45 Correct 144 ms 5924 KB Output is correct
46 Correct 139 ms 5852 KB Output is correct
47 Correct 152 ms 6160 KB Output is correct
48 Correct 144 ms 5800 KB Output is correct
49 Correct 143 ms 5836 KB Output is correct
50 Correct 216 ms 9536 KB Output is correct
51 Correct 197 ms 9008 KB Output is correct
52 Correct 230 ms 10016 KB Output is correct
53 Correct 213 ms 9576 KB Output is correct
54 Correct 162 ms 7216 KB Output is correct
55 Correct 328 ms 13468 KB Output is correct
56 Correct 331 ms 13012 KB Output is correct
57 Correct 271 ms 11328 KB Output is correct
58 Correct 139 ms 5740 KB Output is correct
59 Correct 141 ms 5812 KB Output is correct
60 Correct 150 ms 6212 KB Output is correct
61 Correct 242 ms 9448 KB Output is correct
62 Correct 158 ms 6960 KB Output is correct
63 Correct 149 ms 6328 KB Output is correct
64 Correct 141 ms 5812 KB Output is correct
65 Correct 186 ms 8124 KB Output is correct
66 Correct 141 ms 5816 KB Output is correct
67 Correct 141 ms 5748 KB Output is correct
68 Correct 139 ms 5780 KB Output is correct
69 Correct 144 ms 6080 KB Output is correct
70 Correct 153 ms 6716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 139 ms 5796 KB Output is correct
2 Correct 140 ms 5724 KB Output is correct
3 Correct 139 ms 5724 KB Output is correct
4 Correct 140 ms 5816 KB Output is correct
5 Correct 139 ms 5880 KB Output is correct
6 Correct 139 ms 5752 KB Output is correct
7 Correct 139 ms 5820 KB Output is correct
8 Correct 138 ms 5740 KB Output is correct
9 Correct 139 ms 5924 KB Output is correct
10 Correct 141 ms 5760 KB Output is correct
11 Correct 141 ms 5816 KB Output is correct
12 Correct 140 ms 5828 KB Output is correct
13 Correct 139 ms 5916 KB Output is correct
14 Correct 138 ms 5820 KB Output is correct
15 Correct 138 ms 5824 KB Output is correct
16 Correct 140 ms 5844 KB Output is correct
17 Correct 140 ms 5820 KB Output is correct
18 Correct 140 ms 5780 KB Output is correct
19 Correct 140 ms 5772 KB Output is correct
20 Correct 141 ms 5812 KB Output is correct
21 Correct 139 ms 5780 KB Output is correct
22 Correct 139 ms 5764 KB Output is correct
23 Correct 140 ms 5784 KB Output is correct
24 Correct 141 ms 5832 KB Output is correct
25 Correct 142 ms 5792 KB Output is correct
26 Correct 151 ms 6608 KB Output is correct
27 Correct 149 ms 6456 KB Output is correct
28 Correct 142 ms 6028 KB Output is correct
29 Correct 143 ms 6064 KB Output is correct
30 Correct 143 ms 5856 KB Output is correct
31 Correct 162 ms 6988 KB Output is correct
32 Correct 156 ms 6552 KB Output is correct
33 Correct 150 ms 6456 KB Output is correct
34 Correct 139 ms 5772 KB Output is correct
35 Correct 140 ms 5816 KB Output is correct
36 Correct 146 ms 5940 KB Output is correct
37 Correct 152 ms 6424 KB Output is correct
38 Correct 141 ms 5944 KB Output is correct
39 Correct 138 ms 5852 KB Output is correct
40 Correct 148 ms 6328 KB Output is correct
41 Correct 142 ms 5796 KB Output is correct
42 Correct 143 ms 5788 KB Output is correct
43 Correct 141 ms 5828 KB Output is correct
44 Correct 141 ms 5940 KB Output is correct
45 Correct 144 ms 5924 KB Output is correct
46 Correct 139 ms 5852 KB Output is correct
47 Correct 152 ms 6160 KB Output is correct
48 Correct 144 ms 5800 KB Output is correct
49 Correct 143 ms 5836 KB Output is correct
50 Correct 216 ms 9536 KB Output is correct
51 Correct 197 ms 9008 KB Output is correct
52 Correct 230 ms 10016 KB Output is correct
53 Correct 213 ms 9576 KB Output is correct
54 Correct 162 ms 7216 KB Output is correct
55 Correct 328 ms 13468 KB Output is correct
56 Correct 331 ms 13012 KB Output is correct
57 Correct 271 ms 11328 KB Output is correct
58 Correct 139 ms 5740 KB Output is correct
59 Correct 141 ms 5812 KB Output is correct
60 Correct 150 ms 6212 KB Output is correct
61 Correct 242 ms 9448 KB Output is correct
62 Correct 158 ms 6960 KB Output is correct
63 Correct 149 ms 6328 KB Output is correct
64 Correct 141 ms 5812 KB Output is correct
65 Correct 186 ms 8124 KB Output is correct
66 Correct 141 ms 5816 KB Output is correct
67 Correct 141 ms 5748 KB Output is correct
68 Correct 139 ms 5780 KB Output is correct
69 Correct 144 ms 6080 KB Output is correct
70 Correct 153 ms 6716 KB Output is correct
71 Execution timed out 5088 ms 201032 KB Time limit exceeded
72 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 139 ms 5796 KB Output is correct
2 Correct 140 ms 5724 KB Output is correct
3 Correct 139 ms 5724 KB Output is correct
4 Correct 140 ms 5816 KB Output is correct
5 Correct 139 ms 5880 KB Output is correct
6 Correct 139 ms 5752 KB Output is correct
7 Correct 139 ms 5820 KB Output is correct
8 Correct 138 ms 5740 KB Output is correct
9 Correct 139 ms 5924 KB Output is correct
10 Correct 141 ms 5760 KB Output is correct
11 Correct 141 ms 5816 KB Output is correct
12 Correct 140 ms 5828 KB Output is correct
13 Correct 139 ms 5916 KB Output is correct
14 Correct 138 ms 5820 KB Output is correct
15 Correct 138 ms 5824 KB Output is correct
16 Correct 140 ms 5844 KB Output is correct
17 Correct 140 ms 5820 KB Output is correct
18 Correct 140 ms 5780 KB Output is correct
19 Correct 140 ms 5772 KB Output is correct
20 Correct 141 ms 5812 KB Output is correct
21 Correct 139 ms 5780 KB Output is correct
22 Correct 139 ms 5764 KB Output is correct
23 Correct 140 ms 5784 KB Output is correct
24 Correct 141 ms 5832 KB Output is correct
25 Correct 142 ms 5792 KB Output is correct
26 Correct 151 ms 6608 KB Output is correct
27 Correct 149 ms 6456 KB Output is correct
28 Correct 142 ms 6028 KB Output is correct
29 Correct 143 ms 6064 KB Output is correct
30 Correct 143 ms 5856 KB Output is correct
31 Correct 162 ms 6988 KB Output is correct
32 Correct 156 ms 6552 KB Output is correct
33 Correct 150 ms 6456 KB Output is correct
34 Correct 139 ms 5772 KB Output is correct
35 Correct 140 ms 5816 KB Output is correct
36 Correct 146 ms 5940 KB Output is correct
37 Correct 152 ms 6424 KB Output is correct
38 Correct 141 ms 5944 KB Output is correct
39 Correct 138 ms 5852 KB Output is correct
40 Correct 148 ms 6328 KB Output is correct
41 Correct 142 ms 5796 KB Output is correct
42 Correct 143 ms 5788 KB Output is correct
43 Correct 141 ms 5828 KB Output is correct
44 Correct 141 ms 5940 KB Output is correct
45 Correct 144 ms 5924 KB Output is correct
46 Correct 139 ms 5852 KB Output is correct
47 Correct 152 ms 6160 KB Output is correct
48 Correct 144 ms 5800 KB Output is correct
49 Correct 143 ms 5836 KB Output is correct
50 Correct 216 ms 9536 KB Output is correct
51 Correct 197 ms 9008 KB Output is correct
52 Correct 230 ms 10016 KB Output is correct
53 Correct 213 ms 9576 KB Output is correct
54 Correct 162 ms 7216 KB Output is correct
55 Correct 328 ms 13468 KB Output is correct
56 Correct 331 ms 13012 KB Output is correct
57 Correct 271 ms 11328 KB Output is correct
58 Correct 139 ms 5740 KB Output is correct
59 Correct 141 ms 5812 KB Output is correct
60 Correct 150 ms 6212 KB Output is correct
61 Correct 242 ms 9448 KB Output is correct
62 Correct 158 ms 6960 KB Output is correct
63 Correct 149 ms 6328 KB Output is correct
64 Correct 141 ms 5812 KB Output is correct
65 Correct 186 ms 8124 KB Output is correct
66 Correct 141 ms 5816 KB Output is correct
67 Correct 141 ms 5748 KB Output is correct
68 Correct 139 ms 5780 KB Output is correct
69 Correct 144 ms 6080 KB Output is correct
70 Correct 153 ms 6716 KB Output is correct
71 Execution timed out 5088 ms 201032 KB Time limit exceeded
72 Halted 0 ms 0 KB -