Skip to content

Commit 6c9a8c6

Browse files
lrvideckisweb-flow
andauthored
Plus equals basic string (#127)
* change push_back to += for basic strings * switch to clang format version 19 to match arch local version * trying this * trying this now * Revert "switch to clang format version 19 to match arch local version" This reverts commit 3429086. * revert formatting of some files * fix some things * [auto-verifier] verify commit a875b60 * more fixes * suppress another buggy clang tidy warning * more fixes * convert another one to basic string * another one * format * convert another to basic string * another one * another one * another one * another one * another one * trying this * fix compile error in example init comment * another fix * yet another fix * trying thisasdfkljasdfaslkdjf * new version of clang? * [auto-verifier] verify commit eb0878f * switch back ladder decomp * now formatted * fix cppcheck * switch over another place * another place * allow basic string for graph input * switch another place * changed another place * another suppression --------- Co-authored-by: GitHub <noreply@github.com>
1 parent 85c1660 commit 6c9a8c6

File tree

24 files changed

+92
-139
lines changed

24 files changed

+92
-139
lines changed

.verify-helper/timestamps.remote.json

Lines changed: 7 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -50,39 +50,19 @@
5050
"tests/library_checker_aizu_tests/flow/dinic_aizu.test.cpp": "2024-11-17 14:04:03 -0600",
5151
"tests/library_checker_aizu_tests/flow/hungarian.test.cpp": "2024-11-17 14:04:03 -0600",
5252
"tests/library_checker_aizu_tests/flow/min_cost_max_flow.test.cpp": "2024-12-05 10:41:42 -0600",
53-
"tests/library_checker_aizu_tests/graphs/biconnected_components.test.cpp": "2024-12-15 09:01:54 -0600",
53+
"tests/library_checker_aizu_tests/graphs/biconnected_components.test.cpp": "2025-02-10 14:02:17 -0700",
5454
"tests/library_checker_aizu_tests/graphs/connected_components_of_complement_graph.test.cpp": "2024-12-14 19:50:29 -0600",
5555
"tests/library_checker_aizu_tests/graphs/dijkstra_aizu.test.cpp": "2024-12-14 19:50:29 -0600",
5656
"tests/library_checker_aizu_tests/graphs/dijkstra_lib_checker.test.cpp": "2024-12-14 19:50:29 -0600",
57-
"tests/library_checker_aizu_tests/graphs/directed_cycle.test.cpp": "2025-01-15 00:11:15 -0700",
58-
"tests/library_checker_aizu_tests/graphs/enumerate_triangles.test.cpp": "2024-12-14 19:50:29 -0600",
59-
"tests/library_checker_aizu_tests/graphs/hopcroft_karp_aizu.test.cpp": "2024-12-14 19:50:29 -0600",
60-
"tests/library_checker_aizu_tests/graphs/hopcroft_karp_lib_checker.test.cpp": "2024-12-14 19:50:29 -0600",
57+
"tests/library_checker_aizu_tests/graphs/directed_cycle.test.cpp": "2025-02-10 13:50:35 -0700",
58+
"tests/library_checker_aizu_tests/graphs/enumerate_triangles.test.cpp": "2025-02-10 13:47:58 -0700",
59+
"tests/library_checker_aizu_tests/graphs/hopcroft_karp_aizu.test.cpp": "2025-01-24 10:59:16 -0700",
60+
"tests/library_checker_aizu_tests/graphs/hopcroft_karp_lib_checker.test.cpp": "2025-01-24 10:59:16 -0700",
6161
"tests/library_checker_aizu_tests/graphs/mst.test.cpp": "2024-11-17 14:04:03 -0600",
62-
"tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp": "2025-02-10 14:50:36 -0700",
63-
"tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp": "2025-02-10 14:50:36 -0700",
64-
"tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp": "2025-02-10 14:50:36 -0700",
65-
"tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp": "2024-12-15 09:01:54 -0600",
66-
"tests/library_checker_aizu_tests/handmade_tests/count_paths_forest.test.cpp": "2024-12-15 14:34:10 -0600",
67-
"tests/library_checker_aizu_tests/handmade_tests/dsu_size.test.cpp": "2024-12-14 19:50:29 -0600",
68-
"tests/library_checker_aizu_tests/handmade_tests/edge_cd_small_trees.test.cpp": "2024-12-15 17:01:11 -0600",
69-
"tests/library_checker_aizu_tests/handmade_tests/fib_matrix_expo.test.cpp": "2024-12-14 19:50:29 -0600",
70-
"tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp": "2024-12-15 17:01:11 -0600",
71-
"tests/library_checker_aizu_tests/handmade_tests/lca_ladder_forest.test.cpp": "2025-02-10 14:50:36 -0700",
72-
"tests/library_checker_aizu_tests/handmade_tests/manacher.test.cpp": "2024-12-14 19:50:29 -0600",
73-
"tests/library_checker_aizu_tests/handmade_tests/merge_st_and_wavelet.test.cpp": "2024-12-14 19:50:29 -0600",
74-
"tests/library_checker_aizu_tests/handmade_tests/mobius.test.cpp": "2025-02-10 14:50:36 -0700",
7562
"tests/library_checker_aizu_tests/handmade_tests/mod_int.test.cpp": "2024-12-14 19:50:29 -0600",
7663
"tests/library_checker_aizu_tests/handmade_tests/n_choose_k.test.cpp": "2025-01-15 00:22:31 -0700",
77-
"tests/library_checker_aizu_tests/handmade_tests/permutation_tree_small.test.cpp": "2024-12-14 15:47:13 -0600",
64+
"tests/library_checker_aizu_tests/handmade_tests/permutation_tree_small.test.cpp": "2025-02-10 13:41:14 -0700",
7865
"tests/library_checker_aizu_tests/handmade_tests/rmq_small_n.test.cpp": "2024-12-14 19:50:29 -0600",
79-
"tests/library_checker_aizu_tests/handmade_tests/sa_find_subarray.test.cpp": "2025-02-10 14:50:36 -0700",
80-
"tests/library_checker_aizu_tests/handmade_tests/seg_tree_find.test.cpp": "2024-12-14 19:50:29 -0600",
81-
"tests/library_checker_aizu_tests/handmade_tests/seg_tree_find_small.test.cpp": "2024-12-14 19:50:29 -0600",
82-
"tests/library_checker_aizu_tests/loops/chooses.test.cpp": "2025-02-10 14:50:36 -0700",
83-
"tests/library_checker_aizu_tests/loops/quotients.test.cpp": "2024-11-17 14:04:03 -0600",
84-
"tests/library_checker_aizu_tests/loops/submasks.test.cpp": "2025-02-10 14:50:36 -0700",
85-
"tests/library_checker_aizu_tests/loops/supermasks.test.cpp": "2025-02-10 14:50:36 -0700",
8666
"tests/library_checker_aizu_tests/math/binary_exponentiation_mod.test.cpp": "2024-11-17 14:04:03 -0600",
8767
"tests/library_checker_aizu_tests/math/binary_matrix_mult.test.cpp": "2024-11-17 14:04:03 -0600",
8868
"tests/library_checker_aizu_tests/math/count_paths.test.cpp": "2025-01-15 00:22:31 -0700",
@@ -95,32 +75,14 @@
9575
"tests/library_checker_aizu_tests/math/mod_int_tetration.test.cpp": "2024-11-17 14:04:03 -0600",
9676
"tests/library_checker_aizu_tests/math/n_choose_k.test.cpp": "2025-01-15 00:22:31 -0700",
9777
"tests/library_checker_aizu_tests/math/num_subsequences.test.cpp": "2024-11-17 14:04:03 -0600",
98-
"tests/library_checker_aizu_tests/math/partitions.test.cpp": "2025-02-10 14:50:36 -0700",
9978
"tests/library_checker_aizu_tests/math/prime_sieve.test.cpp": "2024-11-22 11:54:52 -0600",
10079
"tests/library_checker_aizu_tests/math/solve_linear_mod.test.cpp": "2024-12-14 15:47:13 -0600",
10180
"tests/library_checker_aizu_tests/math/tetration.test.cpp": "2024-11-17 14:04:03 -0600",
10281
"tests/library_checker_aizu_tests/math/totient.test.cpp": "2024-11-17 14:04:03 -0600",
103-
"tests/library_checker_aizu_tests/math/xor_basis.test.cpp": "2025-02-10 14:50:36 -0700",
104-
"tests/library_checker_aizu_tests/math/xor_basis_intersection.test.cpp": "2025-02-10 14:50:36 -0700",
105-
"tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_binary_tree.test.cpp": "2025-02-10 14:50:36 -0700",
106-
"tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_k_ary_tree.test.cpp": "2025-02-10 14:50:36 -0700",
107-
"tests/library_checker_aizu_tests/monotonic_stack_related/count_rectangles.test.cpp": "2025-02-10 14:50:36 -0700",
108-
"tests/library_checker_aizu_tests/monotonic_stack_related/max_rect_histogram.test.cpp": "2025-02-10 14:50:36 -0700",
109-
"tests/library_checker_aizu_tests/strings/kmp.test.cpp": "2024-12-14 19:50:29 -0600",
110-
"tests/library_checker_aizu_tests/strings/lcp_array.test.cpp": "2025-02-10 14:50:36 -0700",
111-
"tests/library_checker_aizu_tests/strings/lcp_query_palindrome.test.cpp": "2025-02-10 14:50:36 -0700",
112-
"tests/library_checker_aizu_tests/strings/lcp_query_zfunc.test.cpp": "2025-02-10 14:50:36 -0700",
11382
"tests/library_checker_aizu_tests/strings/lcs_dp.test.cpp": "2024-12-05 10:41:42 -0600",
114-
"tests/library_checker_aizu_tests/strings/lcs_queries.test.cpp": "2024-12-14 19:50:29 -0600",
83+
"tests/library_checker_aizu_tests/strings/lcs_queries.test.cpp": "2025-02-10 13:52:44 -0700",
11584
"tests/library_checker_aizu_tests/strings/lcs_queries_merge_sort_tree.test.cpp": "2024-12-05 10:41:42 -0600",
11685
"tests/library_checker_aizu_tests/strings/manacher.test.cpp": "2024-12-14 19:50:29 -0600",
117-
"tests/library_checker_aizu_tests/strings/multi_matching_bs.test.cpp": "2025-02-10 14:50:36 -0700",
118-
"tests/library_checker_aizu_tests/strings/prefix_function.test.cpp": "2025-02-10 14:50:36 -0700",
119-
"tests/library_checker_aizu_tests/strings/sa_cmp.test.cpp": "2025-02-10 14:50:36 -0700",
120-
"tests/library_checker_aizu_tests/strings/sa_sort_pairs.test.cpp": "2025-02-10 14:50:36 -0700",
121-
"tests/library_checker_aizu_tests/strings/single_matching_bs.test.cpp": "2025-02-10 14:50:36 -0700",
122-
"tests/library_checker_aizu_tests/strings/suffix_array.test.cpp": "2025-02-10 14:50:36 -0700",
123-
"tests/library_checker_aizu_tests/strings/suffix_array_short.test.cpp": "2025-02-10 14:50:36 -0700",
12486
"tests/library_checker_aizu_tests/strings/trie.test.cpp": "2024-12-05 10:41:42 -0600",
12587
"tests/library_checker_aizu_tests/strings/wildcard_pattern_matching.test.cpp": "2024-12-14 19:50:29 -0600",
12688
"tests/library_checker_aizu_tests/trees/count_paths_per_length.test.cpp": "2024-12-15 14:34:10 -0600",
@@ -129,9 +91,5 @@
12991
"tests/library_checker_aizu_tests/trees/edge_cd_count_paths_per_length.test.cpp": "2024-12-15 17:01:11 -0600",
13092
"tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp": "2024-12-15 17:01:11 -0600",
13193
"tests/library_checker_aizu_tests/trees/kth_path_ladder.test.cpp": "2024-12-15 14:34:10 -0600",
132-
"tests/library_checker_aizu_tests/trees/kth_path_linear.test.cpp": "2025-02-10 14:50:36 -0700",
133-
"tests/library_checker_aizu_tests/trees/kth_path_tree_lift.test.cpp": "2025-02-10 14:50:36 -0700",
134-
"tests/library_checker_aizu_tests/trees/lca_all_methods_aizu.test.cpp": "2025-02-10 14:50:36 -0700",
135-
"tests/library_checker_aizu_tests/trees/lca_all_methods_lib_checker.test.cpp": "2025-02-10 14:50:36 -0700",
13694
"tests/library_checker_aizu_tests/trees/subtree_isomorphism.test.cpp": "2024-12-15 14:34:10 -0600"
13795
}

library/data_structures/dsu/kruskal_tree.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
struct kr_tree {
66
int id;
77
vi p;
8-
vector<vi> adj;
8+
vector<basic_string<int>> adj;
99
kr_tree(int n): id(n), p(2 * n, -1), adj(2 * n) {}
1010
int find(int v) {
1111
return p[v] < 0 ? v : p[v] = find(p[v]);

library/data_structures/dsu/range_parallel_equivalence_classes.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
//! @time O((n + q) * \alpha(n))
66
//! @space O(n + q)
77
UF get_rp_dsu(const vector<array<int, 3>>& rests, int n) {
8-
vector<vector<array<int, 2>>> rests_by_len(n + 1);
8+
vector<basic_string<array<int, 2>>> rests_by_len(n + 1);
99
for (auto [l1, l2, len] : rests)
10-
rests_by_len[len].push_back({l1, l2});
10+
rests_by_len[len] += {l1, l2};
1111
UF uf(n);
1212
for (int len = n; len > 0; len--)
1313
for (auto [l1, l2] : rests_by_len[len])
1414
if (uf.join(l1, l2))
15-
rests_by_len[len - 1].push_back({l1 + 1, l2 + 1});
15+
rests_by_len[len - 1] += {l1 + 1, l2 + 1};
1616
return uf;
1717
}

library/data_structures/seg_tree_uncommon/merge_sort_tree.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22
#include "../lazy_seg_tree_midpoint.hpp"
33
struct merge_sort_tree {
44
int n;
5-
vector<vi> tree;
5+
vector<basic_string<int>> tree;
66
merge_sort_tree(const vi& a): n(sz(a)), tree(2 * n) {
77
int pw2 = bit_ceil(size(a));
88
rep(i, 0, n) tree[(i + pw2) % n + n] = {a[i]};
99
for (int i = n - 1; i >= 1; i--) {
10-
tree[i].resize(
11-
sz(tree[2 * i]) + sz(tree[2 * i + 1]));
1210
ranges::merge(tree[2 * i], tree[2 * i + 1],
13-
begin(tree[i]));
11+
back_inserter(tree[i]));
1412
}
1513
}
1614
//! count of i in [l, r) such that a[i] in [vl, vr)

library/data_structures/uncommon/mode_query.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const int b = 318; //!< sqrt(1e5)
44
struct mode_query {
55
int n;
66
vi a, cnt, index_into_index;
7-
vector<vi> index;
7+
vector<basic_string<int>> index;
88
vector<vector<pii>>
99
mode_blocks; //!< {mode, cnt} of range of blocks
1010
//! @param a compressed array: 0 <= a[i] < n
@@ -16,7 +16,7 @@ struct mode_query {
1616
vector<pii>((n + b - 1) / b)) {
1717
rep(i, 0, n) {
1818
index_into_index[i] = sz(index[a[i]]);
19-
index[a[i]].push_back(i);
19+
index[a[i]] += i;
2020
}
2121
for (int start = 0; start < n; start += b) {
2222
int mode = a[start];

library/data_structures/uncommon/permutation_tree.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ struct perm_tree {
1717
};
1818
vector<node> p;
1919
int root;
20-
vector<vi> ch;
20+
vector<basic_string<int>> ch;
2121
bool touches(int u, int v) {
2222
return p[u].mn_num == p[v].mn_num + p[v].len ||
2323
p[v].mn_num == p[u].mn_num + p[u].len;
2424
}
2525
int allocate(int mn_i, int mn_v, int ln, bool join,
26-
const vi& chs) {
26+
const basic_string<int>& chs) {
2727
p.push_back({mn_i, mn_v, ln, join});
2828
ch.push_back(chs);
2929
return sz(ch) - 1;
@@ -50,7 +50,7 @@ struct perm_tree {
5050
if (!empty(ch[u]) && touches(ch[u].back(), v)) {
5151
p[u].mn_num = min(p[u].mn_num, p[v].mn_num);
5252
p[u].len += p[v].len;
53-
ch[u].push_back(v);
53+
ch[u] += v;
5454
v = u;
5555
st.pop_back();
5656
continue;
@@ -73,7 +73,7 @@ struct perm_tree {
7373
break;
7474
}
7575
int min_num = p[v].mn_num;
76-
vi chs(1 + sz(st) - idx, v);
76+
basic_string<int> chs(1 + sz(st) - idx, v);
7777
rep(j, idx, sz(st)) min_num =
7878
min(min_num, p[chs[j - idx] = st[j][0]].mn_num);
7979
v = allocate(l, min_num, i - l + 1, 0, chs);

library/graphs/bridges_cuts/block_vertex_tree.hpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
//! {
55
//! vector<vector<pii>> adj(n);
66
//! auto [num_bccs, bcc_id, is_cut] = cuts(adj, m);
7-
//! vector<vi> bvt = block_vertex_tree(adj,
7+
//! auto bvt = block_vertex_tree(adj,
88
//! num_bccs, bcc_id);
99
//! }
1010
//! vector<basic_string<array<int, 2>>> adj(n);
1111
//! auto [num_bccs, bcc_id, is_cut] = cuts(adj, m);
12-
//! vector<vi> bvt = block_vertex_tree(adj,
13-
//! num_bccs, bcc_id);
12+
//! auto bvt = block_vertex_tree(adj, num_bccs, bcc_id);
1413
//!
1514
//! //to loop over each unique bcc containing a node u:
1615
//! for (int bccid : bvt[v]) {
@@ -23,18 +22,18 @@
2322
//! [n, n + num_bccs) are BCC nodes
2423
//! @time O(n + m)
2524
//! @time O(n)
26-
vector<vi> block_vertex_tree(const auto& adj, int num_bccs,
25+
auto block_vertex_tree(const auto& adj, int num_bccs,
2726
const vi& bcc_id) {
2827
int n = sz(adj);
29-
vector<vi> bvt(n + num_bccs);
28+
vector<basic_string<int>> bvt(n + num_bccs);
3029
vector<bool> vis(num_bccs);
3130
rep(i, 0, n) {
3231
for (auto [_, e_id] : adj[i]) {
3332
int bccid = bcc_id[e_id];
3433
if (!vis[bccid]) {
3534
vis[bccid] = 1;
36-
bvt[i].push_back(bccid + n);
37-
bvt[bccid + n].push_back(i);
35+
bvt[i] += bccid + n;
36+
bvt[bccid + n] += i;
3837
}
3938
}
4039
for (int bccid : bvt[i]) vis[bccid - n] = 0;

library/graphs/bridges_cuts/bridge_tree.hpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,18 @@
44
//! {
55
//! vector<vector<pii>> adj(n);
66
//! auto [num_ccs, br_id, is_br] = bridges(adj, m);
7-
//! vector<vi> bt = bridge_tree(adj,
8-
//! num_ccs, br_id, is_br);
7+
//! auto bt = bridge_tree(adj, num_ccs, br_id, is_br);
98
//! }
109
//! vector<basic_string<array<int, 2>>> adj(n);
1110
//! auto [num_ccs, br_id, is_br] = bridges(adj, m);
12-
//! vector<vi> bt = bridge_tree(adj,
13-
//! num_ccs, br_id, is_br);
11+
//! auto bt = bridge_tree(adj, num_ccs, br_id, is_br);
1412
//! @endcode
1513
//! @time O(n + m)
1614
//! @space O(n)
17-
vector<vi> bridge_tree(const auto& adj, int num_ccs,
15+
auto bridge_tree(const auto& adj, int num_ccs,
1816
const vi& br_id, const vi& is_br) {
19-
vector<vi> tree(num_ccs);
17+
vector<basic_string<int>> tree(num_ccs);
2018
rep(i, 0, sz(adj)) for (auto [u, e_id] : adj[i]) if (
21-
is_br[e_id]) tree[br_id[i]]
22-
.push_back(br_id[u]);
19+
is_br[e_id]) tree[br_id[i]] += br_id[u];
2320
return tree;
2421
}

library/graphs/bridges_cuts/bridges.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
//! int u, v;
1111
//! cin >> u >> v;
1212
//! u--, v--;
13-
//! adj[u].push_back({v, i});
14-
//! adj[v].push_back({u, i});
13+
//! adj[u] += {v, i};
14+
//! adj[v] += {u, i};
1515
//! }
1616
//! auto [num_ccs, br_id, is_br] = bridges(adj, m);
1717
//! @endcode

library/graphs/bridges_cuts/cuts.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
//! cin >> u >> v;
1212
//! u--, v--;
1313
//! //self edges not allowed
14-
//! adj[u].push_back({v, i});
15-
//! adj[v].push_back({u, i});
14+
//! adj[u] += {v, i};
15+
//! adj[v] += {u, i};
1616
//! }
1717
//! auto [num_bccs, bcc_id, is_cut] = cuts(adj, m);
1818
//! @endcode

0 commit comments

Comments
 (0)