Submission #493221

# Submission time Handle Problem Language Result Execution time Memory
493221 2021-12-10T12:40:08 Z blue Toys (CEOI18_toy) C++17
79 / 100
5000 ms 71568 KB
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <map>
using namespace std;

#define sz(x) (int(x.size()))
using vi = vector<int>;

map< int, vector<int> > res;

void solve(int i)
{
    // cerr << "solve " << i << '\n';
    if(res.find(i) != res.end()) return;

    vi ans(1, i-1);
    for(int j = 2; j < i && j*j <= i; j++)
    {
        if(i % j == 0)
        {
            int u = j;
            int v = i/j;
            solve(u);
            solve(v);
            for(int a: res[u])
                for(int b: res[v])
                    ans.push_back(a+b);
        }
    }
    sort(ans.begin(), ans.end());
    ans.erase(unique(ans.begin(), ans.end()), ans.end());

    res[i] = ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    // vector<int> res[1+n];
    // for(int i = 1; i <= n; i++)
    // {
    //     res[i].push_back(i-1);
    //     for(int j = 1; j < i && j*j <= i; j++)
    //     {
    //         if(i % j == 0)
    //         {
    //             int u = j;
    //             int v = i/j;
    //             for(int a: res[u])
    //                 for(int b: res[v])
    //                     res[i].push_back(a+b);
    //             // break;
    //         }
    //     }
    //     // sort(res[i].begin(), res[i].end());
    //     // res[i].erase(unique(res[i].begin(), res[i].end()), res[i].end());
    //
    //     // cerr << i << " : " << sz(res[i]) << '\n';
    // }

    solve(n);

    vi ans = res[n];

    cout << sz(ans) << '\n';
    for(int r: ans) cout << r << ' ';
    cout << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 0 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 0 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 0 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 0 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 3 ms 460 KB Output is correct
51 Correct 3 ms 460 KB Output is correct
52 Correct 3 ms 460 KB Output is correct
53 Correct 3 ms 460 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 6 ms 592 KB Output is correct
56 Correct 6 ms 524 KB Output is correct
57 Correct 5 ms 460 KB Output is correct
58 Correct 0 ms 204 KB Output is correct
59 Correct 0 ms 204 KB Output is correct
60 Correct 1 ms 332 KB Output is correct
61 Correct 3 ms 428 KB Output is correct
62 Correct 1 ms 332 KB Output is correct
63 Correct 1 ms 320 KB Output is correct
64 Correct 0 ms 204 KB Output is correct
65 Correct 2 ms 332 KB Output is correct
66 Correct 0 ms 204 KB Output is correct
67 Correct 0 ms 204 KB Output is correct
68 Correct 0 ms 204 KB Output is correct
69 Correct 0 ms 204 KB Output is correct
70 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 0 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 0 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 3 ms 460 KB Output is correct
51 Correct 3 ms 460 KB Output is correct
52 Correct 3 ms 460 KB Output is correct
53 Correct 3 ms 460 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 6 ms 592 KB Output is correct
56 Correct 6 ms 524 KB Output is correct
57 Correct 5 ms 460 KB Output is correct
58 Correct 0 ms 204 KB Output is correct
59 Correct 0 ms 204 KB Output is correct
60 Correct 1 ms 332 KB Output is correct
61 Correct 3 ms 428 KB Output is correct
62 Correct 1 ms 332 KB Output is correct
63 Correct 1 ms 320 KB Output is correct
64 Correct 0 ms 204 KB Output is correct
65 Correct 2 ms 332 KB Output is correct
66 Correct 0 ms 204 KB Output is correct
67 Correct 0 ms 204 KB Output is correct
68 Correct 0 ms 204 KB Output is correct
69 Correct 0 ms 204 KB Output is correct
70 Correct 1 ms 332 KB Output is correct
71 Correct 832 ms 32284 KB Output is correct
72 Correct 481 ms 17900 KB Output is correct
73 Correct 936 ms 32720 KB Output is correct
74 Correct 361 ms 15724 KB Output is correct
75 Correct 482 ms 25700 KB Output is correct
76 Correct 1806 ms 62536 KB Output is correct
77 Correct 1975 ms 63496 KB Output is correct
78 Correct 1382 ms 56240 KB Output is correct
79 Correct 1541 ms 57248 KB Output is correct
80 Correct 0 ms 204 KB Output is correct
81 Correct 0 ms 204 KB Output is correct
82 Correct 10 ms 844 KB Output is correct
83 Correct 181 ms 6748 KB Output is correct
84 Correct 159 ms 6644 KB Output is correct
85 Correct 33 ms 1900 KB Output is correct
86 Correct 1 ms 204 KB Output is correct
87 Correct 184 ms 8180 KB Output is correct
88 Correct 1 ms 204 KB Output is correct
89 Correct 0 ms 204 KB Output is correct
90 Correct 1 ms 204 KB Output is correct
91 Correct 24 ms 1172 KB Output is correct
92 Correct 110 ms 6812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 0 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 0 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 3 ms 460 KB Output is correct
51 Correct 3 ms 460 KB Output is correct
52 Correct 3 ms 460 KB Output is correct
53 Correct 3 ms 460 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 6 ms 592 KB Output is correct
56 Correct 6 ms 524 KB Output is correct
57 Correct 5 ms 460 KB Output is correct
58 Correct 0 ms 204 KB Output is correct
59 Correct 0 ms 204 KB Output is correct
60 Correct 1 ms 332 KB Output is correct
61 Correct 3 ms 428 KB Output is correct
62 Correct 1 ms 332 KB Output is correct
63 Correct 1 ms 320 KB Output is correct
64 Correct 0 ms 204 KB Output is correct
65 Correct 2 ms 332 KB Output is correct
66 Correct 0 ms 204 KB Output is correct
67 Correct 0 ms 204 KB Output is correct
68 Correct 0 ms 204 KB Output is correct
69 Correct 0 ms 204 KB Output is correct
70 Correct 1 ms 332 KB Output is correct
71 Correct 832 ms 32284 KB Output is correct
72 Correct 481 ms 17900 KB Output is correct
73 Correct 936 ms 32720 KB Output is correct
74 Correct 361 ms 15724 KB Output is correct
75 Correct 482 ms 25700 KB Output is correct
76 Correct 1806 ms 62536 KB Output is correct
77 Correct 1975 ms 63496 KB Output is correct
78 Correct 1382 ms 56240 KB Output is correct
79 Correct 1541 ms 57248 KB Output is correct
80 Correct 0 ms 204 KB Output is correct
81 Correct 0 ms 204 KB Output is correct
82 Correct 10 ms 844 KB Output is correct
83 Correct 181 ms 6748 KB Output is correct
84 Correct 159 ms 6644 KB Output is correct
85 Correct 33 ms 1900 KB Output is correct
86 Correct 1 ms 204 KB Output is correct
87 Correct 184 ms 8180 KB Output is correct
88 Correct 1 ms 204 KB Output is correct
89 Correct 0 ms 204 KB Output is correct
90 Correct 1 ms 204 KB Output is correct
91 Correct 24 ms 1172 KB Output is correct
92 Correct 110 ms 6812 KB Output is correct
93 Execution timed out 5031 ms 71568 KB Time limit exceeded
94 Halted 0 ms 0 KB -