Skip to content

Commit 7a28ec7

Browse files
committed
std::vector -> big_vector
1 parent 7b706e4 commit 7a28ec7

File tree

12 files changed

+30
-21
lines changed

12 files changed

+30
-21
lines changed

cp-algo/number_theory/dirichlet.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#ifndef CP_ALGO_NUMBER_THEORY_DIRICHLET_HPP
22
#define CP_ALGO_NUMBER_THEORY_DIRICHLET_HPP
3+
#include "../util/big_alloc.hpp"
34
#include <algorithm>
45
#include <cstdint>
56
#include <ranges>
@@ -110,7 +111,7 @@ namespace cp_algo::math {
110111

111112
auto Dirichlet_div(auto const& H, auto const& G, int64_t n) {
112113
auto m = std::size(G);
113-
auto F = H | std::views::take(m) | std::ranges::to<std::vector>();
114+
auto F = H | std::views::take(m) | std::ranges::to<big_vector>();
114115
Dirichlet_div_inplace(F, G, n);
115116
return F;
116117
}

cp-algo/number_theory/euler.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#ifndef CP_ALGO_NUMBER_THEORY_EULER_HPP
22
#define CP_ALGO_NUMBER_THEORY_EULER_HPP
33
#include "factorize.hpp"
4+
#include "../util/big_alloc.hpp"
45
namespace cp_algo::math {
56
auto euler_phi(auto m) {
6-
auto primes = to<std::vector>(factorize(m));
7+
auto primes = to<big_vector>(factorize(m));
78
std::ranges::sort(primes);
89
auto [from, to] = std::ranges::unique(primes);
910
primes.erase(from, to);

cp-algo/number_theory/two_squares.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define CP_ALGO_NUMBER_THEORY_TWO_SQUARES_HPP
33
#include "euler.hpp"
44
#include "../util/complex.hpp"
5+
#include "../util/big_alloc.hpp"
56
#include <cassert>
67
#include <utility>
78
#include <vector>
@@ -33,7 +34,7 @@ namespace cp_algo::math {
3334
}
3435

3536
template<typename Int>
36-
std::vector<gaussint<Int>> two_squares_all(Int n) {
37+
big_vector<gaussint<Int>> two_squares_all(Int n) {
3738
if(n == 0) {
3839
return {0};
3940
}
@@ -42,9 +43,9 @@ namespace cp_algo::math {
4243
for(auto p: primes) {
4344
cnt[p]++;
4445
}
45-
std::vector<gaussint<Int>> res = {1};
46+
big_vector<gaussint<Int>> res = {1};
4647
for(auto [p, c]: cnt) {
47-
std::vector<gaussint<Int>> nres;
48+
big_vector<gaussint<Int>> nres;
4849
if(p % 4 == 3) {
4950
if(c % 2 == 0) {
5051
auto mul = bpow(gaussint<Int>(p), c / 2);
@@ -68,7 +69,7 @@ namespace cp_algo::math {
6869
}
6970
res = nres;
7071
}
71-
std::vector<gaussint<Int>> nres;
72+
big_vector<gaussint<Int>> nres;
7273
for(auto p: res) {
7374
while(p.real() < 0 || p.imag() < 0) {
7475
p *= gaussint<Int>(0, 1);

cp-algo/structures/dsu.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#ifndef CP_ALGO_STRUCTURES_DSU_HPP
22
#define CP_ALGO_STRUCTURES_DSU_HPP
3+
#include "../util/big_alloc.hpp"
34
#include <numeric>
45
#include <vector>
56
namespace cp_algo::structures {
@@ -17,7 +18,7 @@ namespace cp_algo::structures {
1718
return a != b;
1819
}
1920
private:
20-
std::vector<int> par;
21+
big_vector<int> par;
2122
};
2223
using dsu = disjoint_set_union;
2324
}

cp-algo/structures/eertree.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#ifndef CP_ALGO_STRUCTURES_EERTREE_HPP
22
#define CP_ALGO_STRUCTURES_EERTREE_HPP
3+
#include "../util/big_alloc.hpp"
34
#include <forward_list>
45
#include <functional>
56
#include <iostream>
@@ -11,7 +12,7 @@ namespace cp_algo::structures {
1112
eertree(size_t q) {
1213
q += 2;
1314
s = std::string(q, -1);
14-
len = par = link = std::vector(q, 0);
15+
len = par = link = big_vector(q, 0);
1516
to.resize(q);
1617
link[0] = 1;
1718
len[1] = -1;
@@ -62,8 +63,8 @@ namespace cp_algo::structures {
6263
print(std::identity{});
6364
}
6465
private:
65-
std::vector<std::forward_list<int>> to;
66-
std::vector<int> len, link, par;
66+
big_vector<std::forward_list<int>> to;
67+
big_vector<int> len, link, par;
6768
std::string s;
6869
int n = 1, sz = 2, last = 0;
6970
};

cp-algo/structures/fenwick.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#ifndef CP_ALGO_STRUCTURES_FENWICK_HPP
22
#define CP_ALGO_STRUCTURES_FENWICK_HPP
3+
#include "../util/big_alloc.hpp"
34
#include <cassert>
45
#include <vector>
56
namespace cp_algo::structures {
@@ -20,7 +21,7 @@ namespace cp_algo::structures {
2021
}
2122
};
2223

23-
template<typename T, std::ranges::range Container = std::vector<T>, typename Op = std::plus<T>>
24+
template<typename T, std::ranges::range Container = big_vector<T>, typename Op = std::plus<T>>
2425
struct fenwick {
2526
Op op;
2627
size_t n;
@@ -83,7 +84,7 @@ namespace cp_algo::structures {
8384
auto maxer = [](auto const& a, auto const& b) {
8485
return std::max(a, b);
8586
};
86-
template<typename T, std::ranges::range Container = std::vector<T>>
87+
template<typename T, std::ranges::range Container = big_vector<T>>
8788
struct fenwick_max: fenwick<T, Container, decltype(maxer)> {
8889
using fenwick<T, Container, decltype(maxer)>::fenwick;
8990
};

cp-algo/structures/segtree.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
#ifndef CP_ALGO_STRUCTURES_SEGMENT_TREE_HPP
22
#define CP_ALGO_STRUCTURES_SEGMENT_TREE_HPP
3+
#include "../util/big_alloc.hpp"
34
#include <vector>
45
#include <numeric>
56
namespace cp_algo::structures {
67
template<typename meta>
78
struct segtree_t {
89
const size_t N;
9-
std::vector<meta> _meta;
10+
big_vector<meta> _meta;
1011

1112
segtree_t(size_t n): N(n), _meta(4 * N) {}
1213

13-
segtree_t(std::vector<meta> leafs): N(size(leafs)), _meta(4 * N) {
14+
segtree_t(big_vector<meta> leafs): N(size(leafs)), _meta(4 * N) {
1415
build(leafs);
1516
}
1617

cp-algo/structures/treap.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#ifndef CP_ALGO_STRUCTURES_TREAP_HPP
22
#define CP_ALGO_STRUCTURES_TREAP_HPP
3+
#include "../util/big_alloc.hpp"
34
#include "../random/rng.hpp"
45
#include "treap/common.hpp"
56
#include <array>
@@ -108,7 +109,7 @@ namespace cp_algo::structures::treap {
108109
}
109110

110111
static treap build(auto const& nodes) {
111-
std::vector<treap> st;
112+
big_vector<treap> st;
112113
for(auto cur: nodes) {
113114
while(st.size() >= 2 && st[st.size() - 2]->prior > cur->prior) {
114115
st.pop_back();

cp-algo/tree/ascending_dfs.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#ifndef CP_ALGO_TREE_ASCENDING_DFS_HPP
22
#define CP_ALGO_TREE_ASCENDING_DFS_HPP
3-
3+
#include "../util/big_alloc.hpp"
44
#include "../graph/base.hpp"
55
#include <cassert>
66
#include <vector>
@@ -48,7 +48,7 @@ namespace cp_algo::graph {
4848
// DFS that uses a precomputed parent-edge array.
4949
template<undirected_graph_type graph>
5050
void parent_dfs(graph const& tree, auto const& parent, auto &&callback) {
51-
std::vector<int> degree(tree.n());
51+
big_vector<int> degree(tree.n());
5252
node_index root = -1;
5353
for (auto [v, e] : parent | std::views::enumerate) {
5454
if (e != -1) {

cp-algo/tree/diameter.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#ifndef CP_ALGO_TREE_DIAMETER_HPP
22
#define CP_ALGO_TREE_DIAMETER_HPP
33
#include "ascending_dfs.hpp"
4+
#include "../util/big_alloc.hpp"
45
#include "../graph/base.hpp"
56
#include <tuple>
67
#include <string>
78
#include <algorithm>
8-
99
namespace cp_algo::graph {
1010
enum class diameter_mode { recover_path, no_recover };
1111

@@ -15,7 +15,7 @@ namespace cp_algo::graph {
1515
int64_t length = 0;
1616
node_index start = 0;
1717
};
18-
std::vector<up_path> up(g.n());
18+
big_vector<up_path> up(g.n());
1919
for(auto v: g.nodes()) {
2020
up[v].start = v;
2121
}

0 commit comments

Comments
 (0)