Submission #538915

# Submission time Handle Problem Language Result Execution time Memory
538915 2022-03-18T04:09:04 Z ryangohca Toys (CEOI18_toy) C++17
79 / 100
889 ms 262144 KB
#include <bits/stdc++.h>
#define int long long
#define pii pair<int, int>
#define ti3 tuple<int, int, int>
#define ti4 tuple<int, int, int, int>
// This is like my secret account; yes it's like that  ~ Baek Jiheon, Feel Good (Secret Code)
using namespace std;
map<pii, int> off;
unordered_set<int> *dfs(int x, int s){
    unordered_set<int> * curr_set = new unordered_set<int>();
    curr_set->insert(x-1);
    off[{x, s}] = 0;
    for (int i = s; i*i<=x; i++){
        if (x%i != 0) continue;
        unordered_set<int> *child = dfs(x/i, i);
        if (child->size() <= curr_set->size()){
            int x1 = off[{x/i, i}];
            int p = off[{x, s}];
            for (auto j : *child){
                curr_set->insert(j + x1 + i-1 - p);
            }
        } else {
            swap(child, curr_set);
            swap(off[{x, s}], off[{x/i, i}]);
            off[{x, s}] += i - 1;
            int x1 = off[{x/i, i}];
            int p = off[{x, s}];
            for (auto j : *child){
                curr_set->insert(j + x1 - p);
            }
        }
    }
    return curr_set;
}
main(){
    int x; cin >> x;
    unordered_set<int> *ans = dfs(x, 2);
    vector<int> ot;
    int x2 = off[{x, 2}];
    for (auto i : *ans){
        ot.push_back(i + x2);
    }
    sort(ot.begin(), ot.end());
    cout << ot.size() << '\n';
    for (auto i : ot) cout << i << ' ';
}

Compilation message

toy.cpp:35:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   35 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 300 KB Output is correct
9 Correct 0 ms 300 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 300 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 300 KB Output is correct
9 Correct 0 ms 300 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 300 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 300 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 300 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 296 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 300 KB Output is correct
48 Correct 1 ms 304 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 300 KB Output is correct
9 Correct 0 ms 300 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 300 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 300 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 300 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 296 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 300 KB Output is correct
48 Correct 1 ms 304 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 2 ms 852 KB Output is correct
51 Correct 2 ms 808 KB Output is correct
52 Correct 2 ms 812 KB Output is correct
53 Correct 2 ms 852 KB Output is correct
54 Correct 1 ms 596 KB Output is correct
55 Correct 2 ms 1236 KB Output is correct
56 Correct 3 ms 1236 KB Output is correct
57 Correct 2 ms 1108 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 2 ms 808 KB Output is correct
62 Correct 1 ms 468 KB Output is correct
63 Correct 1 ms 340 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Correct 1 ms 596 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 1 ms 212 KB Output is correct
68 Correct 1 ms 296 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 1 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 300 KB Output is correct
9 Correct 0 ms 300 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 300 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 300 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 300 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 296 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 300 KB Output is correct
48 Correct 1 ms 304 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 2 ms 852 KB Output is correct
51 Correct 2 ms 808 KB Output is correct
52 Correct 2 ms 812 KB Output is correct
53 Correct 2 ms 852 KB Output is correct
54 Correct 1 ms 596 KB Output is correct
55 Correct 2 ms 1236 KB Output is correct
56 Correct 3 ms 1236 KB Output is correct
57 Correct 2 ms 1108 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 2 ms 808 KB Output is correct
62 Correct 1 ms 468 KB Output is correct
63 Correct 1 ms 340 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Correct 1 ms 596 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 1 ms 212 KB Output is correct
68 Correct 1 ms 296 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 1 ms 596 KB Output is correct
71 Correct 211 ms 76424 KB Output is correct
72 Correct 128 ms 47364 KB Output is correct
73 Correct 236 ms 89960 KB Output is correct
74 Correct 96 ms 36548 KB Output is correct
75 Correct 130 ms 51680 KB Output is correct
76 Correct 452 ms 167308 KB Output is correct
77 Correct 519 ms 200492 KB Output is correct
78 Correct 337 ms 127852 KB Output is correct
79 Correct 348 ms 133632 KB Output is correct
80 Correct 1 ms 296 KB Output is correct
81 Correct 1 ms 212 KB Output is correct
82 Correct 3 ms 980 KB Output is correct
83 Correct 40 ms 17504 KB Output is correct
84 Correct 41 ms 17100 KB Output is correct
85 Correct 8 ms 2856 KB Output is correct
86 Correct 1 ms 340 KB Output is correct
87 Correct 43 ms 16052 KB Output is correct
88 Correct 1 ms 212 KB Output is correct
89 Correct 1 ms 300 KB Output is correct
90 Correct 1 ms 340 KB Output is correct
91 Correct 10 ms 3116 KB Output is correct
92 Correct 39 ms 13520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 300 KB Output is correct
9 Correct 0 ms 300 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 300 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 300 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 300 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 296 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 300 KB Output is correct
48 Correct 1 ms 304 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 2 ms 852 KB Output is correct
51 Correct 2 ms 808 KB Output is correct
52 Correct 2 ms 812 KB Output is correct
53 Correct 2 ms 852 KB Output is correct
54 Correct 1 ms 596 KB Output is correct
55 Correct 2 ms 1236 KB Output is correct
56 Correct 3 ms 1236 KB Output is correct
57 Correct 2 ms 1108 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 2 ms 808 KB Output is correct
62 Correct 1 ms 468 KB Output is correct
63 Correct 1 ms 340 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Correct 1 ms 596 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 1 ms 212 KB Output is correct
68 Correct 1 ms 296 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 1 ms 596 KB Output is correct
71 Correct 211 ms 76424 KB Output is correct
72 Correct 128 ms 47364 KB Output is correct
73 Correct 236 ms 89960 KB Output is correct
74 Correct 96 ms 36548 KB Output is correct
75 Correct 130 ms 51680 KB Output is correct
76 Correct 452 ms 167308 KB Output is correct
77 Correct 519 ms 200492 KB Output is correct
78 Correct 337 ms 127852 KB Output is correct
79 Correct 348 ms 133632 KB Output is correct
80 Correct 1 ms 296 KB Output is correct
81 Correct 1 ms 212 KB Output is correct
82 Correct 3 ms 980 KB Output is correct
83 Correct 40 ms 17504 KB Output is correct
84 Correct 41 ms 17100 KB Output is correct
85 Correct 8 ms 2856 KB Output is correct
86 Correct 1 ms 340 KB Output is correct
87 Correct 43 ms 16052 KB Output is correct
88 Correct 1 ms 212 KB Output is correct
89 Correct 1 ms 300 KB Output is correct
90 Correct 1 ms 340 KB Output is correct
91 Correct 10 ms 3116 KB Output is correct
92 Correct 39 ms 13520 KB Output is correct
93 Runtime error 889 ms 262144 KB Execution killed with signal 9
94 Halted 0 ms 0 KB -