Submission #104955

# Submission time Handle Problem Language Result Execution time Memory
104955 2019-04-10T00:23:32 Z eriksuenderhauf Toys (CEOI18_toy) C++11
100 / 100
3169 ms 109816 KB
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%I64d", &(n))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,null_type,hash<int>> ht2;
typedef cc_hash_table<int,ht2,hash<int>> ht;
ht dp;
int di[100000];
int m = 0;

ht2 dfs(int n) {
    if (dp.find(n) != dp.end())
        return dp[n];
    if (n == 1) {
        ht2 sm;
        sm.insert(0);
        dp[n] = sm;
        return sm;
    }
    ht2 ret;
    ret.insert(n - 1);
    for (int j = 0; j < m; j++) {
        int i = di[j];
        if (i * i > n)
            break;
        if (n % i != 0)
            continue;
        ht2 tmp = dfs(n / i);
        auto it = tmp.begin();
        for (; it != tmp.end(); it++)
            ret.insert((*it) + i - 1);
    }
    dp[n] = ret;
    return ret;
}

int main()
{
    int n;
    ni(n);
    for (int i = 2; i * i <= n; i++)
        if (n % i == 0)
            di[m++] = i;
    ht2 sm = dfs(n);
    m = 0;
    printf("%d\n", sm.size());
    auto it = sm.begin();
    for (; it != sm.end(); it++)
        di[m++] = *it;
    sort(di, di + m);
    for (int i = 0; i < m; i++)
        printf("%d ", di[i]);
    enl;
    return 0;
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:57:29: warning: format '%d' expects argument of type 'int', but argument 2 has type '__gnu_pbds::detail::cc_ht_set<int, __gnu_pbds::null_type, std::hash<int>, std::equal_to<int>, std::allocator<char>, false, __gnu_pbds::direct_mask_range_hashing<>, __gnu_pbds::hash_standard_resize_policy<__gnu_pbds::hash_exponential_size_policy<>, __gnu_pbds::hash_load_check_resize_trigger<>, false, long unsigned int> >::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d\n", sm.size());
                    ~~~~~~~~~^
toy.cpp:7:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 #define ni(n) scanf("%d", &(n))
               ~~~~~^~~~~~~~~~~~
toy.cpp:51:5: note: in expansion of macro 'ni'
     ni(n);
     ^~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 432 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 3 ms 256 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 256 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 432 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 3 ms 256 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 256 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 4 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 4 ms 368 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 372 KB Output is correct
31 Correct 3 ms 512 KB Output is correct
32 Correct 3 ms 512 KB Output is correct
33 Correct 3 ms 512 KB Output is correct
34 Correct 2 ms 256 KB Output is correct
35 Correct 3 ms 384 KB Output is correct
36 Correct 3 ms 384 KB Output is correct
37 Correct 2 ms 384 KB Output is correct
38 Correct 3 ms 384 KB Output is correct
39 Correct 2 ms 384 KB Output is correct
40 Correct 3 ms 384 KB Output is correct
41 Correct 2 ms 256 KB Output is correct
42 Correct 2 ms 384 KB Output is correct
43 Correct 2 ms 384 KB Output is correct
44 Correct 2 ms 384 KB Output is correct
45 Correct 3 ms 384 KB Output is correct
46 Correct 3 ms 384 KB Output is correct
47 Correct 4 ms 428 KB Output is correct
48 Correct 2 ms 384 KB Output is correct
49 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 432 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 3 ms 256 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 256 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 4 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 4 ms 368 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 372 KB Output is correct
31 Correct 3 ms 512 KB Output is correct
32 Correct 3 ms 512 KB Output is correct
33 Correct 3 ms 512 KB Output is correct
34 Correct 2 ms 256 KB Output is correct
35 Correct 3 ms 384 KB Output is correct
36 Correct 3 ms 384 KB Output is correct
37 Correct 2 ms 384 KB Output is correct
38 Correct 3 ms 384 KB Output is correct
39 Correct 2 ms 384 KB Output is correct
40 Correct 3 ms 384 KB Output is correct
41 Correct 2 ms 256 KB Output is correct
42 Correct 2 ms 384 KB Output is correct
43 Correct 2 ms 384 KB Output is correct
44 Correct 2 ms 384 KB Output is correct
45 Correct 3 ms 384 KB Output is correct
46 Correct 3 ms 384 KB Output is correct
47 Correct 4 ms 428 KB Output is correct
48 Correct 2 ms 384 KB Output is correct
49 Correct 2 ms 384 KB Output is correct
50 Correct 9 ms 768 KB Output is correct
51 Correct 7 ms 768 KB Output is correct
52 Correct 7 ms 768 KB Output is correct
53 Correct 6 ms 768 KB Output is correct
54 Correct 4 ms 512 KB Output is correct
55 Correct 9 ms 896 KB Output is correct
56 Correct 8 ms 768 KB Output is correct
57 Correct 9 ms 768 KB Output is correct
58 Correct 2 ms 368 KB Output is correct
59 Correct 2 ms 256 KB Output is correct
60 Correct 3 ms 384 KB Output is correct
61 Correct 6 ms 640 KB Output is correct
62 Correct 4 ms 512 KB Output is correct
63 Correct 5 ms 512 KB Output is correct
64 Correct 2 ms 384 KB Output is correct
65 Correct 6 ms 640 KB Output is correct
66 Correct 2 ms 384 KB Output is correct
67 Correct 2 ms 384 KB Output is correct
68 Correct 2 ms 384 KB Output is correct
69 Correct 2 ms 384 KB Output is correct
70 Correct 3 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 432 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 3 ms 256 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 256 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 4 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 4 ms 368 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 372 KB Output is correct
31 Correct 3 ms 512 KB Output is correct
32 Correct 3 ms 512 KB Output is correct
33 Correct 3 ms 512 KB Output is correct
34 Correct 2 ms 256 KB Output is correct
35 Correct 3 ms 384 KB Output is correct
36 Correct 3 ms 384 KB Output is correct
37 Correct 2 ms 384 KB Output is correct
38 Correct 3 ms 384 KB Output is correct
39 Correct 2 ms 384 KB Output is correct
40 Correct 3 ms 384 KB Output is correct
41 Correct 2 ms 256 KB Output is correct
42 Correct 2 ms 384 KB Output is correct
43 Correct 2 ms 384 KB Output is correct
44 Correct 2 ms 384 KB Output is correct
45 Correct 3 ms 384 KB Output is correct
46 Correct 3 ms 384 KB Output is correct
47 Correct 4 ms 428 KB Output is correct
48 Correct 2 ms 384 KB Output is correct
49 Correct 2 ms 384 KB Output is correct
50 Correct 9 ms 768 KB Output is correct
51 Correct 7 ms 768 KB Output is correct
52 Correct 7 ms 768 KB Output is correct
53 Correct 6 ms 768 KB Output is correct
54 Correct 4 ms 512 KB Output is correct
55 Correct 9 ms 896 KB Output is correct
56 Correct 8 ms 768 KB Output is correct
57 Correct 9 ms 768 KB Output is correct
58 Correct 2 ms 368 KB Output is correct
59 Correct 2 ms 256 KB Output is correct
60 Correct 3 ms 384 KB Output is correct
61 Correct 6 ms 640 KB Output is correct
62 Correct 4 ms 512 KB Output is correct
63 Correct 5 ms 512 KB Output is correct
64 Correct 2 ms 384 KB Output is correct
65 Correct 6 ms 640 KB Output is correct
66 Correct 2 ms 384 KB Output is correct
67 Correct 2 ms 384 KB Output is correct
68 Correct 2 ms 384 KB Output is correct
69 Correct 2 ms 384 KB Output is correct
70 Correct 3 ms 512 KB Output is correct
71 Correct 546 ms 23816 KB Output is correct
72 Correct 379 ms 18756 KB Output is correct
73 Correct 484 ms 21776 KB Output is correct
74 Correct 270 ms 14468 KB Output is correct
75 Correct 348 ms 15392 KB Output is correct
76 Correct 819 ms 31692 KB Output is correct
77 Correct 689 ms 27940 KB Output is correct
78 Correct 587 ms 26144 KB Output is correct
79 Correct 572 ms 25684 KB Output is correct
80 Correct 2 ms 256 KB Output is correct
81 Correct 2 ms 384 KB Output is correct
82 Correct 7 ms 896 KB Output is correct
83 Correct 76 ms 4948 KB Output is correct
84 Correct 103 ms 5752 KB Output is correct
85 Correct 33 ms 2168 KB Output is correct
86 Correct 3 ms 384 KB Output is correct
87 Correct 113 ms 7080 KB Output is correct
88 Correct 2 ms 256 KB Output is correct
89 Correct 2 ms 384 KB Output is correct
90 Correct 2 ms 384 KB Output is correct
91 Correct 38 ms 3160 KB Output is correct
92 Correct 129 ms 8776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 432 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 3 ms 256 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 256 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 4 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 4 ms 368 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 372 KB Output is correct
31 Correct 3 ms 512 KB Output is correct
32 Correct 3 ms 512 KB Output is correct
33 Correct 3 ms 512 KB Output is correct
34 Correct 2 ms 256 KB Output is correct
35 Correct 3 ms 384 KB Output is correct
36 Correct 3 ms 384 KB Output is correct
37 Correct 2 ms 384 KB Output is correct
38 Correct 3 ms 384 KB Output is correct
39 Correct 2 ms 384 KB Output is correct
40 Correct 3 ms 384 KB Output is correct
41 Correct 2 ms 256 KB Output is correct
42 Correct 2 ms 384 KB Output is correct
43 Correct 2 ms 384 KB Output is correct
44 Correct 2 ms 384 KB Output is correct
45 Correct 3 ms 384 KB Output is correct
46 Correct 3 ms 384 KB Output is correct
47 Correct 4 ms 428 KB Output is correct
48 Correct 2 ms 384 KB Output is correct
49 Correct 2 ms 384 KB Output is correct
50 Correct 9 ms 768 KB Output is correct
51 Correct 7 ms 768 KB Output is correct
52 Correct 7 ms 768 KB Output is correct
53 Correct 6 ms 768 KB Output is correct
54 Correct 4 ms 512 KB Output is correct
55 Correct 9 ms 896 KB Output is correct
56 Correct 8 ms 768 KB Output is correct
57 Correct 9 ms 768 KB Output is correct
58 Correct 2 ms 368 KB Output is correct
59 Correct 2 ms 256 KB Output is correct
60 Correct 3 ms 384 KB Output is correct
61 Correct 6 ms 640 KB Output is correct
62 Correct 4 ms 512 KB Output is correct
63 Correct 5 ms 512 KB Output is correct
64 Correct 2 ms 384 KB Output is correct
65 Correct 6 ms 640 KB Output is correct
66 Correct 2 ms 384 KB Output is correct
67 Correct 2 ms 384 KB Output is correct
68 Correct 2 ms 384 KB Output is correct
69 Correct 2 ms 384 KB Output is correct
70 Correct 3 ms 512 KB Output is correct
71 Correct 546 ms 23816 KB Output is correct
72 Correct 379 ms 18756 KB Output is correct
73 Correct 484 ms 21776 KB Output is correct
74 Correct 270 ms 14468 KB Output is correct
75 Correct 348 ms 15392 KB Output is correct
76 Correct 819 ms 31692 KB Output is correct
77 Correct 689 ms 27940 KB Output is correct
78 Correct 587 ms 26144 KB Output is correct
79 Correct 572 ms 25684 KB Output is correct
80 Correct 2 ms 256 KB Output is correct
81 Correct 2 ms 384 KB Output is correct
82 Correct 7 ms 896 KB Output is correct
83 Correct 76 ms 4948 KB Output is correct
84 Correct 103 ms 5752 KB Output is correct
85 Correct 33 ms 2168 KB Output is correct
86 Correct 3 ms 384 KB Output is correct
87 Correct 113 ms 7080 KB Output is correct
88 Correct 2 ms 256 KB Output is correct
89 Correct 2 ms 384 KB Output is correct
90 Correct 2 ms 384 KB Output is correct
91 Correct 38 ms 3160 KB Output is correct
92 Correct 129 ms 8776 KB Output is correct
93 Correct 2740 ms 99328 KB Output is correct
94 Correct 1474 ms 66304 KB Output is correct
95 Correct 1733 ms 69172 KB Output is correct
96 Correct 1632 ms 61064 KB Output is correct
97 Correct 1340 ms 56340 KB Output is correct
98 Correct 3169 ms 108088 KB Output is correct
99 Correct 3026 ms 109816 KB Output is correct
100 Correct 3037 ms 105956 KB Output is correct
101 Correct 2786 ms 98740 KB Output is correct
102 Correct 2624 ms 86896 KB Output is correct
103 Correct 2132 ms 78552 KB Output is correct
104 Correct 2 ms 384 KB Output is correct
105 Correct 3 ms 384 KB Output is correct
106 Correct 11 ms 1432 KB Output is correct
107 Correct 192 ms 13492 KB Output is correct
108 Correct 517 ms 27036 KB Output is correct
109 Correct 62 ms 4492 KB Output is correct
110 Correct 3 ms 384 KB Output is correct
111 Correct 263 ms 16648 KB Output is correct
112 Correct 3 ms 384 KB Output is correct
113 Correct 2 ms 384 KB Output is correct
114 Correct 13 ms 1408 KB Output is correct
115 Correct 3 ms 384 KB Output is correct
116 Correct 29 ms 2684 KB Output is correct
117 Correct 571 ms 33272 KB Output is correct