Submission #168856

# Submission time Handle Problem Language Result Execution time Memory
168856 2019-12-16T17:01:35 Z kostia244 Toys (CEOI18_toy) C++17
100 / 100
2824 ms 105968 KB
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,sse2,sse,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC comment("/STACK:26666666")
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace __gnu_pbds;
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
using ll = long long;
using vi = vector<ll>;
const int mod = 1e9 + 7;
ll n;
vi divs, cans[100100], canb[100100];
int id[100100];
unordered_map<int, int> vis[100100];
__attribute__((always_inline)) inline bool mark(ll i, ll cur) {
	ll x = (i*i <= n ? id[i] : id[31628+(n/i)]);
	if(vis[x][cur]) return false;
	vis[x][cur] = 1;
	return true;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	ll tn = n;
	int x = 0;
	for (ll d = 1; d * d <= tn; d++) {
		if (tn % d)
			continue;
		divs.pb(d);
		id[d] = x++;
		if (d * d != n) {
			id[31628+d]=x++;
			divs.pb(n / d);
		}
	}
	sort(all(divs));
	cans[1].pb(0);
	for (auto i : divs) {
		vi &t = (i * i <= n ? cans[i] : canb[n / i]);
		sort(all(t));
		t.erase(unique(all(t)), t.end());
		for (auto j : divs) {
			if(j==1)continue;
			if (i * j > n)
				break;
			if (n % (i * j))
				continue;
			ll _nxt = i * j;
			vi &nxt = (_nxt * _nxt <= n ? cans[_nxt] : canb[n / _nxt]);
			for (auto q : t) {
				if(mark(_nxt, q+j-1))
				nxt.pb(q + j - 1);
			}
		}
	}
	vi &t = (n * n <= n ? cans[n] : canb[n / n]);
	sort(all(t));
	cout << t.size() << "\n";
	for (auto i : t)
		cout << i << " ";
}

Compilation message

toy.cpp:4:0: warning: ignoring #pragma GCC comment [-Wunknown-pragmas]
 #pragma GCC comment("/STACK:26666666")
# Verdict Execution time Memory Grader output
1 Correct 12 ms 10488 KB Output is correct
2 Correct 11 ms 10488 KB Output is correct
3 Correct 11 ms 10488 KB Output is correct
4 Correct 11 ms 10488 KB Output is correct
5 Correct 12 ms 10488 KB Output is correct
6 Correct 11 ms 10492 KB Output is correct
7 Correct 12 ms 10488 KB Output is correct
8 Correct 11 ms 10488 KB Output is correct
9 Correct 11 ms 10488 KB Output is correct
10 Correct 11 ms 10488 KB Output is correct
11 Correct 11 ms 10488 KB Output is correct
12 Correct 14 ms 10488 KB Output is correct
13 Correct 12 ms 10488 KB Output is correct
14 Correct 11 ms 10488 KB Output is correct
15 Correct 12 ms 10488 KB Output is correct
16 Correct 12 ms 10488 KB Output is correct
17 Correct 12 ms 10488 KB Output is correct
18 Correct 12 ms 10488 KB Output is correct
19 Correct 11 ms 10488 KB Output is correct
20 Correct 13 ms 10488 KB Output is correct
21 Correct 12 ms 10616 KB Output is correct
22 Correct 12 ms 10488 KB Output is correct
23 Correct 11 ms 10488 KB Output is correct
24 Correct 11 ms 10488 KB Output is correct
25 Correct 11 ms 10488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 10488 KB Output is correct
2 Correct 11 ms 10488 KB Output is correct
3 Correct 11 ms 10488 KB Output is correct
4 Correct 11 ms 10488 KB Output is correct
5 Correct 12 ms 10488 KB Output is correct
6 Correct 11 ms 10492 KB Output is correct
7 Correct 12 ms 10488 KB Output is correct
8 Correct 11 ms 10488 KB Output is correct
9 Correct 11 ms 10488 KB Output is correct
10 Correct 11 ms 10488 KB Output is correct
11 Correct 11 ms 10488 KB Output is correct
12 Correct 14 ms 10488 KB Output is correct
13 Correct 12 ms 10488 KB Output is correct
14 Correct 11 ms 10488 KB Output is correct
15 Correct 12 ms 10488 KB Output is correct
16 Correct 12 ms 10488 KB Output is correct
17 Correct 12 ms 10488 KB Output is correct
18 Correct 12 ms 10488 KB Output is correct
19 Correct 11 ms 10488 KB Output is correct
20 Correct 13 ms 10488 KB Output is correct
21 Correct 12 ms 10616 KB Output is correct
22 Correct 12 ms 10488 KB Output is correct
23 Correct 11 ms 10488 KB Output is correct
24 Correct 11 ms 10488 KB Output is correct
25 Correct 11 ms 10488 KB Output is correct
26 Correct 12 ms 10616 KB Output is correct
27 Correct 12 ms 10616 KB Output is correct
28 Correct 12 ms 10488 KB Output is correct
29 Correct 12 ms 10488 KB Output is correct
30 Correct 12 ms 10488 KB Output is correct
31 Correct 12 ms 10616 KB Output is correct
32 Correct 12 ms 10616 KB Output is correct
33 Correct 12 ms 10616 KB Output is correct
34 Correct 12 ms 10488 KB Output is correct
35 Correct 11 ms 10488 KB Output is correct
36 Correct 12 ms 10488 KB Output is correct
37 Correct 12 ms 10616 KB Output is correct
38 Correct 11 ms 10616 KB Output is correct
39 Correct 11 ms 10488 KB Output is correct
40 Correct 12 ms 10616 KB Output is correct
41 Correct 11 ms 10488 KB Output is correct
42 Correct 11 ms 10488 KB Output is correct
43 Correct 12 ms 10488 KB Output is correct
44 Correct 12 ms 10488 KB Output is correct
45 Correct 12 ms 10616 KB Output is correct
46 Correct 11 ms 10488 KB Output is correct
47 Correct 12 ms 10616 KB Output is correct
48 Correct 11 ms 10616 KB Output is correct
49 Correct 12 ms 10488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 10488 KB Output is correct
2 Correct 11 ms 10488 KB Output is correct
3 Correct 11 ms 10488 KB Output is correct
4 Correct 11 ms 10488 KB Output is correct
5 Correct 12 ms 10488 KB Output is correct
6 Correct 11 ms 10492 KB Output is correct
7 Correct 12 ms 10488 KB Output is correct
8 Correct 11 ms 10488 KB Output is correct
9 Correct 11 ms 10488 KB Output is correct
10 Correct 11 ms 10488 KB Output is correct
11 Correct 11 ms 10488 KB Output is correct
12 Correct 14 ms 10488 KB Output is correct
13 Correct 12 ms 10488 KB Output is correct
14 Correct 11 ms 10488 KB Output is correct
15 Correct 12 ms 10488 KB Output is correct
16 Correct 12 ms 10488 KB Output is correct
17 Correct 12 ms 10488 KB Output is correct
18 Correct 12 ms 10488 KB Output is correct
19 Correct 11 ms 10488 KB Output is correct
20 Correct 13 ms 10488 KB Output is correct
21 Correct 12 ms 10616 KB Output is correct
22 Correct 12 ms 10488 KB Output is correct
23 Correct 11 ms 10488 KB Output is correct
24 Correct 11 ms 10488 KB Output is correct
25 Correct 11 ms 10488 KB Output is correct
26 Correct 12 ms 10616 KB Output is correct
27 Correct 12 ms 10616 KB Output is correct
28 Correct 12 ms 10488 KB Output is correct
29 Correct 12 ms 10488 KB Output is correct
30 Correct 12 ms 10488 KB Output is correct
31 Correct 12 ms 10616 KB Output is correct
32 Correct 12 ms 10616 KB Output is correct
33 Correct 12 ms 10616 KB Output is correct
34 Correct 12 ms 10488 KB Output is correct
35 Correct 11 ms 10488 KB Output is correct
36 Correct 12 ms 10488 KB Output is correct
37 Correct 12 ms 10616 KB Output is correct
38 Correct 11 ms 10616 KB Output is correct
39 Correct 11 ms 10488 KB Output is correct
40 Correct 12 ms 10616 KB Output is correct
41 Correct 11 ms 10488 KB Output is correct
42 Correct 11 ms 10488 KB Output is correct
43 Correct 12 ms 10488 KB Output is correct
44 Correct 12 ms 10488 KB Output is correct
45 Correct 12 ms 10616 KB Output is correct
46 Correct 11 ms 10488 KB Output is correct
47 Correct 12 ms 10616 KB Output is correct
48 Correct 11 ms 10616 KB Output is correct
49 Correct 12 ms 10488 KB Output is correct
50 Correct 14 ms 10872 KB Output is correct
51 Correct 14 ms 10872 KB Output is correct
52 Correct 19 ms 10872 KB Output is correct
53 Correct 13 ms 10872 KB Output is correct
54 Correct 13 ms 10616 KB Output is correct
55 Correct 18 ms 11004 KB Output is correct
56 Correct 15 ms 10872 KB Output is correct
57 Correct 15 ms 10872 KB Output is correct
58 Correct 11 ms 10492 KB Output is correct
59 Correct 12 ms 10488 KB Output is correct
60 Correct 12 ms 10488 KB Output is correct
61 Correct 13 ms 10744 KB Output is correct
62 Correct 12 ms 10616 KB Output is correct
63 Correct 12 ms 10616 KB Output is correct
64 Correct 11 ms 10488 KB Output is correct
65 Correct 13 ms 10744 KB Output is correct
66 Correct 11 ms 10492 KB Output is correct
67 Correct 11 ms 10488 KB Output is correct
68 Correct 12 ms 10488 KB Output is correct
69 Correct 12 ms 10488 KB Output is correct
70 Correct 13 ms 10620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 10488 KB Output is correct
2 Correct 11 ms 10488 KB Output is correct
3 Correct 11 ms 10488 KB Output is correct
4 Correct 11 ms 10488 KB Output is correct
5 Correct 12 ms 10488 KB Output is correct
6 Correct 11 ms 10492 KB Output is correct
7 Correct 12 ms 10488 KB Output is correct
8 Correct 11 ms 10488 KB Output is correct
9 Correct 11 ms 10488 KB Output is correct
10 Correct 11 ms 10488 KB Output is correct
11 Correct 11 ms 10488 KB Output is correct
12 Correct 14 ms 10488 KB Output is correct
13 Correct 12 ms 10488 KB Output is correct
14 Correct 11 ms 10488 KB Output is correct
15 Correct 12 ms 10488 KB Output is correct
16 Correct 12 ms 10488 KB Output is correct
17 Correct 12 ms 10488 KB Output is correct
18 Correct 12 ms 10488 KB Output is correct
19 Correct 11 ms 10488 KB Output is correct
20 Correct 13 ms 10488 KB Output is correct
21 Correct 12 ms 10616 KB Output is correct
22 Correct 12 ms 10488 KB Output is correct
23 Correct 11 ms 10488 KB Output is correct
24 Correct 11 ms 10488 KB Output is correct
25 Correct 11 ms 10488 KB Output is correct
26 Correct 12 ms 10616 KB Output is correct
27 Correct 12 ms 10616 KB Output is correct
28 Correct 12 ms 10488 KB Output is correct
29 Correct 12 ms 10488 KB Output is correct
30 Correct 12 ms 10488 KB Output is correct
31 Correct 12 ms 10616 KB Output is correct
32 Correct 12 ms 10616 KB Output is correct
33 Correct 12 ms 10616 KB Output is correct
34 Correct 12 ms 10488 KB Output is correct
35 Correct 11 ms 10488 KB Output is correct
36 Correct 12 ms 10488 KB Output is correct
37 Correct 12 ms 10616 KB Output is correct
38 Correct 11 ms 10616 KB Output is correct
39 Correct 11 ms 10488 KB Output is correct
40 Correct 12 ms 10616 KB Output is correct
41 Correct 11 ms 10488 KB Output is correct
42 Correct 11 ms 10488 KB Output is correct
43 Correct 12 ms 10488 KB Output is correct
44 Correct 12 ms 10488 KB Output is correct
45 Correct 12 ms 10616 KB Output is correct
46 Correct 11 ms 10488 KB Output is correct
47 Correct 12 ms 10616 KB Output is correct
48 Correct 11 ms 10616 KB Output is correct
49 Correct 12 ms 10488 KB Output is correct
50 Correct 14 ms 10872 KB Output is correct
51 Correct 14 ms 10872 KB Output is correct
52 Correct 19 ms 10872 KB Output is correct
53 Correct 13 ms 10872 KB Output is correct
54 Correct 13 ms 10616 KB Output is correct
55 Correct 18 ms 11004 KB Output is correct
56 Correct 15 ms 10872 KB Output is correct
57 Correct 15 ms 10872 KB Output is correct
58 Correct 11 ms 10492 KB Output is correct
59 Correct 12 ms 10488 KB Output is correct
60 Correct 12 ms 10488 KB Output is correct
61 Correct 13 ms 10744 KB Output is correct
62 Correct 12 ms 10616 KB Output is correct
63 Correct 12 ms 10616 KB Output is correct
64 Correct 11 ms 10488 KB Output is correct
65 Correct 13 ms 10744 KB Output is correct
66 Correct 11 ms 10492 KB Output is correct
67 Correct 11 ms 10488 KB Output is correct
68 Correct 12 ms 10488 KB Output is correct
69 Correct 12 ms 10488 KB Output is correct
70 Correct 13 ms 10620 KB Output is correct
71 Correct 391 ms 30864 KB Output is correct
72 Correct 266 ms 26096 KB Output is correct
73 Correct 332 ms 28624 KB Output is correct
74 Correct 194 ms 22812 KB Output is correct
75 Correct 204 ms 23436 KB Output is correct
76 Correct 528 ms 38120 KB Output is correct
77 Correct 489 ms 34640 KB Output is correct
78 Correct 430 ms 33248 KB Output is correct
79 Correct 447 ms 32628 KB Output is correct
80 Correct 12 ms 10488 KB Output is correct
81 Correct 11 ms 10488 KB Output is correct
82 Correct 14 ms 11000 KB Output is correct
83 Correct 50 ms 14532 KB Output is correct
84 Correct 60 ms 15096 KB Output is correct
85 Correct 24 ms 12024 KB Output is correct
86 Correct 12 ms 10616 KB Output is correct
87 Correct 67 ms 15864 KB Output is correct
88 Correct 12 ms 10460 KB Output is correct
89 Correct 12 ms 10616 KB Output is correct
90 Correct 12 ms 10616 KB Output is correct
91 Correct 31 ms 12664 KB Output is correct
92 Correct 110 ms 17656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 10488 KB Output is correct
2 Correct 11 ms 10488 KB Output is correct
3 Correct 11 ms 10488 KB Output is correct
4 Correct 11 ms 10488 KB Output is correct
5 Correct 12 ms 10488 KB Output is correct
6 Correct 11 ms 10492 KB Output is correct
7 Correct 12 ms 10488 KB Output is correct
8 Correct 11 ms 10488 KB Output is correct
9 Correct 11 ms 10488 KB Output is correct
10 Correct 11 ms 10488 KB Output is correct
11 Correct 11 ms 10488 KB Output is correct
12 Correct 14 ms 10488 KB Output is correct
13 Correct 12 ms 10488 KB Output is correct
14 Correct 11 ms 10488 KB Output is correct
15 Correct 12 ms 10488 KB Output is correct
16 Correct 12 ms 10488 KB Output is correct
17 Correct 12 ms 10488 KB Output is correct
18 Correct 12 ms 10488 KB Output is correct
19 Correct 11 ms 10488 KB Output is correct
20 Correct 13 ms 10488 KB Output is correct
21 Correct 12 ms 10616 KB Output is correct
22 Correct 12 ms 10488 KB Output is correct
23 Correct 11 ms 10488 KB Output is correct
24 Correct 11 ms 10488 KB Output is correct
25 Correct 11 ms 10488 KB Output is correct
26 Correct 12 ms 10616 KB Output is correct
27 Correct 12 ms 10616 KB Output is correct
28 Correct 12 ms 10488 KB Output is correct
29 Correct 12 ms 10488 KB Output is correct
30 Correct 12 ms 10488 KB Output is correct
31 Correct 12 ms 10616 KB Output is correct
32 Correct 12 ms 10616 KB Output is correct
33 Correct 12 ms 10616 KB Output is correct
34 Correct 12 ms 10488 KB Output is correct
35 Correct 11 ms 10488 KB Output is correct
36 Correct 12 ms 10488 KB Output is correct
37 Correct 12 ms 10616 KB Output is correct
38 Correct 11 ms 10616 KB Output is correct
39 Correct 11 ms 10488 KB Output is correct
40 Correct 12 ms 10616 KB Output is correct
41 Correct 11 ms 10488 KB Output is correct
42 Correct 11 ms 10488 KB Output is correct
43 Correct 12 ms 10488 KB Output is correct
44 Correct 12 ms 10488 KB Output is correct
45 Correct 12 ms 10616 KB Output is correct
46 Correct 11 ms 10488 KB Output is correct
47 Correct 12 ms 10616 KB Output is correct
48 Correct 11 ms 10616 KB Output is correct
49 Correct 12 ms 10488 KB Output is correct
50 Correct 14 ms 10872 KB Output is correct
51 Correct 14 ms 10872 KB Output is correct
52 Correct 19 ms 10872 KB Output is correct
53 Correct 13 ms 10872 KB Output is correct
54 Correct 13 ms 10616 KB Output is correct
55 Correct 18 ms 11004 KB Output is correct
56 Correct 15 ms 10872 KB Output is correct
57 Correct 15 ms 10872 KB Output is correct
58 Correct 11 ms 10492 KB Output is correct
59 Correct 12 ms 10488 KB Output is correct
60 Correct 12 ms 10488 KB Output is correct
61 Correct 13 ms 10744 KB Output is correct
62 Correct 12 ms 10616 KB Output is correct
63 Correct 12 ms 10616 KB Output is correct
64 Correct 11 ms 10488 KB Output is correct
65 Correct 13 ms 10744 KB Output is correct
66 Correct 11 ms 10492 KB Output is correct
67 Correct 11 ms 10488 KB Output is correct
68 Correct 12 ms 10488 KB Output is correct
69 Correct 12 ms 10488 KB Output is correct
70 Correct 13 ms 10620 KB Output is correct
71 Correct 391 ms 30864 KB Output is correct
72 Correct 266 ms 26096 KB Output is correct
73 Correct 332 ms 28624 KB Output is correct
74 Correct 194 ms 22812 KB Output is correct
75 Correct 204 ms 23436 KB Output is correct
76 Correct 528 ms 38120 KB Output is correct
77 Correct 489 ms 34640 KB Output is correct
78 Correct 430 ms 33248 KB Output is correct
79 Correct 447 ms 32628 KB Output is correct
80 Correct 12 ms 10488 KB Output is correct
81 Correct 11 ms 10488 KB Output is correct
82 Correct 14 ms 11000 KB Output is correct
83 Correct 50 ms 14532 KB Output is correct
84 Correct 60 ms 15096 KB Output is correct
85 Correct 24 ms 12024 KB Output is correct
86 Correct 12 ms 10616 KB Output is correct
87 Correct 67 ms 15864 KB Output is correct
88 Correct 12 ms 10460 KB Output is correct
89 Correct 12 ms 10616 KB Output is correct
90 Correct 12 ms 10616 KB Output is correct
91 Correct 31 ms 12664 KB Output is correct
92 Correct 110 ms 17656 KB Output is correct
93 Correct 2255 ms 95504 KB Output is correct
94 Correct 1384 ms 68256 KB Output is correct
95 Correct 1611 ms 71104 KB Output is correct
96 Correct 1270 ms 64608 KB Output is correct
97 Correct 1184 ms 59440 KB Output is correct
98 Correct 2558 ms 104304 KB Output is correct
99 Correct 2824 ms 105968 KB Output is correct
100 Correct 2524 ms 101548 KB Output is correct
101 Correct 2245 ms 94828 KB Output is correct
102 Correct 1923 ms 86680 KB Output is correct
103 Correct 1742 ms 79188 KB Output is correct
104 Correct 12 ms 10488 KB Output is correct
105 Correct 12 ms 10488 KB Output is correct
106 Correct 17 ms 11256 KB Output is correct
107 Correct 133 ms 20856 KB Output is correct
108 Correct 363 ms 33116 KB Output is correct
109 Correct 42 ms 13816 KB Output is correct
110 Correct 12 ms 10488 KB Output is correct
111 Correct 179 ms 23788 KB Output is correct
112 Correct 12 ms 10616 KB Output is correct
113 Correct 12 ms 10616 KB Output is correct
114 Correct 19 ms 11384 KB Output is correct
115 Correct 12 ms 10616 KB Output is correct
116 Correct 26 ms 12280 KB Output is correct
117 Correct 517 ms 37660 KB Output is correct