답안 #493220

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
493220 2021-12-10T12:37:23 Z blue Toys (CEOI18_toy) C++17
79 / 100
5000 ms 71788 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;

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

    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;
            vi su = solve(u);
            vi sv = solve(v);
            for(int a: su)
                for(int b: sv)
                    ans.push_back(a+b);
        }
    }
    sort(ans.begin(), ans.end());
    ans.erase(unique(ans.begin(), ans.end()), ans.end());

    res[i] = ans;

    return 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';
    // }

    vi ans = solve(n);

    cout << sz(ans) << '\n';
    for(int r: ans) cout << r << ' ';
    cout << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 276 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 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 1 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 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 316 KB Output is correct
20 Correct 1 ms 312 KB Output is correct
21 Correct 0 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 276 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 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 1 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 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 316 KB Output is correct
20 Correct 1 ms 312 KB Output is correct
21 Correct 0 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 1 ms 332 KB Output is correct
30 Correct 0 ms 316 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 1 ms 204 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 312 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 312 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 0 ms 316 KB Output is correct
45 Correct 1 ms 280 KB Output is correct
46 Correct 0 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 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 276 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 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 1 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 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 316 KB Output is correct
20 Correct 1 ms 312 KB Output is correct
21 Correct 0 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 1 ms 332 KB Output is correct
30 Correct 0 ms 316 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 1 ms 204 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 312 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 312 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 0 ms 316 KB Output is correct
45 Correct 1 ms 280 KB Output is correct
46 Correct 0 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 0 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 356 KB Output is correct
55 Correct 5 ms 588 KB Output is correct
56 Correct 7 ms 528 KB Output is correct
57 Correct 4 ms 568 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 460 KB Output is correct
62 Correct 1 ms 332 KB Output is correct
63 Correct 1 ms 332 KB Output is correct
64 Correct 0 ms 204 KB Output is correct
65 Correct 2 ms 436 KB Output is correct
66 Correct 1 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 1 ms 204 KB Output is correct
70 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 276 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 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 1 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 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 316 KB Output is correct
20 Correct 1 ms 312 KB Output is correct
21 Correct 0 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 1 ms 332 KB Output is correct
30 Correct 0 ms 316 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 1 ms 204 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 312 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 312 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 0 ms 316 KB Output is correct
45 Correct 1 ms 280 KB Output is correct
46 Correct 0 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 0 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 356 KB Output is correct
55 Correct 5 ms 588 KB Output is correct
56 Correct 7 ms 528 KB Output is correct
57 Correct 4 ms 568 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 460 KB Output is correct
62 Correct 1 ms 332 KB Output is correct
63 Correct 1 ms 332 KB Output is correct
64 Correct 0 ms 204 KB Output is correct
65 Correct 2 ms 436 KB Output is correct
66 Correct 1 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 1 ms 204 KB Output is correct
70 Correct 1 ms 332 KB Output is correct
71 Correct 860 ms 32316 KB Output is correct
72 Correct 503 ms 18024 KB Output is correct
73 Correct 948 ms 32956 KB Output is correct
74 Correct 370 ms 15820 KB Output is correct
75 Correct 507 ms 17844 KB Output is correct
76 Correct 1863 ms 62984 KB Output is correct
77 Correct 2091 ms 63608 KB Output is correct
78 Correct 1436 ms 56260 KB Output is correct
79 Correct 1495 ms 57744 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 796 KB Output is correct
83 Correct 189 ms 6664 KB Output is correct
84 Correct 163 ms 7764 KB Output is correct
85 Correct 31 ms 2040 KB Output is correct
86 Correct 1 ms 204 KB Output is correct
87 Correct 187 ms 6776 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 21 ms 1436 KB Output is correct
92 Correct 111 ms 6972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 276 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 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 1 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 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 316 KB Output is correct
20 Correct 1 ms 312 KB Output is correct
21 Correct 0 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 1 ms 332 KB Output is correct
30 Correct 0 ms 316 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 1 ms 204 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 312 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 312 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 0 ms 316 KB Output is correct
45 Correct 1 ms 280 KB Output is correct
46 Correct 0 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 0 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 356 KB Output is correct
55 Correct 5 ms 588 KB Output is correct
56 Correct 7 ms 528 KB Output is correct
57 Correct 4 ms 568 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 460 KB Output is correct
62 Correct 1 ms 332 KB Output is correct
63 Correct 1 ms 332 KB Output is correct
64 Correct 0 ms 204 KB Output is correct
65 Correct 2 ms 436 KB Output is correct
66 Correct 1 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 1 ms 204 KB Output is correct
70 Correct 1 ms 332 KB Output is correct
71 Correct 860 ms 32316 KB Output is correct
72 Correct 503 ms 18024 KB Output is correct
73 Correct 948 ms 32956 KB Output is correct
74 Correct 370 ms 15820 KB Output is correct
75 Correct 507 ms 17844 KB Output is correct
76 Correct 1863 ms 62984 KB Output is correct
77 Correct 2091 ms 63608 KB Output is correct
78 Correct 1436 ms 56260 KB Output is correct
79 Correct 1495 ms 57744 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 796 KB Output is correct
83 Correct 189 ms 6664 KB Output is correct
84 Correct 163 ms 7764 KB Output is correct
85 Correct 31 ms 2040 KB Output is correct
86 Correct 1 ms 204 KB Output is correct
87 Correct 187 ms 6776 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 21 ms 1436 KB Output is correct
92 Correct 111 ms 6972 KB Output is correct
93 Execution timed out 5023 ms 71788 KB Time limit exceeded
94 Halted 0 ms 0 KB -