Submission #699257

# Submission time Handle Problem Language Result Execution time Memory
699257 2023-02-16T09:39:52 Z dattranxxx Toys (CEOI18_toy) C++11
79 / 100
5000 ms 85512 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

const int N = 1e5 + 5;

int n;
vector<int> divi[N];
map<int, bool> vis[N];

vector<pair<int, int>> adj[N];

int main() {
  cin.tie(0)->sync_with_stdio(0); cout.tie(0);
  cin >> n;
  vector<int> d;
  for (int i = 2; i * i <= n; ++i) if (n % i == 0) {
    d.emplace_back(i);
    if (i * i != n) d.emplace_back(n / i);
  }
  d.emplace_back(n);
  sort(d.begin(), d.end());
  
  for (int i = 0; i < d.size(); ++i) {
    for (int j = 0; j < i; ++j) if (d[i] % d[j] == 0) {
      int k = lower_bound(d.begin(), d.end(), d[i] / d[j]) - d.begin();
      adj[i].emplace_back(j, k);
    }
  }

  
  queue<pair<int, int>> q;
  q.emplace(d.size() - 1, 0);
  
  while (!q.empty()) {
    int i, s; tie(i, s) = q.front(); q.pop();
    
    for (auto& p : adj[i]) {
      int j, k; tie(j, k) = p;
      if (!vis[k][s + d[j] - 1]) {
        q.emplace(k, s + d[j] - 1);
        vis[k][s + d[j] - 1] = 1;
      }
    }
    
    vis[d.size()][s + d[i] - 1] = 1;
  }
  
  cout << vis[d.size()].size() << '\n';
  for (auto& x : vis[d.size()]) {
    cout << x.first << ' ';
  }
  
  
  
	return 0;
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:24:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   for (int i = 0; i < d.size(); ++i) {
      |                   ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 5 ms 9684 KB Output is correct
3 Correct 5 ms 9684 KB Output is correct
4 Correct 5 ms 9684 KB Output is correct
5 Correct 5 ms 9648 KB Output is correct
6 Correct 4 ms 9684 KB Output is correct
7 Correct 4 ms 9684 KB Output is correct
8 Correct 5 ms 9684 KB Output is correct
9 Correct 5 ms 9684 KB Output is correct
10 Correct 5 ms 9684 KB Output is correct
11 Correct 5 ms 9684 KB Output is correct
12 Correct 5 ms 9684 KB Output is correct
13 Correct 5 ms 9644 KB Output is correct
14 Correct 4 ms 9684 KB Output is correct
15 Correct 5 ms 9696 KB Output is correct
16 Correct 5 ms 9692 KB Output is correct
17 Correct 5 ms 9688 KB Output is correct
18 Correct 6 ms 9636 KB Output is correct
19 Correct 5 ms 9684 KB Output is correct
20 Correct 5 ms 9684 KB Output is correct
21 Correct 5 ms 9684 KB Output is correct
22 Correct 5 ms 9684 KB Output is correct
23 Correct 6 ms 9684 KB Output is correct
24 Correct 5 ms 9684 KB Output is correct
25 Correct 5 ms 9684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 5 ms 9684 KB Output is correct
3 Correct 5 ms 9684 KB Output is correct
4 Correct 5 ms 9684 KB Output is correct
5 Correct 5 ms 9648 KB Output is correct
6 Correct 4 ms 9684 KB Output is correct
7 Correct 4 ms 9684 KB Output is correct
8 Correct 5 ms 9684 KB Output is correct
9 Correct 5 ms 9684 KB Output is correct
10 Correct 5 ms 9684 KB Output is correct
11 Correct 5 ms 9684 KB Output is correct
12 Correct 5 ms 9684 KB Output is correct
13 Correct 5 ms 9644 KB Output is correct
14 Correct 4 ms 9684 KB Output is correct
15 Correct 5 ms 9696 KB Output is correct
16 Correct 5 ms 9692 KB Output is correct
17 Correct 5 ms 9688 KB Output is correct
18 Correct 6 ms 9636 KB Output is correct
19 Correct 5 ms 9684 KB Output is correct
20 Correct 5 ms 9684 KB Output is correct
21 Correct 5 ms 9684 KB Output is correct
22 Correct 5 ms 9684 KB Output is correct
23 Correct 6 ms 9684 KB Output is correct
24 Correct 5 ms 9684 KB Output is correct
25 Correct 5 ms 9684 KB Output is correct
26 Correct 5 ms 9684 KB Output is correct
27 Correct 5 ms 9684 KB Output is correct
28 Correct 5 ms 9684 KB Output is correct
29 Correct 5 ms 9684 KB Output is correct
30 Correct 5 ms 9684 KB Output is correct
31 Correct 5 ms 9684 KB Output is correct
32 Correct 5 ms 9684 KB Output is correct
33 Correct 5 ms 9684 KB Output is correct
34 Correct 5 ms 9684 KB Output is correct
35 Correct 5 ms 9684 KB Output is correct
36 Correct 5 ms 9684 KB Output is correct
37 Correct 5 ms 9684 KB Output is correct
38 Correct 6 ms 9684 KB Output is correct
39 Correct 5 ms 9712 KB Output is correct
40 Correct 6 ms 9684 KB Output is correct
41 Correct 5 ms 9684 KB Output is correct
42 Correct 5 ms 9684 KB Output is correct
43 Correct 5 ms 9684 KB Output is correct
44 Correct 7 ms 9684 KB Output is correct
45 Correct 6 ms 9684 KB Output is correct
46 Correct 5 ms 9684 KB Output is correct
47 Correct 5 ms 9760 KB Output is correct
48 Correct 5 ms 9684 KB Output is correct
49 Correct 5 ms 9684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 5 ms 9684 KB Output is correct
3 Correct 5 ms 9684 KB Output is correct
4 Correct 5 ms 9684 KB Output is correct
5 Correct 5 ms 9648 KB Output is correct
6 Correct 4 ms 9684 KB Output is correct
7 Correct 4 ms 9684 KB Output is correct
8 Correct 5 ms 9684 KB Output is correct
9 Correct 5 ms 9684 KB Output is correct
10 Correct 5 ms 9684 KB Output is correct
11 Correct 5 ms 9684 KB Output is correct
12 Correct 5 ms 9684 KB Output is correct
13 Correct 5 ms 9644 KB Output is correct
14 Correct 4 ms 9684 KB Output is correct
15 Correct 5 ms 9696 KB Output is correct
16 Correct 5 ms 9692 KB Output is correct
17 Correct 5 ms 9688 KB Output is correct
18 Correct 6 ms 9636 KB Output is correct
19 Correct 5 ms 9684 KB Output is correct
20 Correct 5 ms 9684 KB Output is correct
21 Correct 5 ms 9684 KB Output is correct
22 Correct 5 ms 9684 KB Output is correct
23 Correct 6 ms 9684 KB Output is correct
24 Correct 5 ms 9684 KB Output is correct
25 Correct 5 ms 9684 KB Output is correct
26 Correct 5 ms 9684 KB Output is correct
27 Correct 5 ms 9684 KB Output is correct
28 Correct 5 ms 9684 KB Output is correct
29 Correct 5 ms 9684 KB Output is correct
30 Correct 5 ms 9684 KB Output is correct
31 Correct 5 ms 9684 KB Output is correct
32 Correct 5 ms 9684 KB Output is correct
33 Correct 5 ms 9684 KB Output is correct
34 Correct 5 ms 9684 KB Output is correct
35 Correct 5 ms 9684 KB Output is correct
36 Correct 5 ms 9684 KB Output is correct
37 Correct 5 ms 9684 KB Output is correct
38 Correct 6 ms 9684 KB Output is correct
39 Correct 5 ms 9712 KB Output is correct
40 Correct 6 ms 9684 KB Output is correct
41 Correct 5 ms 9684 KB Output is correct
42 Correct 5 ms 9684 KB Output is correct
43 Correct 5 ms 9684 KB Output is correct
44 Correct 7 ms 9684 KB Output is correct
45 Correct 6 ms 9684 KB Output is correct
46 Correct 5 ms 9684 KB Output is correct
47 Correct 5 ms 9760 KB Output is correct
48 Correct 5 ms 9684 KB Output is correct
49 Correct 5 ms 9684 KB Output is correct
50 Correct 7 ms 9940 KB Output is correct
51 Correct 7 ms 9940 KB Output is correct
52 Correct 8 ms 9996 KB Output is correct
53 Correct 8 ms 9940 KB Output is correct
54 Correct 6 ms 9804 KB Output is correct
55 Correct 8 ms 10068 KB Output is correct
56 Correct 8 ms 10068 KB Output is correct
57 Correct 7 ms 10008 KB Output is correct
58 Correct 5 ms 9684 KB Output is correct
59 Correct 5 ms 9684 KB Output is correct
60 Correct 5 ms 9684 KB Output is correct
61 Correct 6 ms 9812 KB Output is correct
62 Correct 6 ms 9812 KB Output is correct
63 Correct 5 ms 9684 KB Output is correct
64 Correct 6 ms 9684 KB Output is correct
65 Correct 6 ms 9812 KB Output is correct
66 Correct 5 ms 9684 KB Output is correct
67 Correct 5 ms 9684 KB Output is correct
68 Correct 7 ms 9684 KB Output is correct
69 Correct 5 ms 9684 KB Output is correct
70 Correct 7 ms 9820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 5 ms 9684 KB Output is correct
3 Correct 5 ms 9684 KB Output is correct
4 Correct 5 ms 9684 KB Output is correct
5 Correct 5 ms 9648 KB Output is correct
6 Correct 4 ms 9684 KB Output is correct
7 Correct 4 ms 9684 KB Output is correct
8 Correct 5 ms 9684 KB Output is correct
9 Correct 5 ms 9684 KB Output is correct
10 Correct 5 ms 9684 KB Output is correct
11 Correct 5 ms 9684 KB Output is correct
12 Correct 5 ms 9684 KB Output is correct
13 Correct 5 ms 9644 KB Output is correct
14 Correct 4 ms 9684 KB Output is correct
15 Correct 5 ms 9696 KB Output is correct
16 Correct 5 ms 9692 KB Output is correct
17 Correct 5 ms 9688 KB Output is correct
18 Correct 6 ms 9636 KB Output is correct
19 Correct 5 ms 9684 KB Output is correct
20 Correct 5 ms 9684 KB Output is correct
21 Correct 5 ms 9684 KB Output is correct
22 Correct 5 ms 9684 KB Output is correct
23 Correct 6 ms 9684 KB Output is correct
24 Correct 5 ms 9684 KB Output is correct
25 Correct 5 ms 9684 KB Output is correct
26 Correct 5 ms 9684 KB Output is correct
27 Correct 5 ms 9684 KB Output is correct
28 Correct 5 ms 9684 KB Output is correct
29 Correct 5 ms 9684 KB Output is correct
30 Correct 5 ms 9684 KB Output is correct
31 Correct 5 ms 9684 KB Output is correct
32 Correct 5 ms 9684 KB Output is correct
33 Correct 5 ms 9684 KB Output is correct
34 Correct 5 ms 9684 KB Output is correct
35 Correct 5 ms 9684 KB Output is correct
36 Correct 5 ms 9684 KB Output is correct
37 Correct 5 ms 9684 KB Output is correct
38 Correct 6 ms 9684 KB Output is correct
39 Correct 5 ms 9712 KB Output is correct
40 Correct 6 ms 9684 KB Output is correct
41 Correct 5 ms 9684 KB Output is correct
42 Correct 5 ms 9684 KB Output is correct
43 Correct 5 ms 9684 KB Output is correct
44 Correct 7 ms 9684 KB Output is correct
45 Correct 6 ms 9684 KB Output is correct
46 Correct 5 ms 9684 KB Output is correct
47 Correct 5 ms 9760 KB Output is correct
48 Correct 5 ms 9684 KB Output is correct
49 Correct 5 ms 9684 KB Output is correct
50 Correct 7 ms 9940 KB Output is correct
51 Correct 7 ms 9940 KB Output is correct
52 Correct 8 ms 9996 KB Output is correct
53 Correct 8 ms 9940 KB Output is correct
54 Correct 6 ms 9804 KB Output is correct
55 Correct 8 ms 10068 KB Output is correct
56 Correct 8 ms 10068 KB Output is correct
57 Correct 7 ms 10008 KB Output is correct
58 Correct 5 ms 9684 KB Output is correct
59 Correct 5 ms 9684 KB Output is correct
60 Correct 5 ms 9684 KB Output is correct
61 Correct 6 ms 9812 KB Output is correct
62 Correct 6 ms 9812 KB Output is correct
63 Correct 5 ms 9684 KB Output is correct
64 Correct 6 ms 9684 KB Output is correct
65 Correct 6 ms 9812 KB Output is correct
66 Correct 5 ms 9684 KB Output is correct
67 Correct 5 ms 9684 KB Output is correct
68 Correct 7 ms 9684 KB Output is correct
69 Correct 5 ms 9684 KB Output is correct
70 Correct 7 ms 9820 KB Output is correct
71 Correct 732 ms 28384 KB Output is correct
72 Correct 471 ms 23916 KB Output is correct
73 Correct 689 ms 26296 KB Output is correct
74 Correct 318 ms 20804 KB Output is correct
75 Correct 411 ms 21636 KB Output is correct
76 Correct 1353 ms 34852 KB Output is correct
77 Correct 1159 ms 31752 KB Output is correct
78 Correct 952 ms 30424 KB Output is correct
79 Correct 990 ms 29872 KB Output is correct
80 Correct 5 ms 9708 KB Output is correct
81 Correct 5 ms 9692 KB Output is correct
82 Correct 8 ms 9968 KB Output is correct
83 Correct 79 ms 12952 KB Output is correct
84 Correct 90 ms 13772 KB Output is correct
85 Correct 19 ms 10836 KB Output is correct
86 Correct 5 ms 9684 KB Output is correct
87 Correct 111 ms 14416 KB Output is correct
88 Correct 6 ms 9684 KB Output is correct
89 Correct 7 ms 9684 KB Output is correct
90 Correct 5 ms 9684 KB Output is correct
91 Correct 27 ms 11476 KB Output is correct
92 Correct 128 ms 16196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 5 ms 9684 KB Output is correct
3 Correct 5 ms 9684 KB Output is correct
4 Correct 5 ms 9684 KB Output is correct
5 Correct 5 ms 9648 KB Output is correct
6 Correct 4 ms 9684 KB Output is correct
7 Correct 4 ms 9684 KB Output is correct
8 Correct 5 ms 9684 KB Output is correct
9 Correct 5 ms 9684 KB Output is correct
10 Correct 5 ms 9684 KB Output is correct
11 Correct 5 ms 9684 KB Output is correct
12 Correct 5 ms 9684 KB Output is correct
13 Correct 5 ms 9644 KB Output is correct
14 Correct 4 ms 9684 KB Output is correct
15 Correct 5 ms 9696 KB Output is correct
16 Correct 5 ms 9692 KB Output is correct
17 Correct 5 ms 9688 KB Output is correct
18 Correct 6 ms 9636 KB Output is correct
19 Correct 5 ms 9684 KB Output is correct
20 Correct 5 ms 9684 KB Output is correct
21 Correct 5 ms 9684 KB Output is correct
22 Correct 5 ms 9684 KB Output is correct
23 Correct 6 ms 9684 KB Output is correct
24 Correct 5 ms 9684 KB Output is correct
25 Correct 5 ms 9684 KB Output is correct
26 Correct 5 ms 9684 KB Output is correct
27 Correct 5 ms 9684 KB Output is correct
28 Correct 5 ms 9684 KB Output is correct
29 Correct 5 ms 9684 KB Output is correct
30 Correct 5 ms 9684 KB Output is correct
31 Correct 5 ms 9684 KB Output is correct
32 Correct 5 ms 9684 KB Output is correct
33 Correct 5 ms 9684 KB Output is correct
34 Correct 5 ms 9684 KB Output is correct
35 Correct 5 ms 9684 KB Output is correct
36 Correct 5 ms 9684 KB Output is correct
37 Correct 5 ms 9684 KB Output is correct
38 Correct 6 ms 9684 KB Output is correct
39 Correct 5 ms 9712 KB Output is correct
40 Correct 6 ms 9684 KB Output is correct
41 Correct 5 ms 9684 KB Output is correct
42 Correct 5 ms 9684 KB Output is correct
43 Correct 5 ms 9684 KB Output is correct
44 Correct 7 ms 9684 KB Output is correct
45 Correct 6 ms 9684 KB Output is correct
46 Correct 5 ms 9684 KB Output is correct
47 Correct 5 ms 9760 KB Output is correct
48 Correct 5 ms 9684 KB Output is correct
49 Correct 5 ms 9684 KB Output is correct
50 Correct 7 ms 9940 KB Output is correct
51 Correct 7 ms 9940 KB Output is correct
52 Correct 8 ms 9996 KB Output is correct
53 Correct 8 ms 9940 KB Output is correct
54 Correct 6 ms 9804 KB Output is correct
55 Correct 8 ms 10068 KB Output is correct
56 Correct 8 ms 10068 KB Output is correct
57 Correct 7 ms 10008 KB Output is correct
58 Correct 5 ms 9684 KB Output is correct
59 Correct 5 ms 9684 KB Output is correct
60 Correct 5 ms 9684 KB Output is correct
61 Correct 6 ms 9812 KB Output is correct
62 Correct 6 ms 9812 KB Output is correct
63 Correct 5 ms 9684 KB Output is correct
64 Correct 6 ms 9684 KB Output is correct
65 Correct 6 ms 9812 KB Output is correct
66 Correct 5 ms 9684 KB Output is correct
67 Correct 5 ms 9684 KB Output is correct
68 Correct 7 ms 9684 KB Output is correct
69 Correct 5 ms 9684 KB Output is correct
70 Correct 7 ms 9820 KB Output is correct
71 Correct 732 ms 28384 KB Output is correct
72 Correct 471 ms 23916 KB Output is correct
73 Correct 689 ms 26296 KB Output is correct
74 Correct 318 ms 20804 KB Output is correct
75 Correct 411 ms 21636 KB Output is correct
76 Correct 1353 ms 34852 KB Output is correct
77 Correct 1159 ms 31752 KB Output is correct
78 Correct 952 ms 30424 KB Output is correct
79 Correct 990 ms 29872 KB Output is correct
80 Correct 5 ms 9708 KB Output is correct
81 Correct 5 ms 9692 KB Output is correct
82 Correct 8 ms 9968 KB Output is correct
83 Correct 79 ms 12952 KB Output is correct
84 Correct 90 ms 13772 KB Output is correct
85 Correct 19 ms 10836 KB Output is correct
86 Correct 5 ms 9684 KB Output is correct
87 Correct 111 ms 14416 KB Output is correct
88 Correct 6 ms 9684 KB Output is correct
89 Correct 7 ms 9684 KB Output is correct
90 Correct 5 ms 9684 KB Output is correct
91 Correct 27 ms 11476 KB Output is correct
92 Correct 128 ms 16196 KB Output is correct
93 Execution timed out 5071 ms 85512 KB Time limit exceeded
94 Halted 0 ms 0 KB -