Submission #679902

# Submission time Handle Problem Language Result Execution time Memory
679902 2023-01-09T15:53:36 Z peijar Toys (CEOI18_toy) C++17
100 / 100
3495 ms 88772 KB
#include <bits/extc++.h>
#include <bits/stdc++.h>
#define int long long
using namespace std;

namespace std {
template <typename T> ostream &operator<<(ostream &out, const vector<T> &vec) {
  out << "[";
  for (int i = 0; i < (int)vec.size(); ++i) {
    out << vec[i];
    if (i + 1 < (int)vec.size())
      out << ", ";
  }
  return out << "]";
}
} // namespace std

void dbg_out() { cout << endl; }
template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) {
  cout << ' ' << H;
  dbg_out(T...);
}

#ifdef DEBUG
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

// To use most b i t s rather than j u s t the lowest ones :
struct chash { // large odd number for C
  const uint64_t C = (int)(4e18 * acos(0)) | 71;
  int operator()(int x) const { return __builtin_bswap64(x * C); }
};

using hash_table = __gnu_pbds::gp_hash_table<int, int, chash>;
using hash_set = __gnu_pbds::gp_hash_table<int, __gnu_pbds::null_type, chash>;

signed main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int n;
  cin >> n;
  vector<int> diviseurs;
  for (int d = 1; d * d <= n; d++) {
    if (n % d == 0) {
      diviseurs.push_back(d);
      if (d * d != n)
        diviseurs.push_back(n / d);
    }
  }

  sort(diviseurs.begin(), diviseurs.end());

  int nbDiviseurs = diviseurs.size();
  hash_table idDiv;
  for (int i = 0; i < nbDiviseurs; ++i)
    idDiv[diviseurs[i]] = i;
  vector<hash_set> possibilites(nbDiviseurs);
  for (int i = 0; i < nbDiviseurs; ++i) {
    int d = diviseurs[i];
    possibilites[i].insert(d - 1);
    for (int j = i + 1; j < nbDiviseurs; ++j)
      if (diviseurs[j] % d == 0) {
        int dd = diviseurs[j] / d;
        if (dd <= d)
          for (int p : possibilites[i])
            for (int q : possibilites[idDiv[dd]])
              possibilites[j].insert(p + q);
      }
  }
  vector<int> ret;
  for (int x : possibilites[nbDiviseurs - 1])
    ret.push_back(x);
  sort(ret.begin(), ret.end());
  cout << ret.size() << endl;
  for (int x : ret)
    cout << x << ' ';
  cout << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 320 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 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 0 ms 212 KB Output is correct
20 Correct 0 ms 324 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 320 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 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 0 ms 212 KB Output is correct
20 Correct 0 ms 324 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 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 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 320 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 320 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 320 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 324 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 1 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 320 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 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 0 ms 212 KB Output is correct
20 Correct 0 ms 324 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 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 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 320 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 320 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 320 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 324 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 1 ms 320 KB Output is correct
50 Correct 2 ms 576 KB Output is correct
51 Correct 2 ms 576 KB Output is correct
52 Correct 2 ms 580 KB Output is correct
53 Correct 2 ms 596 KB Output is correct
54 Correct 1 ms 468 KB Output is correct
55 Correct 3 ms 724 KB Output is correct
56 Correct 3 ms 708 KB Output is correct
57 Correct 3 ms 596 KB Output is correct
58 Correct 0 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 572 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 2 ms 468 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 0 ms 212 KB Output is correct
68 Correct 1 ms 212 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 320 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 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 0 ms 212 KB Output is correct
20 Correct 0 ms 324 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 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 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 320 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 320 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 320 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 324 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 1 ms 320 KB Output is correct
50 Correct 2 ms 576 KB Output is correct
51 Correct 2 ms 576 KB Output is correct
52 Correct 2 ms 580 KB Output is correct
53 Correct 2 ms 596 KB Output is correct
54 Correct 1 ms 468 KB Output is correct
55 Correct 3 ms 724 KB Output is correct
56 Correct 3 ms 708 KB Output is correct
57 Correct 3 ms 596 KB Output is correct
58 Correct 0 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 572 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 2 ms 468 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 0 ms 212 KB Output is correct
68 Correct 1 ms 212 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 1 ms 340 KB Output is correct
71 Correct 334 ms 19416 KB Output is correct
72 Correct 177 ms 15108 KB Output is correct
73 Correct 275 ms 17852 KB Output is correct
74 Correct 128 ms 11652 KB Output is correct
75 Correct 156 ms 12868 KB Output is correct
76 Correct 553 ms 26512 KB Output is correct
77 Correct 534 ms 23388 KB Output is correct
78 Correct 410 ms 21248 KB Output is correct
79 Correct 424 ms 21240 KB Output is correct
80 Correct 0 ms 212 KB Output is correct
81 Correct 1 ms 212 KB Output is correct
82 Correct 5 ms 724 KB Output is correct
83 Correct 46 ms 4112 KB Output is correct
84 Correct 46 ms 4420 KB Output is correct
85 Correct 11 ms 1748 KB Output is correct
86 Correct 1 ms 340 KB Output is correct
87 Correct 56 ms 5684 KB Output is correct
88 Correct 1 ms 212 KB Output is correct
89 Correct 1 ms 212 KB Output is correct
90 Correct 1 ms 340 KB Output is correct
91 Correct 12 ms 2476 KB Output is correct
92 Correct 50 ms 6848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 320 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 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 0 ms 212 KB Output is correct
20 Correct 0 ms 324 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 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 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 320 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 320 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 320 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 324 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 1 ms 320 KB Output is correct
50 Correct 2 ms 576 KB Output is correct
51 Correct 2 ms 576 KB Output is correct
52 Correct 2 ms 580 KB Output is correct
53 Correct 2 ms 596 KB Output is correct
54 Correct 1 ms 468 KB Output is correct
55 Correct 3 ms 724 KB Output is correct
56 Correct 3 ms 708 KB Output is correct
57 Correct 3 ms 596 KB Output is correct
58 Correct 0 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 572 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 2 ms 468 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 0 ms 212 KB Output is correct
68 Correct 1 ms 212 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 1 ms 340 KB Output is correct
71 Correct 334 ms 19416 KB Output is correct
72 Correct 177 ms 15108 KB Output is correct
73 Correct 275 ms 17852 KB Output is correct
74 Correct 128 ms 11652 KB Output is correct
75 Correct 156 ms 12868 KB Output is correct
76 Correct 553 ms 26512 KB Output is correct
77 Correct 534 ms 23388 KB Output is correct
78 Correct 410 ms 21248 KB Output is correct
79 Correct 424 ms 21240 KB Output is correct
80 Correct 0 ms 212 KB Output is correct
81 Correct 1 ms 212 KB Output is correct
82 Correct 5 ms 724 KB Output is correct
83 Correct 46 ms 4112 KB Output is correct
84 Correct 46 ms 4420 KB Output is correct
85 Correct 11 ms 1748 KB Output is correct
86 Correct 1 ms 340 KB Output is correct
87 Correct 56 ms 5684 KB Output is correct
88 Correct 1 ms 212 KB Output is correct
89 Correct 1 ms 212 KB Output is correct
90 Correct 1 ms 340 KB Output is correct
91 Correct 12 ms 2476 KB Output is correct
92 Correct 50 ms 6848 KB Output is correct
93 Correct 2657 ms 79912 KB Output is correct
94 Correct 1186 ms 52720 KB Output is correct
95 Correct 1479 ms 55932 KB Output is correct
96 Correct 1273 ms 49232 KB Output is correct
97 Correct 1240 ms 46104 KB Output is correct
98 Correct 3262 ms 87268 KB Output is correct
99 Correct 3495 ms 88772 KB Output is correct
100 Correct 3118 ms 85808 KB Output is correct
101 Correct 3272 ms 80356 KB Output is correct
102 Correct 2735 ms 70572 KB Output is correct
103 Correct 1825 ms 63484 KB Output is correct
104 Correct 1 ms 212 KB Output is correct
105 Correct 1 ms 212 KB Output is correct
106 Correct 7 ms 980 KB Output is correct
107 Correct 192 ms 10720 KB Output is correct
108 Correct 522 ms 21284 KB Output is correct
109 Correct 30 ms 3380 KB Output is correct
110 Correct 1 ms 340 KB Output is correct
111 Correct 216 ms 12744 KB Output is correct
112 Correct 1 ms 212 KB Output is correct
113 Correct 1 ms 212 KB Output is correct
114 Correct 4 ms 1144 KB Output is correct
115 Correct 1 ms 212 KB Output is correct
116 Correct 12 ms 1920 KB Output is correct
117 Correct 317 ms 25428 KB Output is correct