File tree Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Original file line number Diff line number Diff line change 5
5
#include < iostream>
6
6
#include < vector>
7
7
#include < string>
8
- #include " ../util/bump_alloc.hpp"
9
8
namespace cp_algo ::structures {
10
9
template <int sigma = 26 , char mch = ' a' >
11
10
struct eertree {
@@ -63,7 +62,7 @@ namespace cp_algo::structures {
63
62
print (std::identity{});
64
63
}
65
64
private:
66
- std::vector<std::forward_list<int , bump_alloc< int > >> to;
65
+ std::vector<std::forward_list<int >> to;
67
66
std::vector<int > len, link, par;
68
67
std::string s;
69
68
int n = 1 , sz = 2 , last = 0 ;
Original file line number Diff line number Diff line change 1
1
#ifndef CP_ALGO_UTIL_BUMP_ALLOC_HPP
2
2
#define CP_ALGO_UTIL_BUMP_ALLOC_HPP
3
3
#include < cstddef>
4
+ #include " big_alloc.hpp"
4
5
namespace cp_algo {
5
- alignas (64 ) char buf[450 << 20 ];
6
- size_t buf_ind = sizeof buf;
7
- template <class T > struct bump_alloc {
6
+ template <class T , size_t max_len>
7
+ struct bump_alloc {
8
+ static char * buf;
9
+ static size_t buf_ind;
8
10
using value_type = T;
9
11
bump_alloc () = default ;
10
12
template <class U > bump_alloc (const U&) {}
@@ -15,5 +17,9 @@ namespace cp_algo {
15
17
}
16
18
void deallocate (T*, size_t ) {}
17
19
};
20
+ template <class T , size_t max_len>
21
+ char * bump_alloc<T, max_len>::buf = big_alloc<char >().allocate(max_len * sizeof (T));
22
+ template <class T , size_t max_len>
23
+ size_t bump_alloc<T, max_len>::buf_ind = max_len * sizeof (T);
18
24
}
19
25
#endif // CP_ALGO_UTIL_BUMP_ALLOC_HPP
Original file line number Diff line number Diff line change 6
6
#include " blazingio/blazingio.min.hpp"
7
7
#include " cp-algo/util/checkpoint.hpp"
8
8
#include " cp-algo/util/simd.hpp"
9
+ #include " cp-algo/util/bump_alloc.hpp"
9
10
#include " cp-algo/math/common.hpp"
10
11
11
12
using namespace std ;
@@ -14,13 +15,16 @@ using namespace cp_algo;
14
15
constexpr int mod = 998244353 ;
15
16
constexpr int imod = -math::inv2(mod);
16
17
18
+ template <int maxn = 100'000 >
17
19
vector<int > facts (vector<int > const & args) {
18
20
constexpr int accum = 4 ;
19
21
constexpr int simd_size = 8 ;
20
22
constexpr int block = 1 << 18 ;
21
23
constexpr int subblock = block / simd_size;
22
- static basic_string<array<int , 2 >> odd_args_per_block[mod / subblock];
23
- static basic_string<array<int , 2 >> reg_args_per_block[mod / subblock];
24
+ using T = array<int , 2 >;
25
+ using alloc = bump_alloc<T, 30 * maxn>;
26
+ basic_string<T, char_traits<T>, alloc> odd_args_per_block[mod / subblock];
27
+ basic_string<T, char_traits<T>, alloc> reg_args_per_block[mod / subblock];
24
28
constexpr int limit_reg = mod / 64 ;
25
29
int limit_odd = 0 ;
26
30
You can’t perform that action at this time.
0 commit comments