Skip to content

Commit 2ce1531

Browse files
authored
no basic_string in library anymore after learning s[s.size()] isn't RTE (#149)
* no basic_string in library anymore after learning s[s.size()] isn't RTE * fixes * another fix * another fix * Delete .verify-helper/timestamps.remote.json to rerun all tests
1 parent 8d9023b commit 2ce1531

File tree

17 files changed

+35
-188
lines changed

17 files changed

+35
-188
lines changed

.verify-helper/timestamps.remote.json

Lines changed: 0 additions & 141 deletions
This file was deleted.

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<basic_string<int>> adj;
8+
vector<array<int, 2>> 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<basic_string<array<int, 2>>> rests_by_len(n + 1);
8+
vector<vector<pii>> rests_by_len(n + 1);
99
for (auto [l1, l2, len] : rests)
10-
rests_by_len[len] += {l1, l2};
10+
rests_by_len[len].push_back({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] += {l1 + 1, l2 + 1};
15+
rests_by_len[len - 1].push_back({l1 + 1, l2 + 1});
1616
return uf;
1717
}

library/data_structures/seg_tree_uncommon/merge_sort_tree.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "../lazy_seg_tree_midpoint.hpp"
33
struct merge_sort_tree {
44
int n;
5-
vector<basic_string<int>> tree;
5+
vector<vi> 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]};

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<basic_string<int>> index;
7+
vector<vi> 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]] += i;
19+
index[a[i]].push_back(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<basic_string<int>> ch;
20+
vector<vi> 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 basic_string<int>& chs) {
26+
const vi& 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] += v;
53+
ch[u].push_back(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-
basic_string<int> chs(1 + sz(st) - idx, v);
76+
vi 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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
auto block_vertex_tree(const auto& adj, int num_bccs,
2626
const vi& bcc_id) {
2727
int n = sz(adj);
28-
vector<basic_string<int>> bvt(n + num_bccs);
28+
vector<vi> bvt(n + num_bccs);
2929
vector<bool> vis(num_bccs);
3030
rep(i, 0, n) {
3131
for (auto [_, e_id] : adj[i]) {
3232
int bccid = bcc_id[e_id];
3333
if (!vis[bccid]) {
3434
vis[bccid] = 1;
35-
bvt[i] += bccid + n;
36-
bvt[bccid + n] += i;
35+
bvt[i].push_back(bccid + n);
36+
bvt[bccid + n].push_back(i);
3737
}
3838
}
3939
for (int bccid : bvt[i]) vis[bccid - n] = 0;

library/graphs/bridges_cuts/bridge_tree.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
//! @space O(n)
1515
auto bridge_tree(const auto& adj, int num_ccs,
1616
const vi& br_id, const vi& is_br) {
17-
vector<basic_string<int>> tree(num_ccs);
17+
vector<vi> tree(num_ccs);
1818
rep(i, 0, sz(adj)) for (auto [u, e_id] : adj[i]) if (
19-
is_br[e_id]) tree[br_id[i]] += br_id[u];
19+
is_br[e_id]) tree[br_id[i]]
20+
.push_back(br_id[u]);
2021
return tree;
2122
}

library/graphs/enumerate_triangles.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ void enumerate_triangles(const vector<pii>& edges, int n,
1111
auto f) {
1212
vi deg(n);
1313
for (auto [u, v] : edges) deg[u]++, deg[v]++;
14-
vector<basic_string<int>> adj(n);
14+
vector<vi> adj(n);
1515
for (auto [u, v] : edges) {
1616
if (tie(deg[u], u) > tie(deg[v], v)) swap(u, v);
17-
adj[u] += v;
17+
adj[u].push_back(v);
1818
}
1919
vector<bool> seen(n);
2020
for (auto [u, v] : edges) {

library/graphs/functional_graph_processor.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//! @space O(n)
1414
struct func_graph {
1515
vector<pii> root_of;
16-
vector<basic_string<int>> cycle, childs;
16+
vector<vi> cycle, childs;
1717
func_graph(const vi& a): root_of(sz(a)), childs(sz(a)) {
1818
vi state(sz(a));
1919
rep(i, 0, sz(a)) if (!state[i]) {
@@ -26,15 +26,15 @@ struct func_graph {
2626
cycle.emplace_back();
2727
while (state[u] == 1) {
2828
root_of[u] = {sz(cycle) - 1, sz(cycle.back())};
29-
cycle.back() += u;
29+
cycle.back().push_back(u);
3030
state[u] = 2;
3131
u = a[u];
3232
}
3333
}
3434
int v = i;
3535
while (state[v] == 1) {
3636
root_of[v] = root_of[u];
37-
childs[a[v]] += v;
37+
childs[a[v]].push_back(v);
3838
state[v] = 2;
3939
v = a[v];
4040
}

0 commit comments

Comments
 (0)