From 6dc468998ad6d8a7168ba28b83f08fabff68e3cd Mon Sep 17 00:00:00 2001 From: manoflearning <77jwk0724@gmail.com> Date: Tue, 6 Jan 2026 00:18:13 +0900 Subject: [PATCH] feat: remove aliases (vi, vl, vvi, vvl), macro (pb) --- src/0-common/common.hpp | 5 -- src/1-ds/fenwick_tree.cpp | 16 ++--- src/1-ds/li_chao_tree.cpp | 6 +- src/1-ds/merge_sort_tree.cpp | 12 ++-- src/1-ds/segment_tree.cpp | 50 +++++++-------- src/1-ds/union_find.cpp | 2 +- src/2-graph/bcc.cpp | 22 +++---- src/2-graph/euler_circuit.cpp | 14 ++-- src/2-graph/kth_shortest_path.cpp | 20 +++--- src/2-graph/offline_dynamic_connectivity.cpp | 8 +-- src/2-graph/scc_2_sat.cpp | 36 +++++------ src/2-graph/shortest_path.cpp | 14 ++-- src/3-tree/centroid_decomp.cpp | 10 +-- src/3-tree/hld.cpp | 10 +-- src/3-tree/lca_sparse_table.cpp | 10 +-- src/3-tree/tree_composition.cpp | 22 +++---- src/3-tree/tree_exchange_argument.cpp | 12 ++-- src/4-optimizations/flow.cpp | 38 +++++------ src/4-optimizations/hungarian.cpp | 10 +-- src/5-string/aho_corasick.cpp | 8 +-- src/5-string/kmp_algorithm.cpp | 10 +-- src/5-string/manachers_algorithm.cpp | 4 +- src/5-string/rabin_karp_algorithm.cpp | 8 +-- src/5-string/suffix_array.cpp | 10 +-- src/5-string/trie.cpp | 4 +- src/5-string/z_algorithm.cpp | 4 +- src/6-geometry/bulldozer_trick.cpp | 10 +-- src/6-geometry/convex_hull.cpp | 4 +- src/6-geometry/half_plane_intersection.cpp | 8 +-- src/7-math/comb_binom.cpp | 6 +- src/7-math/comb_cat_der.cpp | 2 +- src/7-math/conv_fft.cpp | 22 +++---- src/7-math/linalg_gauss.cpp | 12 ++-- src/7-math/linalg_mat.cpp | 4 +- src/7-math/misc_sqrt.cpp | 18 +++--- src/7-math/nt_mr_rho.cpp | 8 +-- src/7-math/nt_sieve.cpp | 22 +++---- src/8-misc/dp_opt.cpp | 18 +++--- src/8-misc/kitamasa.cpp | 4 +- src/8-misc/lis_in_o_nlogn.cpp | 22 +++---- .../sqrt_decomposition_mos_algorithm.cpp | 2 +- .../system_of_difference_constraints.cpp | 6 +- tests/1-ds/test_fenwick_tree.cpp | 16 ++--- tests/1-ds/test_li_chao_tree.cpp | 6 +- tests/1-ds/test_merge_sort_tree.cpp | 10 +-- tests/1-ds/test_segment_tree.cpp | 64 +++++++++---------- tests/1-ds/test_union_find.cpp | 4 +- tests/2-graph/test_bcc.cpp | 26 ++++---- tests/2-graph/test_euler_circuit.cpp | 20 +++--- tests/2-graph/test_kth_shortest_path.cpp | 14 ++-- .../test_offline_dynamic_connectivity.cpp | 12 ++-- tests/2-graph/test_scc_2_sat.cpp | 18 +++--- tests/2-graph/test_shortest_path.cpp | 12 ++-- tests/3-tree/test_centroid_decomp.cpp | 44 ++++++------- tests/3-tree/test_hld.cpp | 28 ++++---- tests/3-tree/test_lca_sparse_table.cpp | 12 ++-- tests/3-tree/test_tree_composition.cpp | 38 +++++------ tests/3-tree/test_tree_exchange_argument.cpp | 50 +++++++-------- tests/4-optimizations/test_flow.cpp | 32 +++++----- tests/4-optimizations/test_hungarian.cpp | 10 +-- tests/5-string/test_aho_corasick.cpp | 4 +- tests/5-string/test_kmp_algorithm.cpp | 12 ++-- tests/5-string/test_manachers_algorithm.cpp | 2 +- tests/5-string/test_rabin_karp_algorithm.cpp | 8 +-- tests/5-string/test_suffix_array.cpp | 6 +- tests/5-string/test_trie.cpp | 2 +- tests/5-string/test_z_algorithm.cpp | 6 +- tests/6-geometry/test_bulldozer_trick.cpp | 34 +++++----- tests/6-geometry/test_convex_hull.cpp | 4 +- .../test_half_plane_intersection.cpp | 24 +++---- .../test_minimum_enclosing_circle.cpp | 2 +- tests/6-geometry/test_ray_casting.cpp | 2 +- tests/6-geometry/test_rotating_callipers.cpp | 2 +- tests/6-geometry/test_sort_by_angular.cpp | 2 +- tests/7-math/test_comb_cat_der.cpp | 8 +-- tests/7-math/test_conv_fft.cpp | 22 +++---- tests/7-math/test_linalg_gauss.cpp | 10 +-- tests/7-math/test_linalg_mat.cpp | 4 +- tests/7-math/test_misc_sqrt.cpp | 20 +++--- tests/7-math/test_nt_crt.cpp | 2 +- tests/7-math/test_nt_mr_rho.cpp | 16 ++--- tests/7-math/test_nt_sieve.cpp | 8 +-- tests/8-misc/test_dp_opt.cpp | 20 +++--- tests/8-misc/test_kitamasa.cpp | 8 +-- tests/8-misc/test_lis_in_o_nlogn.cpp | 12 ++-- tests/8-misc/test_simd.cpp | 2 +- .../test_sqrt_decomposition_mos_algorithm.cpp | 8 +-- .../test_system_of_difference_constraints.cpp | 6 +- 88 files changed, 600 insertions(+), 605 deletions(-) diff --git a/src/0-common/common.hpp b/src/0-common/common.hpp index 4f27a97..cf8a8bc 100644 --- a/src/0-common/common.hpp +++ b/src/0-common/common.hpp @@ -6,12 +6,7 @@ using ll = long long; using ld = long double; using pii = pair; using pll = pair; -using vi = vector; -using vl = vector; -using vvi = vector>; -using vvl = vector>; #define fr first #define sc second -#define pb push_back #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() diff --git a/src/1-ds/fenwick_tree.cpp b/src/1-ds/fenwick_tree.cpp index 0dd3f3c..6fd791e 100644 --- a/src/1-ds/fenwick_tree.cpp +++ b/src/1-ds/fenwick_tree.cpp @@ -6,14 +6,14 @@ // usage: fenwick fw; fw.build(a); fw.add(p, x); fw.sum(l, r); fw.kth(k); struct fenwick { int n; - vl a, t; + vector a, t; void init(int n_) { // goal: allocate arrays for size n. n = n_; a.assign(n, 0); t.assign(n, 0); } - void build(const vl &v) { + void build(const vector &v) { // goal: build fenwick in O(n) from initial array. n = sz(v); a = v; @@ -60,7 +60,7 @@ struct fenwick { // usage: fenw_range fw; fw.init(n); fw.add(l, r, x); ll v = fw.get(p); struct fenw_range { // 1-indexed int n; - vl t; + vector t; void init(int n_) { // goal: allocate internal tree (1-indexed). n = n_; @@ -85,19 +85,19 @@ struct fenw_range { // 1-indexed // usage: fenw_2d fw; fw.build(a); fw.add(x, y, v); fw.sum(x1, y1, x2, y2); struct fenw_2d { // 0-indexed int n, m; - vvl a, t; + vector> a, t; void init(int n_, int m_) { // goal: allocate arrays for n x m. n = n_, m = m_; - a.assign(n, vl(m, 0)); - t.assign(n, vl(m, 0)); + a.assign(n, vector(m, 0)); + t.assign(n, vector(m, 0)); } - void build(const vvl &v) { + void build(const vector> &v) { // goal: build 2D fenwick in O(n*m). n = sz(v); m = n ? sz(v[0]) : 0; a = v; - t.assign(n, vl(m, 0)); + t.assign(n, vector(m, 0)); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { t[i][j] += a[i][j]; diff --git a/src/1-ds/li_chao_tree.cpp b/src/1-ds/li_chao_tree.cpp index 3e3ffce..8758bf7 100644 --- a/src/1-ds/li_chao_tree.cpp +++ b/src/1-ds/li_chao_tree.cpp @@ -22,7 +22,7 @@ struct li_chao { void init(ll xl, ll xr) { // goal: set x-range and clear tree. t.clear(); - t.pb({xl, xr, -1, -1, LINE_E}); + t.push_back({xl, xr, -1, -1, LINE_E}); } void add(lc_line nw, int v = 0) { // goal: insert a new line into the segment. @@ -40,14 +40,14 @@ struct li_chao { t[v].ln = hi; if (t[v].r == -1) { t[v].r = sz(t); - t.pb({mid + 1, xr, -1, -1, LINE_E}); + t.push_back({mid + 1, xr, -1, -1, LINE_E}); } add(lo, t[v].r); } else { t[v].ln = lo; if (t[v].l == -1) { t[v].l = sz(t); - t.pb({xl, mid, -1, -1, LINE_E}); + t.push_back({xl, mid, -1, -1, LINE_E}); } add(hi, t[v].l); } diff --git a/src/1-ds/merge_sort_tree.cpp b/src/1-ds/merge_sort_tree.cpp index e3f3f61..8ece15c 100644 --- a/src/1-ds/merge_sort_tree.cpp +++ b/src/1-ds/merge_sort_tree.cpp @@ -6,11 +6,11 @@ constexpr int MAX_MST = 1 << 17; // constraint: MAX_MST >= n; values fit in int; 0-indexed [l, r]; build once. // usage: merge_seg st; st.build(a); st.query(l, r, k); struct merge_seg { - vi t[MAX_MST << 1]; - void build(const vi &a) { + vector t[MAX_MST << 1]; + void build(const vector &a) { // goal: build sorted lists for each node. for (int i = 0; i < sz(a); i++) - t[i + MAX_MST].pb(a[i]); + t[i + MAX_MST].push_back(a[i]); for (int i = MAX_MST - 1; i >= 1; i--) { t[i].resize(sz(t[i << 1]) + sz(t[i << 1 | 1])); merge(all(t[i << 1]), all(t[i << 1 | 1]), t[i].begin()); @@ -31,11 +31,11 @@ struct merge_seg { // constraint: MAX_MST >= n; values fit in int; 0-indexed [l, r]; build once. // usage: merge_seg_it st; st.build(a); st.query(l, r, k); struct merge_seg_it { - vi t[MAX_MST << 1]; - void build(const vi &a) { + vector t[MAX_MST << 1]; + void build(const vector &a) { // goal: build sorted lists for each node. for (int i = 0; i < sz(a); i++) - t[i + MAX_MST].pb(a[i]); + t[i + MAX_MST].push_back(a[i]); for (int i = MAX_MST - 1; i >= 1; i--) { t[i].resize(sz(t[i << 1]) + sz(t[i << 1 | 1])); merge(all(t[i << 1]), all(t[i << 1 | 1]), t[i].begin()); diff --git a/src/1-ds/segment_tree.cpp b/src/1-ds/segment_tree.cpp index 760e9fc..07b1a64 100644 --- a/src/1-ds/segment_tree.cpp +++ b/src/1-ds/segment_tree.cpp @@ -6,8 +6,8 @@ // usage: seg_tree st; st.build(a); st.set(p, v); st.query(l, r); struct seg_tree { int flag; - vl t; - void build(const vl &a) { + vector t; + void build(const vector &a) { // goal: build tree from 1-indexed array. int n = sz(a) - 1; flag = 1; @@ -36,8 +36,8 @@ struct seg_tree { // usage: seg_tree_it st; st.build(a); st.set(p, v); st.query(l, r); struct seg_tree_it { // 0-indexed int n; - vl t; - void build(const vl &a) { + vector t; + void build(const vector &a) { // goal: build tree from 0-indexed array. n = sz(a); t.assign(2 * n, 0); @@ -65,7 +65,7 @@ struct seg_tree_it { // 0-indexed // usage: seg_tree_kth st; st.init(n); st.add(p, v); st.kth(k); struct seg_tree_kth { int flag; - vl t; + vector t; void init(int n) { // goal: allocate tree for size n. flag = 1; @@ -91,8 +91,8 @@ struct seg_tree_kth { // usage: seg_tree_lz st; st.build(a); st.add(l, r, v); st.query(l, r); struct seg_tree_lz { int flag; - vl t, lz; - void build(const vl &a) { + vector t, lz; + void build(const vector &a) { // goal: build tree and clear lazy tags. int n = sz(a) - 1; flag = 1; @@ -149,19 +149,19 @@ struct seg_pst { }; int n; vector t; - vi root; + vector root; - void newnd() { t.pb({-1, -1, 0}); } - void build(int n_, const vl &a) { + void newnd() { t.push_back({-1, -1, 0}); } + void build(int n_, const vector &a) { // goal: build initial version. n = n_; t.clear(); root.clear(); newnd(); - root.pb(0); + root.push_back(0); build(1, n, root[0], a); } - void build(int l, int r, int v, const vl &a) { + void build(int l, int r, int v, const vector &a) { // goal: build node v for range [l, r]. if (l == r) { t[v].val = a[l]; @@ -179,7 +179,7 @@ struct seg_pst { void set(int p, ll val) { // goal: create new version with a[p] = val. newnd(); - root.pb(sz(t) - 1); + root.push_back(sz(t) - 1); set(p, val, 1, n, root[sz(root) - 2], root.back()); } void set(int p, ll val, int l, int r, int v1, int v2) { @@ -246,13 +246,13 @@ struct seg_sparse { if (p <= mid) { if (t[v].l == -1) { t[v].l = sz(t); - t.pb({0, -1, -1}); + t.push_back({0, -1, -1}); } add(p, x, t[v].l, nl, mid); } else { if (t[v].r == -1) { t[v].r = sz(t); - t.pb({0, -1, -1}); + t.push_back({0, -1, -1}); } add(p, x, t[v].r, mid + 1, nr); } @@ -275,11 +275,11 @@ struct seg_sparse { // usage: seg_2d st; st.build(a); st.set(x, y, v); st.query(x1, x2, y1, y2); struct seg_2d { // 0-indexed int n; - vvl t; - void build(const vvl &a) { + vector> t; + void build(const vector> &a) { // goal: build 2D tree from initial grid. n = sz(a); - t.assign(2 * n, vl(2 * n, 0)); + t.assign(2 * n, vector(2 * n, 0)); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) t[i + n][j + n] = a[i][j]; @@ -325,24 +325,24 @@ struct seg_2d { // 0-indexed // usage: seg2d_comp st(n); st.mark_set(x, y); st.mark_qry(x1, x2, y1, y2); st.prep(); st.set(x, y, v); st.query(x1, x2, y1, y2); struct seg2d_comp { // 0-indexed int n; - vvl a; - vvi used; + vector> a; + vector> used; unordered_map mp; seg2d_comp(int n) : n(n), a(2 * n), used(2 * n) {} void mark_set(int x, int y) { // goal: record y-coordinates that will be updated. - for (x += n; x >= 1; x >>= 1) used[x].pb(y); + for (x += n; x >= 1; x >>= 1) used[x].push_back(y); } void mark_qry(int x1, int x2, int y1, int y2) { // goal: record y-coordinates needed for queries. for (x1 += n, x2 += n + 1; x1 < x2; x1 >>= 1, x2 >>= 1) { if (x1 & 1) { - used[x1].pb(y1); - used[x1++].pb(y2); + used[x1].push_back(y1); + used[x1++].push_back(y2); } if (x2 & 1) { - used[--x2].pb(y1); - used[x2].pb(y2); + used[--x2].push_back(y1); + used[x2].push_back(y2); } } } diff --git a/src/1-ds/union_find.cpp b/src/1-ds/union_find.cpp index aca213c..04b3262 100644 --- a/src/1-ds/union_find.cpp +++ b/src/1-ds/union_find.cpp @@ -5,7 +5,7 @@ // constraint: 1-indexed [1, n]. // usage: dsu d; d.init(n); d.join(a, b); int r = d.find(x); int s = d.size(x); struct dsu { - vi p; + vector p; void init(int n) { p.assign(n + 1, -1); } // goal: reset to n singletons. int find(int x) { return p[x] < 0 ? x : p[x] = find(p[x]); } // result: root of x. int size(int x) { return -p[find(x)]; } diff --git a/src/2-graph/bcc.cpp b/src/2-graph/bcc.cpp index 376ea63..663325f 100644 --- a/src/2-graph/bcc.cpp +++ b/src/2-graph/bcc.cpp @@ -7,7 +7,7 @@ struct bcc_graph { int n, tim; vector> adj; - vi dfn, low, ap, st; + vector dfn, low, ap, st; vector ed, ae; vector> bccs; @@ -25,9 +25,9 @@ struct bcc_graph { } void add(int u, int v) { int id = sz(ed); - ed.pb({u, v}); - adj[u].pb({v, id}); - adj[v].pb({u, id}); + ed.push_back({u, v}); + adj[u].push_back({v, id}); + adj[v].push_back({u, id}); } void dfs(int v, int pe) { dfn[v] = low[v] = ++tim; @@ -37,27 +37,27 @@ struct bcc_graph { if (dfn[to] != -1) { // edge: back edge to ancestor. low[v] = min(low[v], dfn[to]); - if (dfn[to] < dfn[v]) st.pb(id); + if (dfn[to] < dfn[v]) st.push_back(id); continue; } - st.pb(id); + st.push_back(id); ch++; dfs(to, id); low[v] = min(low[v], low[to]); - if (pe != -1 && low[to] >= dfn[v]) ap.pb(v); - if (low[to] > dfn[v]) ae.pb({min(v, to), max(v, to)}); + if (pe != -1 && low[to] >= dfn[v]) ap.push_back(v); + if (low[to] > dfn[v]) ae.push_back({min(v, to), max(v, to)}); if (low[to] >= dfn[v]) { vector comp; while (1) { int eid = st.back(); st.pop_back(); - comp.pb(ed[eid]); + comp.push_back(ed[eid]); if (eid == id) break; } - bccs.pb(comp); + bccs.push_back(comp); } } - if (pe == -1 && ch > 1) ap.pb(v); + if (pe == -1 && ch > 1) ap.push_back(v); } void run() { for (int v = 1; v <= n; v++) diff --git a/src/2-graph/euler_circuit.cpp b/src/2-graph/euler_circuit.cpp index 9f67492..f1d944a 100644 --- a/src/2-graph/euler_circuit.cpp +++ b/src/2-graph/euler_circuit.cpp @@ -6,13 +6,13 @@ // usage: euler_cir g; g.init(n); g.add(u,v); if (g.can()) auto path=g.run(1); struct euler_cir { int n; - vvi adj; - vi nxt, path; + vector> adj; + vector nxt, path; void init(int n_) { // goal: allocate adjacency matrix and reset state. n = n_; - adj.assign(n + 1, vi(n + 1)); + adj.assign(n + 1, vector(n + 1)); nxt.assign(n + 1, 1); path.clear(); } @@ -23,7 +23,7 @@ struct euler_cir { } bool can() { // result: whether an Euler circuit exists. - vi deg(n + 1); + vector deg(n + 1); for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) deg[i] += adj[i][j]; for (int i = 1; i <= n; i++) @@ -35,7 +35,7 @@ struct euler_cir { break; } if (!s) return 1; - vi vis(n + 1); + vector vis(n + 1); queue q; q.push(s); vis[s] = 1; @@ -58,9 +58,9 @@ struct euler_cir { dfs(i); } } - path.pb(v); + path.push_back(v); } - vi run(int s = 1) { + vector run(int s = 1) { // result: Euler circuit starting from s (if exists). for (int i = 1; i <= n; i++) nxt[i] = 1; path.clear(); diff --git a/src/2-graph/kth_shortest_path.cpp b/src/2-graph/kth_shortest_path.cpp index 69bc605..6738fbb 100644 --- a/src/2-graph/kth_shortest_path.cpp +++ b/src/2-graph/kth_shortest_path.cpp @@ -19,7 +19,7 @@ struct kth_walk { vector h; void init() { h.assign(1, {{0, 0}, 0, 0, 0}); } int mk(pll x) { - h.pb({x, 0, 0, 1}); + h.push_back({x, 0, 0, 1}); return sz(h) - 1; } void norm(int x) { @@ -43,13 +43,13 @@ struct kth_walk { hp.init(); } void add(int u, int v, ll w) { - g[u].pb({w, v}); - rg[v].pb({w, u}); + g[u].push_back({w, v}); + rg[v].push_back({w, u}); } - vl run(int s, int e, int k) { - vi nxt(n + 1, -1), ord, vis(n + 1); - vl dist(n + 1, INF); + vector run(int s, int e, int k) { + vector nxt(n + 1, -1), ord, vis(n + 1); + vector dist(n + 1, INF); // goal: shortest path tree from e on reversed graph. dist[e] = 0; @@ -62,7 +62,7 @@ struct kth_walk { if (vis[x]) continue; vis[x] = 1; nxt[x] = p; - ord.pb(x); + ord.push_back(x); for (auto [c, y] : rg[x]) { if (!vis[y] && dist[y] > d + c) { dist[y] = d + c; @@ -72,7 +72,7 @@ struct kth_walk { } if (dist[s] >= INF) return {}; - vi rt(n + 1), chk(n + 1); + vector rt(n + 1), chk(n + 1); for (int x : ord) if (dist[x] < INF) { if (nxt[x] != -1) rt[x] = rt[nxt[x]]; @@ -86,13 +86,13 @@ struct kth_walk { } } - vl ans = {dist[s]}; + vector ans = {dist[s]}; priority_queue, greater> pq2; if (rt[s]) pq2.push({hp.h[rt[s]].x.fr, rt[s]}); while (sz(ans) < k && !pq2.empty()) { auto [d, x] = pq2.top(); pq2.pop(); - ans.pb(dist[s] + d); + ans.push_back(dist[s] + d); int y = hp.h[x].x.sc; if (rt[y]) pq2.push({d + hp.h[rt[y]].x.fr, rt[y]}); if (hp.h[x].l) pq2.push({d - hp.h[x].x.fr + hp.h[hp.h[x].l].x.fr, hp.h[x].l}); diff --git a/src/2-graph/offline_dynamic_connectivity.cpp b/src/2-graph/offline_dynamic_connectivity.cpp index 75a7270..de75300 100644 --- a/src/2-graph/offline_dynamic_connectivity.cpp +++ b/src/2-graph/offline_dynamic_connectivity.cpp @@ -18,7 +18,7 @@ struct dyn_conn { if (nr == -1) nr = flg; if (r < nl || nr < l) return; if (l <= nl && nr <= r) { - t[n].pb(e); + t[n].push_back(e); return; } int mid = (nl + nr) >> 1; @@ -28,7 +28,7 @@ struct dyn_conn { } sg; struct dsu { - vi par, siz, st; + vector par, siz, st; void init(int n) { // goal: reset to n isolated nodes. par.resize(n + 1); @@ -48,7 +48,7 @@ struct dyn_conn { if (siz[a] < siz[b]) swap(a, b); par[b] = a; siz[a] += siz[b]; - st.pb(b); + st.push_back(b); return 1; } void undo() { @@ -64,7 +64,7 @@ struct dyn_conn { int n, q; map mp; vector qry; - vi ans; + vector ans; void init(int n_, int q_) { // goal: initialize with n nodes and q operations. diff --git a/src/2-graph/scc_2_sat.cpp b/src/2-graph/scc_2_sat.cpp index fa036e4..c46e977 100644 --- a/src/2-graph/scc_2_sat.cpp +++ b/src/2-graph/scc_2_sat.cpp @@ -6,8 +6,8 @@ // usage: scc_kosa s; s.init(n); s.add(u,v); int c=s.run(); struct scc_kosa { int n; - vvi g, rg, sccs; - vi vis, comp, ord; + vector> g, rg, sccs; + vector vis, comp, ord; void init(int n_) { n = n_; @@ -19,18 +19,18 @@ struct scc_kosa { ord.clear(); } void add(int u, int v) { - g[u].pb(v); - rg[v].pb(u); + g[u].push_back(v); + rg[v].push_back(u); } void dfs1(int v) { vis[v] = 1; for (int to : rg[v]) if (!vis[to]) dfs1(to); - ord.pb(v); + ord.push_back(v); } void dfs2(int v, int id) { comp[v] = id; - sccs[id].pb(v); + sccs[id].push_back(v); for (int to : g[v]) if (comp[to] == -1) dfs2(to, id); } @@ -40,7 +40,7 @@ struct scc_kosa { reverse(all(ord)); for (int v : ord) { if (comp[v] != -1) continue; - sccs.pb({}); + sccs.push_back({}); dfs2(v, sz(sccs) - 1); } return sz(sccs); @@ -53,8 +53,8 @@ struct scc_kosa { // usage: scc_tarjan s; s.init(n); s.add(u,v); int c=s.run(); struct scc_tarjan { int n, tim; - vvi g, sccs; - vi dfn, low, comp, st, ins; + vector> g, sccs; + vector dfn, low, comp, st, ins; void init(int n_) { n = n_; @@ -67,10 +67,10 @@ struct scc_tarjan { ins.assign(n + 1, 0); st.clear(); } - void add(int u, int v) { g[u].pb(v); } + void add(int u, int v) { g[u].push_back(v); } void dfs(int v) { dfn[v] = low[v] = ++tim; - st.pb(v); + st.push_back(v); ins[v] = 1; for (int to : g[v]) { if (dfn[to] == -1) { @@ -81,14 +81,14 @@ struct scc_tarjan { } } if (low[v] != dfn[v]) return; - sccs.pb({}); + sccs.push_back({}); int id = sz(sccs) - 1; while (1) { int x = st.back(); st.pop_back(); ins[x] = 0; comp[x] = id; - sccs[id].pb(x); + sccs[id].push_back(x); if (x == v) break; } } @@ -105,8 +105,8 @@ struct scc_tarjan { // usage: two_sat s; s.init(n); s.add(a,b); bool ok=s.run(); // s.val struct two_sat { int n, tim, cid; - vvi g; - vi dfn, low, comp, st, ins, val; + vector> g; + vector dfn, low, comp, st, ins, val; void init(int n_) { n = n_; @@ -126,12 +126,12 @@ struct two_sat { } void add(int a, int b) { // goal: (a v b) == (!a -> b) & (!b -> a) - g[id(-a)].pb(id(b)); - g[id(-b)].pb(id(a)); + g[id(-a)].push_back(id(b)); + g[id(-b)].push_back(id(a)); } void dfs(int v) { dfn[v] = low[v] = ++tim; - st.pb(v); + st.push_back(v); ins[v] = 1; for (int to : g[v]) { if (dfn[to] == -1) { diff --git a/src/2-graph/shortest_path.cpp b/src/2-graph/shortest_path.cpp index 918118a..a68946d 100644 --- a/src/2-graph/shortest_path.cpp +++ b/src/2-graph/shortest_path.cpp @@ -14,10 +14,10 @@ struct dijkstra { n = n_; adj.assign(n + 1, {}); } - void add(int u, int v, ll w) { adj[u].pb({w, v}); } - vl run(int s) { + void add(int u, int v, ll w) { adj[u].push_back({w, v}); } + vector run(int s) { // result: dist[i] = shortest distance from s to i. - vl dist(n + 1, INF); + vector dist(n + 1, INF); priority_queue, greater> pq; dist[s] = 0; pq.push({0, s}); @@ -50,8 +50,8 @@ struct bell_ford { n = n_; ed.clear(); } - void add(int u, int v, ll w) { ed.pb({u, v, w}); } - bool run(int s, vl &dist) { + void add(int u, int v, ll w) { ed.push_back({u, v, w}); } + bool run(int s, vector &dist) { // result: false if a negative cycle is reachable. dist.assign(n + 1, INF); dist[s] = 0; @@ -78,12 +78,12 @@ struct bell_ford { struct floyd { static const ll INF = (1LL << 62); int n; - vvl d; + vector> d; void init(int n_) { // goal: initialize distance matrix. n = n_; - d.assign(n + 1, vl(n + 1, INF)); + d.assign(n + 1, vector(n + 1, INF)); for (int i = 1; i <= n; i++) d[i][i] = 0; } void add(int u, int v, ll w) { d[u][v] = min(d[u][v], w); } diff --git a/src/3-tree/centroid_decomp.cpp b/src/3-tree/centroid_decomp.cpp index a773275..62e6da9 100644 --- a/src/3-tree/centroid_decomp.cpp +++ b/src/3-tree/centroid_decomp.cpp @@ -6,8 +6,8 @@ // usage: cen_decomp cd; cd.init(n); cd.add(u,v); cd.build(); int p=cd.par[v]; struct cen_decomp { int n; - vvi adj, chd; - vi par, siz; + vector> adj, chd; + vector par, siz; vector used; void init(int n_) { @@ -19,8 +19,8 @@ struct cen_decomp { used.assign(n + 1, 0); } void add(int u, int v) { - adj[u].pb(v); - adj[v].pb(u); + adj[u].push_back(v); + adj[v].push_back(u); } int get_sz(int v, int p) { // goal: subtree sizes for centroid search. @@ -43,7 +43,7 @@ struct cen_decomp { int tot = get_sz(v, p); int c = get_cent(v, p, tot); par[c] = p; - if (p) chd[p].pb(c); + if (p) chd[p].push_back(c); used[c] = 1; for (int to : adj[c]) if (!used[to]) build(to, c); diff --git a/src/3-tree/hld.cpp b/src/3-tree/hld.cpp index fdb16b5..035d48a 100644 --- a/src/3-tree/hld.cpp +++ b/src/3-tree/hld.cpp @@ -8,8 +8,8 @@ struct hld_tree { seg_tree seg; int n, tim; - vvi adj; - vi par, dep, siz, heavy, top, in; + vector> adj; + vector par, dep, siz, heavy, top, in; void init(int n_) { n = n_; @@ -23,8 +23,8 @@ struct hld_tree { in.assign(n + 1, 0); } void add(int u, int v) { - adj[u].pb(v); - adj[v].pb(u); + adj[u].push_back(v); + adj[v].push_back(u); } int dfs_sz(int v, int p) { // goal: compute subtree sizes and heavy child. @@ -51,7 +51,7 @@ struct hld_tree { void build(int root = 1) { dfs_sz(root, 0); dfs_hld(root, root); - vl a(n + 1, 0); + vector a(n + 1, 0); seg.build(a); } void set(int v, ll val) { seg.set(in[v], val); } diff --git a/src/3-tree/lca_sparse_table.cpp b/src/3-tree/lca_sparse_table.cpp index eb73f14..394ae24 100644 --- a/src/3-tree/lca_sparse_table.cpp +++ b/src/3-tree/lca_sparse_table.cpp @@ -6,20 +6,20 @@ // usage: lca_sparse l; l.init(n); l.add(u,v); l.build(1); int w=l.lca(u,v); struct lca_sparse { int n, lg; - vvi adj, up; - vi dep; + vector> adj, up; + vector dep; void init(int n_) { n = n_; lg = 1; while ((1 << lg) <= n) lg++; adj.assign(n + 1, {}); - up.assign(lg, vi(n + 1, 0)); + up.assign(lg, vector(n + 1, 0)); dep.assign(n + 1, 0); } void add(int u, int v) { - adj[u].pb(v); - adj[v].pb(u); + adj[u].push_back(v); + adj[v].push_back(u); } void dfs(int v, int p) { // goal: set parent and depth. diff --git a/src/3-tree/tree_composition.cpp b/src/3-tree/tree_composition.cpp index a252db8..4affd1f 100644 --- a/src/3-tree/tree_composition.cpp +++ b/src/3-tree/tree_composition.cpp @@ -6,15 +6,15 @@ // usage: tree_comp tc; tc.init(n); tc.add(u,v); tc.build(root); auto nodes=tc.make(vs); // use tc.vt_adj struct tree_comp { int n, lg, tim; - vvi adj, up, vt_adj; - vi tin, tout, dep; + vector> adj, up, vt_adj; + vector tin, tout, dep; void init(int n_) { n = n_; lg = 1; while ((1 << lg) <= n) lg++; adj.assign(n + 1, {}); - up.assign(lg, vi(n + 1, 0)); + up.assign(lg, vector(n + 1, 0)); vt_adj.assign(n + 1, {}); tin.assign(n + 1, 0); tout.assign(n + 1, 0); @@ -22,8 +22,8 @@ struct tree_comp { tim = 0; } void add(int u, int v) { - adj[u].pb(v); - adj[v].pb(u); + adj[u].push_back(v); + adj[v].push_back(u); } void dfs(int v, int p) { // goal: build tin/tout, depth, and parents. @@ -57,23 +57,23 @@ struct tree_comp { } return up[0][a]; } - vi make(vi vs) { + vector make(vector vs) { if (vs.empty()) return {}; sort(all(vs), [&](int a, int b) { return tin[a] < tin[b]; }); vs.erase(unique(all(vs)), vs.end()); int m = sz(vs); - for (int i = 0; i + 1 < m; i++) vs.pb(lca(vs[i], vs[i + 1])); + for (int i = 0; i + 1 < m; i++) vs.push_back(lca(vs[i], vs[i + 1])); sort(all(vs), [&](int a, int b) { return tin[a] < tin[b]; }); vs.erase(unique(all(vs)), vs.end()); for (int v : vs) vt_adj[v].clear(); - vi st; - st.pb(vs[0]); + vector st; + st.push_back(vs[0]); for (int i = 1; i < sz(vs); i++) { int v = vs[i]; // invariant: stack is ancestor chain. while (!is_anc(st.back(), v)) st.pop_back(); - vt_adj[st.back()].pb(v); - st.pb(v); + vt_adj[st.back()].push_back(v); + st.push_back(v); } return vs; } diff --git a/src/3-tree/tree_exchange_argument.cpp b/src/3-tree/tree_exchange_argument.cpp index dd673a9..6e9ecf8 100644 --- a/src/3-tree/tree_exchange_argument.cpp +++ b/src/3-tree/tree_exchange_argument.cpp @@ -6,8 +6,8 @@ // usage: tree_xchg tx; tx.init(n, root); tx.add(u,v); // set tx.ds.w/t/cw; ll ans=tx.run(); struct tree_xchg { struct uf { - vi par; - vl cw, w, t; + vector par; + vector cw, w, t; void init(int n) { par.assign(n + 1, -1); cw.resize(n + 1); @@ -32,8 +32,8 @@ struct tree_xchg { }; int n, root; - vvi adj; - vi par; + vector> adj; + vector par; void init(int n_, int r) { n = n_; @@ -43,8 +43,8 @@ struct tree_xchg { ds.init(n); } void add(int u, int v) { - adj[u].pb(v); - adj[v].pb(u); + adj[u].push_back(v); + adj[v].push_back(u); } void dfs(int v, int p) { par[v] = p; diff --git a/src/4-optimizations/flow.cpp b/src/4-optimizations/flow.cpp index 781ee85..c0ce5ac 100644 --- a/src/4-optimizations/flow.cpp +++ b/src/4-optimizations/flow.cpp @@ -23,7 +23,7 @@ struct dinic { int n; vector> g; - vi level, work; + vector level, work; dinic(int n = 0) { init(n); } void init(int n_) { @@ -34,8 +34,8 @@ struct dinic { // goal: add forward + reverse edge edge a{v, sz(g[v]), cap}; edge b{u, sz(g[u]), 0}; - g[u].pb(a); - g[v].pb(b); + g[u].push_back(a); + g[v].push_back(b); return {u, sz(g[u]) - 1}; } ll edge_flow(edge_ref e) const { @@ -104,8 +104,8 @@ struct dinic { // usage: hk bm(n_l, n_r); bm.add_edge(l, r); int m = bm.max_matching(); struct hk { int n_l, n_r; - vvi g; - vi dist, match_l, match_r; + vector> g; + vector dist, match_l, match_r; hk(int n_l_ = 0, int n_r_ = 0) { init(n_l_, n_r_); } void init(int n_l_, int n_r_) { @@ -118,7 +118,7 @@ struct hk { } void add_edge(int l, int r) { // goal: add edge from left to right - g[l].pb(r); + g[l].push_back(r); } bool bfs() { @@ -202,8 +202,8 @@ struct mcmf { // goal: add forward + reverse edge with costs edge a{v, sz(g[v]), cap, cost}; edge b{u, sz(g[u]), 0, -cost}; - g[u].pb(a); - g[v].pb(b); + g[u].push_back(a); + g[v].push_back(b); return {u, sz(g[u]) - 1}; } ll edge_flow(edge_ref e) const { @@ -221,12 +221,12 @@ struct mcmf { pll min_cost_mf(int s, int t, ll max_f = INF, bool init_pot = true) { ll flow = 0, cost = 0; - vl pot(n, 0), dist(n); - vi pv(n), pe(n); + vector pot(n, 0), dist(n); + vector pv(n), pe(n); if (init_pot) { // goal: initial potentials for negative costs - vl d(n, INF); + vector d(n, INF); vector in_q(n, 0); queue q; d[s] = 0; @@ -309,7 +309,7 @@ struct lr_dinic { int n; dinic mf; - vl demand; + vector demand; vector edges; lr_dinic(int n = 0) { init(n); } @@ -323,7 +323,7 @@ struct lr_dinic { // goal: store lower bounds via node demands demand[u] -= lo; demand[v] += lo; - edges.pb({mf.add_edge(u, v, hi - lo), lo}); + edges.push_back({mf.add_edge(u, v, hi - lo), lo}); return sz(edges) - 1; } ll edge_flow(int id) const { @@ -336,10 +336,10 @@ struct lr_dinic { int ss = n, tt = n + 1; for (int i = 0; i < n; i++) { if (demand[i] > 0) { - aux.pb(mf.add_edge(ss, i, demand[i])); + aux.push_back(mf.add_edge(ss, i, demand[i])); total += demand[i]; } else if (demand[i] < 0) { - aux.pb(mf.add_edge(i, tt, -demand[i])); + aux.push_back(mf.add_edge(i, tt, -demand[i])); } } return total; @@ -390,7 +390,7 @@ struct lr_mcmf { int n; mcmf mf; - vl demand; + vector demand; vector edges; ll base_cost; @@ -407,7 +407,7 @@ struct lr_mcmf { demand[u] -= lo; demand[v] += lo; base_cost += lo * cost; - edges.pb({mf.add_edge(u, v, hi - lo, cost), lo}); + edges.push_back({mf.add_edge(u, v, hi - lo, cost), lo}); return sz(edges) - 1; } ll edge_flow(int id) const { @@ -420,10 +420,10 @@ struct lr_mcmf { int ss = n, tt = n + 1; for (int i = 0; i < n; i++) { if (demand[i] > 0) { - aux.pb(mf.add_edge(ss, i, demand[i], 0)); + aux.push_back(mf.add_edge(ss, i, demand[i], 0)); total += demand[i]; } else if (demand[i] < 0) { - aux.pb(mf.add_edge(i, tt, -demand[i], 0)); + aux.push_back(mf.add_edge(i, tt, -demand[i], 0)); } } return total; diff --git a/src/4-optimizations/hungarian.cpp b/src/4-optimizations/hungarian.cpp index fa438ca..aebcf24 100644 --- a/src/4-optimizations/hungarian.cpp +++ b/src/4-optimizations/hungarian.cpp @@ -5,15 +5,15 @@ // constraint: 1 <= n <= m, 1-indexed cost a[1..n][1..m] (minimization). // usage: hungarian hu; auto [cost, match_l] = hu.run(n, m, a); // match_l[i]=j struct hungarian { - pair run(int n, int m, const vvl &a) { + pair> run(int n, int m, const vector> &a) { // result: {min_cost, match_l} with match_l[i]=assigned column. const ll INF = (1LL << 62); - vl u(n + 1), v(m + 1); - vi p(m + 1), way(m + 1); + vector u(n + 1), v(m + 1); + vector p(m + 1), way(m + 1); for (int i = 1; i <= n; i++) { p[0] = i; int j0 = 0; - vl minv(m + 1, INF); + vector minv(m + 1, INF); vector used(m + 1, 0); do { used[j0] = 1; @@ -41,7 +41,7 @@ struct hungarian { j0 = j1; } while (j0); } - vi match_l(n + 1, 0); + vector match_l(n + 1, 0); for (int j = 1; j <= m; j++) if (p[j]) match_l[p[j]] = j; return {-v[0], match_l}; diff --git a/src/5-string/aho_corasick.cpp b/src/5-string/aho_corasick.cpp index c90a738..2cf6ffa 100644 --- a/src/5-string/aho_corasick.cpp +++ b/src/5-string/aho_corasick.cpp @@ -7,7 +7,7 @@ struct aho_corasick { static constexpr int ALPHA = 26; vector> nxt; - vi fail, out; + vector fail, out; aho_corasick() { init(); } void init() { @@ -24,10 +24,10 @@ struct aho_corasick { int c = ch - 'a'; if (nxt[v][c] == -1) { nxt[v][c] = sz(nxt); - nxt.pb({}); + nxt.push_back({}); nxt.back().fill(-1); - fail.pb(0); - out.pb(0); + fail.push_back(0); + out.push_back(0); } v = nxt[v][c]; } diff --git a/src/5-string/kmp_algorithm.cpp b/src/5-string/kmp_algorithm.cpp index 876fb25..5f30011 100644 --- a/src/5-string/kmp_algorithm.cpp +++ b/src/5-string/kmp_algorithm.cpp @@ -4,9 +4,9 @@ // time: O(|t|+|p|); memory: O(|p|) // constraint: returns 0-indexed match positions. // usage: auto pos = kmp_match(t, p); // p in t -vi kmp_pi(const string &p) { +vector kmp_pi(const string &p) { // result: pi[i] = length of longest proper prefix ending at i. - vi pi(sz(p)); + vector pi(sz(p)); for (int i = 1, j = 0; i < sz(p); i++) { while (j && p[i] != p[j]) j = pi[j - 1]; if (p[i] == p[j]) pi[i] = ++j; @@ -14,16 +14,16 @@ vi kmp_pi(const string &p) { return pi; } -vi kmp_match(const string &t, const string &p) { +vector kmp_match(const string &t, const string &p) { // result: all start indices where p matches t. - vi res; + vector res; if (p.empty()) return res; auto pi = kmp_pi(p); for (int i = 0, j = 0; i < sz(t); i++) { while (j && t[i] != p[j]) j = pi[j - 1]; if (t[i] != p[j]) continue; if (j == sz(p) - 1) { - res.pb(i - (sz(p) - 1)); + res.push_back(i - (sz(p) - 1)); j = pi[j]; } else { j++; diff --git a/src/5-string/manachers_algorithm.cpp b/src/5-string/manachers_algorithm.cpp index c8e1a9b..ecee641 100644 --- a/src/5-string/manachers_algorithm.cpp +++ b/src/5-string/manachers_algorithm.cpp @@ -4,10 +4,10 @@ // time: O(n); memory: O(n) // constraint: 0-indexed; d1[i]=odd radius, d2[i]=even radius. // usage: auto [d1,d2]=manacher(s); // max len = max(2*d1[i]-1,2*d2[i]) -pair manacher(const string &s) { +pair, vector> manacher(const string &s) { // result: d1/d2 radii for odd/even palindromes centered at i. int n = sz(s); - vi d1(n), d2(n); + vector d1(n), d2(n); for (int i = 0, l = 0, r = -1; i < n; i++) { int k = (i > r) ? 1 : min(d1[l + r - i], r - i + 1); while (i - k >= 0 && i + k < n && s[i - k] == s[i + k]) k++; diff --git a/src/5-string/rabin_karp_algorithm.cpp b/src/5-string/rabin_karp_algorithm.cpp index 4e94dcf..b6d7818 100644 --- a/src/5-string/rabin_karp_algorithm.cpp +++ b/src/5-string/rabin_karp_algorithm.cpp @@ -8,7 +8,7 @@ struct rabin_karp { static constexpr ll MOD1 = 1000000007; static constexpr ll MOD2 = 1000000009; static constexpr ll BASE = 911382323; - vl p1, p2, h1, h2; + vector p1, p2, h1, h2; void build(const string &s) { // goal: precompute prefix hashes and powers. @@ -35,9 +35,9 @@ struct rabin_karp { } }; -vi rk_match(const string &t, const string &p) { +vector rk_match(const string &t, const string &p) { // result: all positions where p matches t (by hash). - vi res; + vector res; int n = sz(t), m = sz(p); if (!m || n < m) return res; rabin_karp ht, hp; @@ -45,6 +45,6 @@ vi rk_match(const string &t, const string &p) { hp.build(p); pll hp0 = hp.get(0, m); for (int i = 0; i + m <= n; i++) - if (ht.get(i, i + m) == hp0) res.pb(i); + if (ht.get(i, i + m) == hp0) res.push_back(i); return res; } diff --git a/src/5-string/suffix_array.cpp b/src/5-string/suffix_array.cpp index 5852516..6c34915 100644 --- a/src/5-string/suffix_array.cpp +++ b/src/5-string/suffix_array.cpp @@ -4,12 +4,12 @@ // time: build_sa O(n log n), build_lcp O(n); memory: O(n) // constraint: s is 0-indexed string, sa is 0-indexed positions. // usage: suffix_array sa; sa.build(s); // sa.sa, sa.lcp (lcp[i]=lcp(sa[i], sa[i-1])) -vi build_sa(const string &s) { +vector build_sa(const string &s) { // result: sa[i] = starting index of i-th suffix in sorted order. int n = sz(s); if (!n) return {}; int m = max(256, n) + 1; - vi sa(n), r(2 * n), nr(2 * n), cnt(m), idx(n); + vector sa(n), r(2 * n), nr(2 * n), cnt(m), idx(n); for (int i = 0; i < n; i++) sa[i] = i, r[i] = (unsigned char)s[i]; for (int d = 1; d < n; d <<= 1) { auto cmp = [&](int i, int j) { @@ -32,10 +32,10 @@ vi build_sa(const string &s) { return sa; } -vi build_lcp(const string &s, const vi &sa) { +vector build_lcp(const string &s, const vector &sa) { // result: lcp[i] = LCP of sa[i] and sa[i-1]. int n = sz(s); - vi lcp(n), rk(n); + vector lcp(n), rk(n); for (int i = 0; i < n; i++) rk[sa[i]] = i; for (int i = 0, k = 0; i < n; i++) { int r = rk[i]; @@ -49,7 +49,7 @@ vi build_lcp(const string &s, const vi &sa) { } struct suffix_array { - vi sa, lcp; + vector sa, lcp; void build(const string &s) { // goal: fill sa and lcp for string s. sa = build_sa(s); diff --git a/src/5-string/trie.cpp b/src/5-string/trie.cpp index a274f21..ca50e51 100644 --- a/src/5-string/trie.cpp +++ b/src/5-string/trie.cpp @@ -23,9 +23,9 @@ struct trie { int c = ch - 'a'; if (nxt[v][c] == -1) { nxt[v][c] = sz(nxt); - nxt.pb({}); + nxt.push_back({}); nxt.back().fill(-1); - term.pb(0); + term.push_back(0); } v = nxt[v][c]; } diff --git a/src/5-string/z_algorithm.cpp b/src/5-string/z_algorithm.cpp index 0eb8cd6..53d69aa 100644 --- a/src/5-string/z_algorithm.cpp +++ b/src/5-string/z_algorithm.cpp @@ -4,10 +4,10 @@ // time: O(n); memory: O(n) // constraint: z[0]=n, 0-indexed string. // usage: auto z = z_func(s); -vi z_func(const string &s) { +vector z_func(const string &s) { // result: z[i] = longest prefix length matching s[i..]. int n = sz(s); - vi z(n); + vector z(n); if (!n) return z; z[0] = n; for (int i = 1, l = 0, r = 0; i < n; i++) { diff --git a/src/6-geometry/bulldozer_trick.cpp b/src/6-geometry/bulldozer_trick.cpp index 8f5c335..373f8d1 100644 --- a/src/6-geometry/bulldozer_trick.cpp +++ b/src/6-geometry/bulldozer_trick.cpp @@ -22,7 +22,7 @@ void bulldozer(vector &p, F f) { int n = sz(p); sort(all(p)); vector base = p; - vi pos(n); + vector pos(n); iota(all(pos), 0); vector ln; ln.reserve(1LL * n * (n - 1) / 2); @@ -35,7 +35,7 @@ void bulldozer(vector &p, F f) { dx = -dx, dy = -dy; swap(u, v); } - ln.pb({u, v, dx, dy}); + ln.push_back({u, v, dx, dy}); } } sort(all(ln)); @@ -44,13 +44,13 @@ void bulldozer(vector &p, F f) { while (j < sz(ln) && ln[j] == ln[i]) j++; ll dx = ln[i].dx, dy = ln[i].dy; if (dx == 0) break; - unordered_map mp; + unordered_map> mp; mp.reserve((j - i) * 2 + 1); for (int k = i; k < j; k++) { int u = ln[k].u, v = ln[k].v; ll c = -dy * base[u].x + dx * base[u].y; - mp[c].pb(u); - mp[c].pb(v); + mp[c].push_back(u); + mp[c].push_back(v); } for (auto &it : mp) { auto &vec = it.sc; diff --git a/src/6-geometry/convex_hull.cpp b/src/6-geometry/convex_hull.cpp index 60c6cad..c925465 100644 --- a/src/6-geometry/convex_hull.cpp +++ b/src/6-geometry/convex_hull.cpp @@ -13,12 +13,12 @@ vector convex_hull(vector p) { vector lo, hi; for (auto &v : p) { while (sz(lo) >= 2 && cross(lo[sz(lo) - 2], lo.back(), v) <= 0) lo.pop_back(); - lo.pb(v); + lo.push_back(v); } for (int i = n - 1; i >= 0; i--) { auto v = p[i]; while (sz(hi) >= 2 && cross(hi[sz(hi) - 2], hi.back(), v) <= 0) hi.pop_back(); - hi.pb(v); + hi.push_back(v); } lo.pop_back(); hi.pop_back(); diff --git a/src/6-geometry/half_plane_intersection.cpp b/src/6-geometry/half_plane_intersection.cpp index a134d7a..8c339f4 100644 --- a/src/6-geometry/half_plane_intersection.cpp +++ b/src/6-geometry/half_plane_intersection.cpp @@ -42,12 +42,12 @@ vector hpi(vector ln) { vector v; for (auto &l : ln) { if (v.empty()) { - v.pb(l); + v.push_back(l); continue; } ptd da = dir(v.back()), db = dir(l); if (!eq(cross(da, db), 0)) { - v.pb(l); + v.push_back(l); continue; } if (cross(da, l.s - v.back().s) > 0) v.back() = l; @@ -56,7 +56,7 @@ vector hpi(vector ln) { for (auto &l : v) { while (sz(dq) >= 2 && bad(dq[sz(dq) - 2], dq.back(), l)) dq.pop_back(); while (sz(dq) >= 2 && bad(dq[0], dq[1], l)) dq.pop_front(); - dq.pb(l); + dq.push_back(l); } while (sz(dq) >= 3 && bad(dq[sz(dq) - 2], dq.back(), dq[0])) dq.pop_back(); while (sz(dq) >= 3 && bad(dq[0], dq[1], dq.back())) dq.pop_front(); @@ -66,7 +66,7 @@ vector hpi(vector ln) { ptd p; if (line_inter(dq[i].s, dq[i].t, dq[(i + 1) % sz(dq)].s, dq[(i + 1) % sz(dq)].t, p)) { - poly.pb(p); + poly.push_back(p); } } } diff --git a/src/7-math/comb_binom.cpp b/src/7-math/comb_binom.cpp index 4044de6..90926ff 100644 --- a/src/7-math/comb_binom.cpp +++ b/src/7-math/comb_binom.cpp @@ -23,12 +23,12 @@ struct comb_lr { // usage: comb_dp cb; cb.init(n); ll v=cb.ncr(n,r); struct comb_dp { int n; - vvl dp; + vector> dp; void init(int n_) { // goal: build dp up to n. n = n_; - dp.assign(n + 1, vl(n + 1, 0)); + dp.assign(n + 1, vector(n + 1, 0)); for (int i = 0; i <= n; i++) { dp[i][0] = dp[i][i] = 1; for (int j = 1; j < i; j++) dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j]; @@ -47,7 +47,7 @@ struct comb_dp { struct comb_mod { int n; ll mod; - vl fac, ifac; + vector fac, ifac; void init(int n_, ll mod_) { // goal: precompute fac/ifac up to n. diff --git a/src/7-math/comb_cat_der.cpp b/src/7-math/comb_cat_der.cpp index ae93d11..a45715b 100644 --- a/src/7-math/comb_cat_der.cpp +++ b/src/7-math/comb_cat_der.cpp @@ -27,7 +27,7 @@ struct catalan_mod { // usage: derange_mod de; de.init(n, mod); ll v=de.get(k); struct derange_mod { ll mod; - vl dp; + vector dp; void init(int n, ll mod_) { // goal: precompute derangements up to n. diff --git a/src/7-math/conv_fft.cpp b/src/7-math/conv_fft.cpp index f8fdefd..53209b0 100644 --- a/src/7-math/conv_fft.cpp +++ b/src/7-math/conv_fft.cpp @@ -35,7 +35,7 @@ struct fft_conv { for (int i = 0; i < n; i++) a[i] /= n; } - static vl mul(const vl &a, const vl &b) { + static vector mul(const vector &a, const vector &b) { // result: integer convolution of a and b. if (a.empty() || b.empty()) return {}; int n = 1; @@ -47,12 +47,12 @@ struct fft_conv { fft(fb); for (int i = 0; i < n; i++) fa[i] *= fb[i]; fft(fa, 1); - vl ret(n); + vector ret(n); for (int i = 0; i < n; i++) ret[i] = llround(fa[i].real()); return ret; } - static vl mul_mod(const vl &a, const vl &b, ll mod) { + static vector mul_mod(const vector &a, const vector &b, ll mod) { // result: convolution of a and b modulo mod. if (a.empty() || b.empty()) return {}; int n = 1; @@ -73,7 +73,7 @@ struct fft_conv { } fft(r1, 1); fft(r2, 1); - vl ret(n); + vector ret(n); for (int i = 0; i < n; i++) { ll av = llround(r1[i].real()) % mod; ll bv = (llround(r1[i].imag()) + llround(r2[i].real())) % mod; @@ -110,16 +110,16 @@ struct ntt_mod { return ans; } - static void ntt(vl &a) { + static void ntt(vector &a) { // goal: inplace NTT of a. int n = sz(a), lg = 31 - __builtin_clz(n); - static vl rt(2, 1); + static vector rt(2, 1); for (static int k = 2, s = 2; k < n; k <<= 1, s++) { rt.resize(n); ll z[] = {1, mod_pow(ROOT, MOD >> s)}; for (int i = k; i < 2 * k; i++) rt[i] = rt[i / 2] * z[i & 1] % MOD; } - vl rev(n); + vector rev(n); for (int i = 0; i < n; i++) rev[i] = (rev[i / 2] | (i & 1) << lg) / 2; for (int i = 0; i < n; i++) if (i < rev[i]) swap(a[i], a[rev[i]]); @@ -133,14 +133,14 @@ struct ntt_mod { } } - static vl mul(const vl &a, const vl &b) { + static vector mul(const vector &a, const vector &b) { // result: convolution under MOD. if (a.empty() || b.empty()) return {}; int s = sz(a) + sz(b) - 1; int n = 1; while (n < s) n <<= 1; int inv = mod_pow(n, MOD - 2); - vl l(n, 0), r(n, 0), out(n); + vector l(n, 0), r(n, 0), out(n); for (int i = 0; i < sz(a); i++) l[i] = norm(a[i]); for (int i = 0; i < sz(b); i++) r[i] = norm(b[i]); ntt(l); @@ -167,7 +167,7 @@ struct ntt_any { static constexpr ll M2 = 469762049; static constexpr ll M3 = 1224736769; - static vl mul(const vl &a, const vl &b, ll mod) { + static vector mul(const vector &a, const vector &b, ll mod) { // result: convolution under arbitrary mod via CRT. if (a.empty() || b.empty()) return {}; using ntt1 = ntt_mod; @@ -183,7 +183,7 @@ struct ntt_any { const ll INV_M1M2_M3 = euclid::inv_mod(M1M2 % M3, M3); int n = sz(c1); - vl ret(n); + vector ret(n); for (int i = 0; i < n; i++) { ll x1 = c1[i]; ll x2 = c2[i] - x1; diff --git a/src/7-math/linalg_gauss.cpp b/src/7-math/linalg_gauss.cpp index 16375bd..d8a1485 100644 --- a/src/7-math/linalg_gauss.cpp +++ b/src/7-math/linalg_gauss.cpp @@ -46,10 +46,10 @@ struct gauss_real { // constraint: mod is prime; matrix is n x (m+1) augmented. // usage: auto x=gauss_mod::solve(a, mod); // empty if no solution struct gauss_mod { - static vi solve(vvi a, int mod) { + static vector solve(vector> a, int mod) { int n = sz(a); int m = sz(a[0]) - 1; - vi where(m, -1); + vector where(m, -1); int r = 0; for (int c = 0; c < m && r < n; c++) { int p = r; @@ -83,7 +83,7 @@ struct gauss_mod { } if (all0 && a[i][m]) return {}; } - vi ans(m, 0); + vector ans(m, 0); for (int i = 0; i < m; i++) if (where[i] != -1) ans[i] = a[where[i]][m]; return ans; @@ -95,9 +95,9 @@ struct gauss_mod { // constraint: each row is size >= m+1; last bit is RHS. // usage: auto x=gauss_xor::solve(a, m); // empty if no solution struct gauss_xor { - static vi solve(vector> a, int m) { + static vector solve(vector> a, int m) { int n = sz(a); - vi where(m, -1); + vector where(m, -1); int r = 0; for (int c = 0; c < m && r < n; c++) { int p = -1; @@ -122,7 +122,7 @@ struct gauss_xor { } if (all0 && a[i][m]) return {}; } - vi ans(m, 0); + vector ans(m, 0); for (int i = 0; i < m; i++) if (where[i] != -1) ans[i] = a[where[i]][m]; return ans; diff --git a/src/7-math/linalg_mat.cpp b/src/7-math/linalg_mat.cpp index c136edc..8df3808 100644 --- a/src/7-math/linalg_mat.cpp +++ b/src/7-math/linalg_mat.cpp @@ -7,9 +7,9 @@ // usage: matrix a(n,n,mod); auto r=matrix::power(a, e); struct matrix { ll mod; - vvl a; + vector> a; - matrix(int n = 0, int m = 0, ll mod_ = 1) : mod(mod_), a(n, vl(m, 0)) {} + matrix(int n = 0, int m = 0, ll mod_ = 1) : mod(mod_), a(n, vector(m, 0)) {} static matrix ident(int n, ll mod) { matrix r(n, n, mod); for (int i = 0; i < n; i++) r.a[i][i] = 1 % mod; diff --git a/src/7-math/misc_sqrt.cpp b/src/7-math/misc_sqrt.cpp index 1a7c7de..c90c6cb 100644 --- a/src/7-math/misc_sqrt.cpp +++ b/src/7-math/misc_sqrt.cpp @@ -6,32 +6,32 @@ // constraint: x >= 1 and fits in ll. // usage: auto d=sqrt_alg::divisors(x); auto pf=sqrt_alg::prime_fac(x); struct sqrt_alg { - static vl divisors(ll x) { + static vector divisors(ll x) { // result: sorted divisors of x. - vl d; + vector d; for (ll i = 1; i <= x / i; i++) { if (x % i) continue; - d.pb(i); - if (i * i != x) d.pb(x / i); + d.push_back(i); + if (i * i != x) d.push_back(x / i); } sort(all(d)); return d; } - static vl prime_fac(ll x) { + static vector prime_fac(ll x) { // result: prime factors of x (with repetition). - vl p; + vector p; while ((x & 1) == 0) { - p.pb(2); + p.push_back(2); x >>= 1; } for (ll i = 3; i <= x / i; i += 2) { while (x % i == 0) { - p.pb(i); + p.push_back(i); x /= i; } } - if (x > 1) p.pb(x); + if (x > 1) p.push_back(x); return p; } }; diff --git a/src/7-math/nt_mr_rho.cpp b/src/7-math/nt_mr_rho.cpp index f4f7eb0..bdf6271 100644 --- a/src/7-math/nt_mr_rho.cpp +++ b/src/7-math/nt_mr_rho.cpp @@ -57,19 +57,19 @@ struct pollard_rho { if (d != n) return d; } } - static void rec(ll n, vl &out) { + static void rec(ll n, vector &out) { if (n == 1) return; if (miller_rabin::is_prime(n)) { - out.pb(n); + out.push_back(n); return; } ll d = rho(n); rec(d, out); rec(n / d, out); } - static vl factor(ll n) { + static vector factor(ll n) { // result: prime factors of |n| with repetition, sorted. - vl out; + vector out; if (n < 0) n = -n; if (n == 0) return out; rec(n, out); diff --git a/src/7-math/nt_sieve.cpp b/src/7-math/nt_sieve.cpp index 3883342..1c4ebfe 100644 --- a/src/7-math/nt_sieve.cpp +++ b/src/7-math/nt_sieve.cpp @@ -8,7 +8,7 @@ struct era_sieve { int n; vector isp; - vi primes; + vector primes; era_sieve(int n_ = 0) { if (n_ >= 0) init(n_); @@ -25,9 +25,9 @@ struct era_sieve { for (ll j = i * i; j <= n; j += i << 1) isp[j] = 0; } primes.clear(); - if (n >= 2) primes.pb(2); + if (n >= 2) primes.push_back(2); for (int i = 3; i <= n; i += 2) - if (isp[i]) primes.pb(i); + if (isp[i]) primes.push_back(i); } bool is_prime(int x) const { return x >= 2 && x <= n && isp[x]; } }; @@ -38,7 +38,7 @@ struct era_sieve { // usage: lin_sieve sv(n); auto fc=sv.factor_cnt(x); int mu=sv.mu[x]; struct lin_sieve { int n; - vi lp, primes, mu, phi; + vector lp, primes, mu, phi; lin_sieve(int n_ = 0) { if (n_ >= 0) init(n_); @@ -54,7 +54,7 @@ struct lin_sieve { for (int i = 2; i <= n; i++) { if (!lp[i]) { lp[i] = i; - primes.pb(i); + primes.push_back(i); mu[i] = -1; phi[i] = i - 1; } @@ -73,12 +73,12 @@ struct lin_sieve { } } bool is_prime(int x) const { return x >= 2 && x <= n && lp[x] == x; } - vi factor(int x) const { + vector factor(int x) const { // result: prime factors of x (with repetition), in nondecreasing order - vi ret; + vector ret; while (x > 1) { int p = lp[x]; - ret.pb(p); + ret.push_back(p); x /= p; } return ret; @@ -90,7 +90,7 @@ struct lin_sieve { int p = lp[x]; int e = 0; while (x % p == 0) x /= p, e++; - ret.pb({p, e}); + ret.push_back({p, e}); } return ret; } @@ -100,7 +100,7 @@ struct lin_sieve { // time: O(n); memory: O(n) // constraint: n >= 0. // usage: auto mu = mobius(n); if(mu[x]) ... -inline vi mobius(int n) { +inline vector mobius(int n) { lin_sieve sv(n); return sv.mu; } @@ -122,7 +122,7 @@ struct euler_phi { if (x > 1) ret = ret / x * (x - 1); return ret; } - static vi phi_upto(int n) { + static vector phi_upto(int n) { lin_sieve sv(n); return sv.phi; } diff --git a/src/8-misc/dp_opt.cpp b/src/8-misc/dp_opt.cpp index 96d02b4..bf2422d 100644 --- a/src/8-misc/dp_opt.cpp +++ b/src/8-misc/dp_opt.cpp @@ -34,7 +34,7 @@ struct cht_mono { st.pop_back(); } if (st.empty()) cur.x = NEG_INF; - st.pb(cur); + st.push_back(cur); } ll get(ll x) const { // invariant: st is sorted by x; pick last with x_i <= x @@ -57,15 +57,15 @@ struct cht_mono { struct knuth_opt { static constexpr ll INF = (1LL << 62); int n; - vvl dp; - vvi opt; + vector> dp; + vector> opt; template void build(int n_, F cost) { // goal: fill dp/opt for 0..n-1 n = n_; - dp.assign(n, vl(n, 0)); - opt.assign(n, vi(n, 0)); + dp.assign(n, vector(n, 0)); + opt.assign(n, vector(n, 0)); for (int i = 0; i < n; i++) opt[i][i] = i; for (int len = 2; len <= n; len++) { for (int i = 0; i + len - 1 < n; i++) { @@ -94,10 +94,10 @@ struct knuth_opt { // usage: dnc_opt dc; dc.run(k, n, base, cost); auto ans = dc.dp(); struct dnc_opt { static constexpr ll INF = (1LL << 62); - vl prv, cur; + vector prv, cur; template - void run(int k, int n, const vl &base, F cost) { + void run(int k, int n, const vector &base, F cost) { // goal: compute dp for k layers, starting from base prv = base; cur.assign(n, INF); @@ -107,7 +107,7 @@ struct dnc_opt { prv.swap(cur); } } - const vl &dp() const { return prv; } + const vector &dp() const { return prv; } template void solve(int l, int r, int opt_l, int opt_r, F cost) { @@ -131,7 +131,7 @@ struct dnc_opt { // time: O(n log n); memory: O(n) // constraint: values fit in ll. // usage: ll ops = slope_trick(a); -ll slope_trick(vl a) { +ll slope_trick(vector a) { ll ret = 0; priority_queue pq; for (int i = 0; i < sz(a); i++) { diff --git a/src/8-misc/kitamasa.cpp b/src/8-misc/kitamasa.cpp index edc5a77..b488bad 100644 --- a/src/8-misc/kitamasa.cpp +++ b/src/8-misc/kitamasa.cpp @@ -4,7 +4,7 @@ // time: O(k^2 log n); memory: O(k^2) // constraint: coef.size() == init.size(); mod >= 1. // usage: coef[i] for A_{n-1-i}; ll an = kitamasa(coef, init, n, mod); -using poly = vl; +using poly = vector; ll mod_norm(ll x, ll mod) { x %= mod; @@ -36,7 +36,7 @@ poly poly_div(const poly &a, const poly &f, ll mod) { return ret; } -ll kitamasa(const vl &coef, const vl &init, ll n, ll mod) { +ll kitamasa(const vector &coef, const vector &init, ll n, ll mod) { int k = sz(coef); assert(k == sz(init)); if (n < k) return mod_norm(init[n], mod); diff --git a/src/8-misc/lis_in_o_nlogn.cpp b/src/8-misc/lis_in_o_nlogn.cpp index 84ad0a6..ddf3aba 100644 --- a/src/8-misc/lis_in_o_nlogn.cpp +++ b/src/8-misc/lis_in_o_nlogn.cpp @@ -5,39 +5,39 @@ // constraint: use lower_bound for strict; use upper_bound for non-decreasing. // usage: int len = lis_len(a); auto seq = lis_seq(a); -int lis_len(const vl &a) { +int lis_len(const vector &a) { // result: length of LIS. - vl tail; + vector tail; for (ll x : a) { auto it = lower_bound(all(tail), x); - if (it == tail.end()) tail.pb(x); + if (it == tail.end()) tail.push_back(x); else *it = x; } return sz(tail); } -vl lis_seq(const vl &a) { +vector lis_seq(const vector &a) { // result: one LIS sequence. int n = sz(a); - vl tail; - vi tail_idx; - vi pre(n, -1); + vector tail; + vector tail_idx; + vector pre(n, -1); for (int i = 0; i < n; i++) { ll x = a[i]; int pos = lower_bound(all(tail), x) - tail.begin(); if (pos == sz(tail)) { - tail.pb(x); - tail_idx.pb(i); + tail.push_back(x); + tail_idx.push_back(i); } else { tail[pos] = x; tail_idx[pos] = i; } if (pos > 0) pre[i] = tail_idx[pos - 1]; } - vl ret; + vector ret; int cur = tail_idx.empty() ? -1 : tail_idx.back(); while (cur != -1) { - ret.pb(a[cur]); + ret.push_back(a[cur]); cur = pre[cur]; } reverse(all(ret)); diff --git a/src/8-misc/sqrt_decomposition_mos_algorithm.cpp b/src/8-misc/sqrt_decomposition_mos_algorithm.cpp index a97a932..6ee630d 100644 --- a/src/8-misc/sqrt_decomposition_mos_algorithm.cpp +++ b/src/8-misc/sqrt_decomposition_mos_algorithm.cpp @@ -19,7 +19,7 @@ struct mo { bs = max(1, (int)sqrt(n)); q.clear(); } - void add_query(int l, int r, int idx) { q.pb({l, r, idx}); } + void add_query(int l, int r, int idx) { q.push_back({l, r, idx}); } template void run(Add add, Del del, Out out) { // goal: process queries in Mo order with callbacks. diff --git a/src/8-misc/system_of_difference_constraints.cpp b/src/8-misc/system_of_difference_constraints.cpp index 6aa7d0a..7600cd0 100644 --- a/src/8-misc/system_of_difference_constraints.cpp +++ b/src/8-misc/system_of_difference_constraints.cpp @@ -12,7 +12,7 @@ struct diff_cons { int n; vector> g; - vl dist; + vector dist; diff_cons(int n_ = 0) { init(n_); } void init(int n_) { @@ -22,7 +22,7 @@ struct diff_cons { } void add_le(int u, int v, ll w) { // goal: x_v - x_u <= w - g[u].pb({v, w}); + g[u].push_back({v, w}); } void add_ge(int u, int v, ll w) { // goal: x_v - x_u >= w <=> x_u - x_v <= -w @@ -56,5 +56,5 @@ struct diff_cons { } return true; } - vl val() const { return dist; } + vector val() const { return dist; } }; diff --git a/tests/1-ds/test_fenwick_tree.cpp b/tests/1-ds/test_fenwick_tree.cpp index 02e5c8e..afec125 100644 --- a/tests/1-ds/test_fenwick_tree.cpp +++ b/tests/1-ds/test_fenwick_tree.cpp @@ -11,13 +11,13 @@ ll rnd(ll l, ll r) { return dis(rng); } -ll sum_1d(const vl &a, int l, int r) { +ll sum_1d(const vector &a, int l, int r) { ll ret = 0; for (int i = l; i <= r; i++) ret += a[i]; return ret; } -int kth_naive(const vl &a, ll k) { +int kth_naive(const vector &a, ll k) { ll cur = 0; for (int i = 0; i < sz(a); i++) { cur += a[i]; @@ -26,7 +26,7 @@ int kth_naive(const vl &a, ll k) { return -1; } -ll sum_2d(const vvl &a, int x1, int y1, int x2, int y2) { +ll sum_2d(const vector> &a, int x1, int y1, int x2, int y2) { ll ret = 0; for (int i = x1; i <= x2; i++) for (int j = y1; j <= y2; j++) ret += a[i][j]; @@ -35,7 +35,7 @@ ll sum_2d(const vvl &a, int x1, int y1, int x2, int y2) { void test_fenwick_basic() { fenwick fw; - vl a = {5}; + vector a = {5}; fw.build(a); assert(fw.sum(0, 0) == 5); assert(fw.kth(1) == 0); @@ -47,7 +47,7 @@ void test_fenwick_basic() { void test_fenwick_random() { int n = 50; - vl a(n); + vector a(n); for (int i = 0; i < n; i++) a[i] = rnd(0, 5); fenwick fw; @@ -88,7 +88,7 @@ void test_fenwick_rp_basic() { void test_fenwick_rp_random() { int n = 40; - vl a(n + 1, 0); + vector a(n + 1, 0); fenw_range fw; fw.init(n); @@ -109,7 +109,7 @@ void test_fenwick_rp_random() { void test_fenwick_2d_basic() { fenw_2d fw; - vvl a = {{3}}; + vector> a = {{3}}; fw.build(a); assert(fw.sum(0, 0, 0, 0) == 3); fw.set(0, 0, -2); @@ -118,7 +118,7 @@ void test_fenwick_2d_basic() { void test_fenwick_2d_random() { int n = 8, m = 7; - vvl a(n, vl(m, 0)); + vector> a(n, vector(m, 0)); for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) a[i][j] = rnd(-3, 3); diff --git a/tests/1-ds/test_li_chao_tree.cpp b/tests/1-ds/test_li_chao_tree.cpp index 9c8fbb0..da90d97 100644 --- a/tests/1-ds/test_li_chao_tree.cpp +++ b/tests/1-ds/test_li_chao_tree.cpp @@ -23,12 +23,12 @@ void test_li_chao_basic() { li_chao lc; lc.init(-5, 5); vector lns; - lns.pb({2, 1}); + lns.push_back({2, 1}); lc.add(lns.back()); assert(lc.query(-5) == max_naive(lns, -5)); assert(lc.query(5) == max_naive(lns, 5)); - lns.pb({2, -3}); + lns.push_back({2, -3}); lc.add(lns.back()); assert(lc.query(0) == max_naive(lns, 0)); } @@ -44,7 +44,7 @@ void test_li_chao_random() { if (op == 0) { ll a = rnd(-5, 5); ll b = rnd(-20, 20); - lns.pb({a, b}); + lns.push_back({a, b}); lc.add(lns.back()); } else { ll x = rnd(xl, xr); diff --git a/tests/1-ds/test_merge_sort_tree.cpp b/tests/1-ds/test_merge_sort_tree.cpp index 4f0eada..5d8ef3b 100644 --- a/tests/1-ds/test_merge_sort_tree.cpp +++ b/tests/1-ds/test_merge_sort_tree.cpp @@ -11,14 +11,14 @@ ll rnd(ll l, ll r) { return dis(rng); } -int count_greater(const vi &a, int l, int r, int k) { +int count_greater(const vector &a, int l, int r, int k) { int ret = 0; for (int i = l; i <= r; i++) ret += (a[i] > k); return ret; } void test_merge_sort_tree_basic() { - vi a = {5}; + vector a = {5}; merge_seg st; st.build(a); assert(st.query(0, 0, 4) == 1); @@ -27,7 +27,7 @@ void test_merge_sort_tree_basic() { void test_merge_sort_tree_random() { int n = 60; - vi a(n); + vector a(n); for (int i = 0; i < n; i++) a[i] = (int)rnd(-10, 10); merge_seg st; @@ -42,7 +42,7 @@ void test_merge_sort_tree_random() { } void test_merge_sort_tree_iter_basic() { - vi a = {2}; + vector a = {2}; merge_seg_it st; st.build(a); assert(st.query(0, 0, 1) == 1); @@ -51,7 +51,7 @@ void test_merge_sort_tree_iter_basic() { void test_merge_sort_tree_iter_random() { int n = 60; - vi a(n); + vector a(n); for (int i = 0; i < n; i++) a[i] = (int)rnd(-10, 10); merge_seg_it st; diff --git a/tests/1-ds/test_segment_tree.cpp b/tests/1-ds/test_segment_tree.cpp index a7a7744..bd76df2 100644 --- a/tests/1-ds/test_segment_tree.cpp +++ b/tests/1-ds/test_segment_tree.cpp @@ -11,13 +11,13 @@ ll rnd(ll l, ll r) { return dis(rng); } -ll sum_range(const vl &a, int l, int r) { +ll sum_range(const vector &a, int l, int r) { ll ret = 0; for (int i = l; i <= r; i++) ret += a[i]; return ret; } -int kth_naive_freq(const vl &a, ll k) { +int kth_naive_freq(const vector &a, ll k) { ll cur = 0; for (int i = 1; i < sz(a); i++) { cur += a[i]; @@ -27,7 +27,7 @@ int kth_naive_freq(const vl &a, ll k) { } void test_segt_basic() { - vl a = {0, 3}; + vector a = {0, 3}; seg_tree st; st.build(a); assert(st.query(1, 1) == 3); @@ -37,7 +37,7 @@ void test_segt_basic() { void test_segt_random() { int n = 50; - vl a(n + 1, 0); + vector a(n + 1, 0); for (int i = 1; i <= n; i++) a[i] = rnd(-5, 5); seg_tree st; @@ -59,7 +59,7 @@ void test_segt_random() { } void test_segti_basic() { - vl a = {4}; + vector a = {4}; seg_tree_it st; st.build(a); assert(st.query(0, 1) == 4); @@ -69,7 +69,7 @@ void test_segti_basic() { void test_segti_random() { int n = 50; - vl a(n, 0); + vector a(n, 0); for (int i = 0; i < n; i++) a[i] = rnd(-5, 5); seg_tree_it st; @@ -105,7 +105,7 @@ void test_segk_basic() { void test_segk_random() { int n = 40; - vl a(n + 1, 0); + vector a(n + 1, 0); seg_tree_kth st; st.init(n); @@ -127,7 +127,7 @@ void test_segk_random() { } void test_seglz_basic() { - vl a = {0, 1, 2}; + vector a = {0, 1, 2}; seg_tree_lz st; st.build(a); st.add(1, 2, 3); @@ -136,7 +136,7 @@ void test_seglz_basic() { void test_seglz_random() { int n = 40; - vl a(n + 1, 0); + vector a(n + 1, 0); for (int i = 1; i <= n; i++) a[i] = rnd(-5, 5); seg_tree_lz st; @@ -160,7 +160,7 @@ void test_seglz_random() { void test_pst_basic() { int n = 3; - vl a = {0, 1, 2, 3}; + vector a = {0, 1, 2, 3}; seg_pst st; st.build(n, a); st.set(2, 5); @@ -170,10 +170,10 @@ void test_pst_basic() { void test_pst_random() { int n = 20; - vvl ver; - vl a(n + 1, 0); + vector> ver; + vector a(n + 1, 0); for (int i = 1; i <= n; i++) a[i] = rnd(-5, 5); - ver.pb(a); + ver.push_back(a); seg_pst st; st.build(n, a); @@ -183,9 +183,9 @@ void test_pst_random() { if (op == 0) { int p = (int)rnd(1, n); ll v = rnd(-5, 5); - vl nw = ver.back(); + vector nw = ver.back(); nw[p] = v; - ver.pb(nw); + ver.push_back(nw); st.set(p, v); } else { int id = (int)rnd(0, sz(ver) - 1); @@ -198,7 +198,7 @@ void test_pst_random() { void test_pst_kth_basic() { int n = 5; - vl a = {0, 2, 0, 1, 3, 0}; + vector a = {0, 2, 0, 1, 3, 0}; seg_pst st; st.build(n, a); assert(st.kth(1, 0) == 1); @@ -214,10 +214,10 @@ void test_pst_kth_basic() { void test_pst_kth_random() { int n = 40; - vvl ver; - vl a(n + 1, 0); + vector> ver; + vector a(n + 1, 0); for (int i = 1; i <= n; i++) a[i] = rnd(0, 3); - ver.pb(a); + ver.push_back(a); seg_pst st; st.build(n, a); @@ -227,9 +227,9 @@ void test_pst_kth_random() { if (op == 0) { int p = (int)rnd(1, n); ll v = rnd(0, 5); - vl nw = ver.back(); + vector nw = ver.back(); nw[p] = v; - ver.pb(nw); + ver.push_back(nw); st.set(p, v); } else { int id = (int)rnd(0, sz(ver) - 1); @@ -276,7 +276,7 @@ void test_dyseg_random() { } } -ll sum_rect(const vvl &a, int x1, int y1, int x2, int y2) { +ll sum_rect(const vector> &a, int x1, int y1, int x2, int y2) { ll ret = 0; for (int i = x1; i <= x2; i++) for (int j = y1; j <= y2; j++) ret += a[i][j]; @@ -284,7 +284,7 @@ ll sum_rect(const vvl &a, int x1, int y1, int x2, int y2) { } void test_seg2d_basic() { - vvl a = {{7}}; + vector> a = {{7}}; seg_2d st; st.build(a); assert(st.query(0, 0, 0, 0) == 7); @@ -294,7 +294,7 @@ void test_seg2d_basic() { void test_seg2d_random() { int n = 7; - vvl a(n, vl(n, 0)); + vector> a(n, vector(n, 0)); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) a[i][j] = rnd(-3, 3); @@ -329,10 +329,10 @@ void test_seg2dc_basic() { int n = 1; seg2d_comp st(n); vector ops; - ops.pb({0, 0, 0, 0, 0, 5}); - ops.pb({1, 0, 0, 0, 0, 0}); - ops.pb({0, 0, 0, 0, 0, -2}); - ops.pb({1, 0, 0, 0, 0, 0}); + ops.push_back({0, 0, 0, 0, 0, 5}); + ops.push_back({1, 0, 0, 0, 0, 0}); + ops.push_back({0, 0, 0, 0, 0, -2}); + ops.push_back({1, 0, 0, 0, 0, 0}); for (auto &op : ops) { if (op.type == 0) st.mark_set(op.x1, op.y1); @@ -340,7 +340,7 @@ void test_seg2dc_basic() { } st.prep(); - vvl a(n, vl(n, 0)); + vector> a(n, vector(n, 0)); for (auto &op : ops) { if (op.type == 0) { a[op.x1][op.y1] = op.val; @@ -370,13 +370,13 @@ void test_seg2dc_random() { int x = (int)rnd(0, n - 1); int y = (int)rnd(0, n - 1); ll v = rnd(-5, 5); - ops.pb({0, x, 0, y, 0, v}); + ops.push_back({0, x, 0, y, 0, v}); } else { int x1 = (int)rnd(0, n - 1); int x2 = (int)rnd(x1, n - 1); int y1 = (int)rnd(0, n - 1); int y2 = (int)rnd(y1, n - 1); - ops.pb({1, x1, x2, y1, y2, 0}); + ops.push_back({1, x1, x2, y1, y2, 0}); } } @@ -386,7 +386,7 @@ void test_seg2dc_random() { } st.prep(); - vvl a(n, vl(n, 0)); + vector> a(n, vector(n, 0)); for (auto &op : ops) { if (op.type == 0) { a[op.x1][op.y1] = op.val; diff --git a/tests/1-ds/test_union_find.cpp b/tests/1-ds/test_union_find.cpp index c890040..d699179 100644 --- a/tests/1-ds/test_union_find.cpp +++ b/tests/1-ds/test_union_find.cpp @@ -12,8 +12,8 @@ ll rnd(ll l, ll r) { } struct naive_dsu { - vi comp; - vi siz; + vector comp; + vector siz; void init(int n) { comp.resize(n); diff --git a/tests/2-graph/test_bcc.cpp b/tests/2-graph/test_bcc.cpp index 3ead5a1..0da8629 100644 --- a/tests/2-graph/test_bcc.cpp +++ b/tests/2-graph/test_bcc.cpp @@ -12,15 +12,15 @@ int rnd(int l, int r) { } int ccnt(int n, const vector &ed, int sv, int se) { - vvi adj(n + 1); + vector> adj(n + 1); for (int i = 0; i < sz(ed); i++) { if (i == se) continue; int u = ed[i].fr, v = ed[i].sc; if (u == sv || v == sv) continue; - adj[u].pb(v); - adj[v].pb(u); + adj[u].push_back(v); + adj[v].push_back(u); } - vi vis(n + 1); + vector vis(n + 1); int cnt = 0; for (int v = 1; v <= n; v++) { if (v == sv || vis[v]) continue; @@ -39,11 +39,11 @@ int ccnt(int n, const vector &ed, int sv, int se) { return cnt; } -vi ap_na(int n, const vector &ed) { +vector ap_na(int n, const vector &ed) { int base = ccnt(n, ed, 0, -1); - vi ap; + vector ap; for (int v = 1; v <= n; v++) - if (ccnt(n, ed, v, -1) > base) ap.pb(v); + if (ccnt(n, ed, v, -1) > base) ap.push_back(v); return ap; } @@ -54,7 +54,7 @@ vector ae_na(int n, const vector &ed) { if (ccnt(n, ed, 0, i) > base) { int u = ed[i].fr, v = ed[i].sc; if (u > v) swap(u, v); - ae.pb({u, v}); + ae.push_back({u, v}); } } sort(all(ae)); @@ -81,12 +81,12 @@ void chk_bcc(int n, const vector &ed, bcc_graph &g) { vector> adj(n + 1); for (int i = 0; i < sz(comp); i++) { int u = comp[i].fr, v = comp[i].sc; - adj[u].pb({v, i}); - adj[v].pb({u, i}); + adj[u].push_back({v, i}); + adj[v].push_back({u, i}); } for (int i = 0; i < sz(comp); i++) { int u = comp[i].fr, v = comp[i].sc; - vi vis(n + 1); + vector vis(n + 1); queue q; q.push(u); vis[u] = 1; @@ -115,7 +115,7 @@ void t_fix() { auto ae = g.ae; sort(all(ap)); sort(all(ae)); - assert(ap == vi({2})); + assert(ap == vector({2})); assert(ae == vector({{1, 2}, {2, 3}})); chk_bcc(n, ed, g); } @@ -131,7 +131,7 @@ void t_rnd() { i--; continue; } - ed.pb({u, v}); + ed.push_back({u, v}); } bcc_graph g; g.init(n); diff --git a/tests/2-graph/test_euler_circuit.cpp b/tests/2-graph/test_euler_circuit.cpp index f245078..7f4795b 100644 --- a/tests/2-graph/test_euler_circuit.cpp +++ b/tests/2-graph/test_euler_circuit.cpp @@ -11,7 +11,7 @@ int rnd(int l, int r) { return dis(rng); } -int ecnt(int n, const vvi &cnt) { +int ecnt(int n, const vector> &cnt) { int m = 0; for (int i = 1; i <= n; i++) m += cnt[i][i]; for (int i = 1; i <= n; i++) @@ -19,8 +19,8 @@ int ecnt(int n, const vvi &cnt) { return m; } -bool can_na(int n, const vvi &cnt) { - vi deg(n + 1); +bool can_na(int n, const vector> &cnt) { + vector deg(n + 1); for (int i = 1; i <= n; i++) { deg[i] += 2 * cnt[i][i]; for (int j = 1; j <= n; j++) @@ -35,7 +35,7 @@ bool can_na(int n, const vvi &cnt) { break; } if (!s) return 1; - vi vis(n + 1); + vector vis(n + 1); queue q; q.push(s); vis[s] = 1; @@ -53,13 +53,13 @@ bool can_na(int n, const vvi &cnt) { return 1; } -void add_ed(euler_cir &g, vvi &cnt, int u, int v) { +void add_ed(euler_cir &g, vector> &cnt, int u, int v) { g.add(u, v); if (u == v) cnt[u][u]++; else cnt[u][v]++, cnt[v][u]++; } -void chk_run(int n, const vvi &cnt, const vi &path) { +void chk_run(int n, const vector> &cnt, const vector &path) { int m = ecnt(n, cnt); if (m == 0) { assert(sz(path) == 1); @@ -86,7 +86,7 @@ void t_fix() { int n = 3; euler_cir g; g.init(n); - vvi cnt(n + 1, vi(n + 1)); + vector> cnt(n + 1, vector(n + 1)); add_ed(g, cnt, 1, 2); add_ed(g, cnt, 2, 3); add_ed(g, cnt, 3, 1); @@ -95,7 +95,7 @@ void t_fix() { chk_run(n, cnt, path); g.init(n); - cnt.assign(n + 1, vi(n + 1)); + cnt.assign(n + 1, vector(n + 1)); add_ed(g, cnt, 1, 2); add_ed(g, cnt, 2, 3); assert(!g.can()); @@ -107,7 +107,7 @@ void t_rnd() { int m = rnd(0, 8); euler_cir g; g.init(n); - vvi cnt(n + 1, vi(n + 1)); + vector> cnt(n + 1, vector(n + 1)); for (int i = 0; i < m; i++) { int u = rnd(1, n), v = rnd(1, n); add_ed(g, cnt, u, v); @@ -117,7 +117,7 @@ void t_rnd() { assert(ok1 == ok2); if (ok1) { int s = 1; - vi deg(n + 1); + vector deg(n + 1); for (int i = 1; i <= n; i++) { deg[i] += 2 * cnt[i][i]; for (int j = 1; j <= n; j++) diff --git a/tests/2-graph/test_kth_shortest_path.cpp b/tests/2-graph/test_kth_shortest_path.cpp index e673886..9ec3daa 100644 --- a/tests/2-graph/test_kth_shortest_path.cpp +++ b/tests/2-graph/test_kth_shortest_path.cpp @@ -13,17 +13,17 @@ int rnd(int l, int r) { kth_walk ks; -vl kth_na(int n, const vector> &g, int s, int e, int k) { - vi cnt(n + 1); +vector kth_na(int n, const vector> &g, int s, int e, int k) { + vector cnt(n + 1); priority_queue, greater> pq; pq.push({0, s}); - vl res; + vector res; while (!pq.empty() && sz(res) < k) { auto [d, v] = pq.top(); pq.pop(); cnt[v]++; if (cnt[v] > k) continue; - if (v == e) res.pb(d); + if (v == e) res.push_back(d); if (cnt[v] <= k) for (auto [w, to] : g[v]) pq.push({d + w, to}); } @@ -33,8 +33,8 @@ vl kth_na(int n, const vector> &g, int s, int e, int k) { void t_fix() { int n = 3; vector> g(n + 1); - g[1].pb({1, 2}); - g[2].pb({1, 3}); + g[1].push_back({1, 2}); + g[2].push_back({1, 3}); ks.init(n); ks.add(1, 2, 1); ks.add(2, 3, 1); @@ -52,7 +52,7 @@ void t_rnd() { for (int i = 0; i < m; i++) { int u = rnd(1, n), v = rnd(1, n); ll w = rnd(1, 5); - g[u].pb({w, v}); + g[u].push_back({w, v}); ks.add(u, v, w); } int s = rnd(1, n), e = rnd(1, n), k = rnd(1, 10); diff --git a/tests/2-graph/test_offline_dynamic_connectivity.cpp b/tests/2-graph/test_offline_dynamic_connectivity.cpp index a11f68f..416abec 100644 --- a/tests/2-graph/test_offline_dynamic_connectivity.cpp +++ b/tests/2-graph/test_offline_dynamic_connectivity.cpp @@ -13,12 +13,12 @@ int rnd(int l, int r) { int conn(int n, const set &act, int s, int e) { if (s == e) return 1; - vvi adj(n + 1); + vector> adj(n + 1); for (auto [u, v] : act) { - adj[u].pb(v); - adj[v].pb(u); + adj[u].push_back(v); + adj[v].push_back(u); } - vi vis(n + 1); + vector vis(n + 1); queue q; q.push(s); vis[s] = 1; @@ -34,7 +34,7 @@ int conn(int n, const set &act, int s, int e) { void t_fix() { int n = 4, q = 6; - vi op(q + 1), u(q + 1), v(q + 1), ans(q + 1); + vector op(q + 1), u(q + 1), v(q + 1), ans(q + 1); op[1] = 1, u[1] = 1, v[1] = 2; op[2] = 3, u[2] = 1, v[2] = 3; op[3] = 1, u[3] = 2, v[3] = 3; @@ -64,7 +64,7 @@ void t_rnd() { for (int it = 0; it < 200; it++) { int n = rnd(2, 8); int q = rnd(1, 40); - vi op(q + 1), u(q + 1), v(q + 1), ans(q + 1); + vector op(q + 1), u(q + 1), v(q + 1), ans(q + 1); set act; for (int i = 1; i <= q; i++) { int t = rnd(0, 9); diff --git a/tests/2-graph/test_scc_2_sat.cpp b/tests/2-graph/test_scc_2_sat.cpp index 97e303b..0593310 100644 --- a/tests/2-graph/test_scc_2_sat.cpp +++ b/tests/2-graph/test_scc_2_sat.cpp @@ -11,8 +11,8 @@ int rnd(int l, int r) { return dis(rng); } -vvi rch(int n, const vvi &g) { - vvi r(n + 1, vi(n + 1)); +vector> rch(int n, const vector> &g) { + vector> r(n + 1, vector(n + 1)); for (int s = 1; s <= n; s++) { queue q; q.push(s); @@ -28,9 +28,9 @@ vvi rch(int n, const vvi &g) { return r; } -vi cmp_na(int n, const vvi &g) { +vector cmp_na(int n, const vector> &g) { auto r = rch(n, g); - vi cmp(n + 1, -1); + vector cmp(n + 1, -1); int cid = 0; for (int i = 1; i <= n; i++) { if (cmp[i] != -1) continue; @@ -41,7 +41,7 @@ vi cmp_na(int n, const vvi &g) { return cmp; } -bool sat_br(int n, const vector &cl, vi &val) { +bool sat_br(int n, const vector &cl, vector &val) { int lim = 1 << n; for (int mask = 0; mask < lim; mask++) { bool ok = 1; @@ -65,10 +65,10 @@ void t_scc() { for (int it = 0; it < 200; it++) { int n = rnd(1, 7); int m = rnd(0, n * (n - 1)); - vvi g(n + 1); + vector> g(n + 1); for (int i = 0; i < m; i++) { int u = rnd(1, n), v = rnd(1, n); - g[u].pb(v); + g[u].push_back(v); } auto cmp = cmp_na(n, g); @@ -104,9 +104,9 @@ void t_sat() { int a = rnd(1, n), b = rnd(1, n); if (rnd(0, 1)) a = -a; if (rnd(0, 1)) b = -b; - cl.pb({a, b}); + cl.push_back({a, b}); } - vi val; + vector val; bool ok2 = sat_br(n, cl, val); two_sat ts; diff --git a/tests/2-graph/test_shortest_path.cpp b/tests/2-graph/test_shortest_path.cpp index 42e120d..800dd76 100644 --- a/tests/2-graph/test_shortest_path.cpp +++ b/tests/2-graph/test_shortest_path.cpp @@ -11,9 +11,9 @@ int rnd(int l, int r) { return dis(rng); } -vvl floy(int n, const vector> &ed) { +vector> floy(int n, const vector> &ed) { const ll INF = (1LL << 60); - vvl d(n + 1, vl(n + 1, INF)); + vector> d(n + 1, vector(n + 1, INF)); for (int i = 1; i <= n; i++) d[i][i] = 0; for (auto [u, v, w] : ed) d[u][v] = min(d[u][v], w); for (int k = 1; k <= n; k++) @@ -36,7 +36,7 @@ void t_dijk() { for (int i = 0; i < m; i++) { int u = rnd(1, n), v = rnd(1, n); ll w = rnd(0, 9); - ed.pb({u, v, w}); + ed.push_back({u, v, w}); dj.add(u, v, w); } auto d = floy(n, ed); @@ -62,7 +62,7 @@ void t_bell() { for (int i = 0; i < m; i++) { int u = rnd(1, n), v = rnd(1, n); ll w = rnd(-5, 9); - ed.pb({u, v, w}); + ed.push_back({u, v, w}); bl.add(u, v, w); } auto d = floy(n, ed); @@ -70,7 +70,7 @@ void t_bell() { bool neg = 0; for (int v = 1; v <= n; v++) if (d[s][v] < INF / 2 && d[v][v] < 0) neg = 1; - vl dist; + vector dist; bool ok = bl.run(s, dist); if (neg) { assert(!ok); @@ -97,7 +97,7 @@ void t_floy() { for (int i = 0; i < m; i++) { int u = rnd(1, n), v = rnd(1, n); ll w = rnd(-5, 9); - ed.pb({u, v, w}); + ed.push_back({u, v, w}); fl.add(u, v, w); } auto d = floy(n, ed); diff --git a/tests/3-tree/test_centroid_decomp.cpp b/tests/3-tree/test_centroid_decomp.cpp index 8501a07..e15e797 100644 --- a/tests/3-tree/test_centroid_decomp.cpp +++ b/tests/3-tree/test_centroid_decomp.cpp @@ -11,18 +11,18 @@ int rnd(int l, int r) { return dis(rng); } -void add_edge(vvi &adj, int u, int v) { - adj[u].pb(v); - adj[v].pb(u); +void add_edge(vector> &adj, int u, int v) { + adj[u].push_back(v); + adj[v].push_back(u); } -vvi gen_tree(int n) { - vvi adj(n + 1); +vector> gen_tree(int n) { + vector> adj(n + 1); for (int v = 2; v <= n; v++) add_edge(adj, v, rnd(1, v - 1)); return adj; } -int get_root(int n, const vi &par) { +int get_root(int n, const vector &par) { int root = 0; for (int v = 1; v <= n; v++) if (!par[v]) { @@ -33,7 +33,7 @@ int get_root(int n, const vi &par) { return root; } -void get_sub(int v, const vvi &chd, vi &sub) { +void get_sub(int v, const vector> &chd, vector &sub) { sub[v] = 1; for (int to : chd[v]) { get_sub(to, chd, sub); @@ -41,19 +41,19 @@ void get_sub(int v, const vvi &chd, vi &sub) { } } -vi get_nodes(int v, const vvi &chd) { - vi res; - vi st = {v}; +vector get_nodes(int v, const vector> &chd) { + vector res; + vector st = {v}; while (!st.empty()) { int x = st.back(); st.pop_back(); - res.pb(x); - for (int to : chd[x]) st.pb(to); + res.push_back(x); + for (int to : chd[x]) st.push_back(to); } return res; } -void check_one(const vvi &adj) { +void check_one(const vector> &adj) { int n = sz(adj) - 1; cen_decomp cd; cd.init(n); @@ -65,7 +65,7 @@ void check_one(const vvi &adj) { int root = get_root(n, cd.par); // check: centroid tree is a rooted tree on [1..n]. - vi vis(n + 1); + vector vis(n + 1); queue q; q.push(root); vis[root] = 1; @@ -85,7 +85,7 @@ void check_one(const vvi &adj) { assert(cnt == n); assert(edges == n - 1); - vi sub(n + 1); + vector sub(n + 1); get_sub(root, cd.chd, sub); // check: centroid property (each child component size <= half). @@ -98,7 +98,7 @@ void check_one(const vvi &adj) { vector in_c(n + 1, 0); for (int v : nodes_c) in_c[v] = 1; - vi first(n + 1, 0); + vector first(n + 1, 0); queue qq; for (int nb : adj[c]) { if (!in_c[nb]) continue; @@ -117,11 +117,11 @@ void check_one(const vvi &adj) { for (int v : nodes_c) if (v != c) assert(first[v]); - vi labs; + vector labs; for (int x : cd.chd[c]) { int lab = first[x]; assert(lab); - labs.pb(lab); + labs.push_back(lab); auto nodes_x = get_nodes(x, cd.chd); for (int v : nodes_x) assert(first[v] == lab); } @@ -134,24 +134,24 @@ void check_one(const vvi &adj) { void t_fix() { { int n = 1; - vvi adj(n + 1); + vector> adj(n + 1); check_one(adj); } { int n = 2; - vvi adj(n + 1); + vector> adj(n + 1); add_edge(adj, 1, 2); check_one(adj); } { int n = 7; - vvi adj(n + 1); + vector> adj(n + 1); for (int i = 1; i < n; i++) add_edge(adj, i, i + 1); check_one(adj); } { int n = 9; - vvi adj(n + 1); + vector> adj(n + 1); for (int i = 2; i <= n; i++) add_edge(adj, 1, i); check_one(adj); } diff --git a/tests/3-tree/test_hld.cpp b/tests/3-tree/test_hld.cpp index 017ace1..bfe0a08 100644 --- a/tests/3-tree/test_hld.cpp +++ b/tests/3-tree/test_hld.cpp @@ -11,8 +11,8 @@ int rnd(int l, int r) { return dis(rng); } -vi path_nodes(int n, const vvi &adj, int s, int e) { - vi par(n + 1, -1); +vector path_nodes(int n, const vector> &adj, int s, int e) { + vector par(n + 1, -1); queue q; q.push(s); par[s] = s; @@ -26,22 +26,22 @@ vi path_nodes(int n, const vvi &adj, int s, int e) { q.push(to); } } - vi res; + vector res; int v = e; while (v != par[v]) { - res.pb(v); + res.push_back(v); v = par[v]; } - res.pb(s); + res.push_back(s); return res; } void t_fix() { int n = 4; - vvi adj(n + 1); + vector> adj(n + 1); auto add = [&](int u, int v) { - adj[u].pb(v); - adj[v].pb(u); + adj[u].push_back(v); + adj[v].push_back(u); }; add(1, 2); add(2, 3); @@ -53,7 +53,7 @@ void t_fix() { for (int v : adj[u]) if (u < v) h.add(u, v); h.build(1); - vl val = {0, 1, 2, 3, 4}; + vector val = {0, 1, 2, 3, 4}; for (int i = 1; i <= n; i++) h.set(i, val[i]); auto p = path_nodes(n, adj, 3, 4); ll sum = 0; @@ -64,18 +64,18 @@ void t_fix() { void t_rnd() { for (int it = 0; it < 200; it++) { int n = rnd(2, 9); - vi par(n + 1, 0); - vvi adj(n + 1); + vector par(n + 1, 0); + vector> adj(n + 1); for (int v = 2; v <= n; v++) { par[v] = rnd(1, v - 1); - adj[v].pb(par[v]); - adj[par[v]].pb(v); + adj[v].push_back(par[v]); + adj[par[v]].push_back(v); } hld_tree h; h.init(n); for (int v = 2; v <= n; v++) h.add(v, par[v]); h.build(1); - vl val(n + 1); + vector val(n + 1); for (int i = 1; i <= n; i++) { val[i] = rnd(-5, 5); h.set(i, val[i]); diff --git a/tests/3-tree/test_lca_sparse_table.cpp b/tests/3-tree/test_lca_sparse_table.cpp index f6e1e66..d595a91 100644 --- a/tests/3-tree/test_lca_sparse_table.cpp +++ b/tests/3-tree/test_lca_sparse_table.cpp @@ -11,8 +11,8 @@ int rnd(int l, int r) { return dis(rng); } -int lca_na(int n, const vvi &adj, int root, int a, int b) { - vi par(n + 1, 0), dep(n + 1, 0); +int lca_na(int n, const vector> &adj, int root, int a, int b) { + vector par(n + 1, 0), dep(n + 1, 0); queue q; q.push(root); par[root] = root; @@ -35,12 +35,12 @@ int lca_na(int n, const vvi &adj, int root, int a, int b) { void t_rnd() { for (int it = 0; it < 200; it++) { int n = rnd(2, 20); - vi par(n + 1, 0); - vvi adj(n + 1); + vector par(n + 1, 0); + vector> adj(n + 1); for (int v = 2; v <= n; v++) { par[v] = rnd(1, v - 1); - adj[v].pb(par[v]); - adj[par[v]].pb(v); + adj[v].push_back(par[v]); + adj[par[v]].push_back(v); } lca_sparse l; l.init(n); diff --git a/tests/3-tree/test_tree_composition.cpp b/tests/3-tree/test_tree_composition.cpp index fd806ca..4baacff 100644 --- a/tests/3-tree/test_tree_composition.cpp +++ b/tests/3-tree/test_tree_composition.cpp @@ -11,18 +11,18 @@ int rnd(int l, int r) { return dis(rng); } -void add_edge(vvi &adj, int u, int v) { - adj[u].pb(v); - adj[v].pb(u); +void add_edge(vector> &adj, int u, int v) { + adj[u].push_back(v); + adj[v].push_back(u); } -vvi gen_tree(int n) { - vvi adj(n + 1); +vector> gen_tree(int n) { + vector> adj(n + 1); for (int v = 2; v <= n; v++) add_edge(adj, v, rnd(1, v - 1)); return adj; } -void root_tree(int n, const vvi &adj, int root, vi &par, vi &dep) { +void root_tree(int n, const vector> &adj, int root, vector &par, vector &dep) { par.assign(n + 1, -1); dep.assign(n + 1, 0); queue q; @@ -42,14 +42,14 @@ void root_tree(int n, const vvi &adj, int root, vi &par, vi &dep) { for (int v = 1; v <= n; v++) assert(par[v] != -1); } -int lca_na(int a, int b, const vi &par, const vi &dep) { +int lca_na(int a, int b, const vector &par, const vector &dep) { while (dep[a] > dep[b]) a = par[a]; while (dep[b] > dep[a]) b = par[b]; while (a != b) a = par[a], b = par[b]; return a; } -vi lca_closure(vi vs, const vi &par, const vi &dep) { +vector lca_closure(vector vs, const vector &par, const vector &dep) { int n = sz(par) - 1; sort(all(vs)); vs.erase(unique(all(vs)), vs.end()); @@ -64,7 +64,7 @@ vi lca_closure(vi vs, const vi &par, const vi &dep) { int c = lca_na(vs[i], vs[j], par, dep); if (!in_set[c]) { in_set[c] = 1; - vs.pb(c); + vs.push_back(c); chg = 1; } } @@ -76,9 +76,9 @@ vi lca_closure(vi vs, const vi &par, const vi &dep) { return vs; } -void check_one(const vvi &adj, const vi &vs) { +void check_one(const vector> &adj, const vector &vs) { int n = sz(adj) - 1; - vi par, dep; + vector par, dep; root_tree(n, adj, 1, par, dep); tree_comp tc; @@ -102,7 +102,7 @@ void check_one(const vvi &adj, const vi &vs) { vector in_set(n + 1, 0); for (int v : exp_nodes) in_set[v] = 1; - vi in_cnt(n + 1, 0), par_vt(n + 1, 0); + vector in_cnt(n + 1, 0), par_vt(n + 1, 0); int edges = 0; for (int v : exp_nodes) for (int to : tc.vt_adj[v]) { @@ -132,15 +132,15 @@ void check_one(const vvi &adj, const vi &vs) { } } - vi vis(n + 1); - vi st = {root}; + vector vis(n + 1); + vector st = {root}; vis[root] = 1; while (!st.empty()) { int v = st.back(); st.pop_back(); for (int to : tc.vt_adj[v]) { vis[to] = 1; - st.pb(to); + st.push_back(to); } } for (int v : exp_nodes) assert(vis[v]); @@ -149,13 +149,13 @@ void check_one(const vvi &adj, const vi &vs) { void t_fix() { { int n = 1; - vvi adj(n + 1); + vector> adj(n + 1); check_one(adj, {}); check_one(adj, {1}); } { int n = 5; - vvi adj(n + 1); + vector> adj(n + 1); for (int i = 1; i < n; i++) add_edge(adj, i, i + 1); check_one(adj, {3}); check_one(adj, {2, 4}); @@ -169,8 +169,8 @@ void t_rnd() { int n = rnd(2, 30); auto adj = gen_tree(n); int k = rnd(0, n); - vi vs; - for (int i = 0; i < k; i++) vs.pb(rnd(1, n)); + vector vs; + for (int i = 0; i < k; i++) vs.push_back(rnd(1, n)); check_one(adj, vs); } } diff --git a/tests/3-tree/test_tree_exchange_argument.cpp b/tests/3-tree/test_tree_exchange_argument.cpp index 14f0023..6a877eb 100644 --- a/tests/3-tree/test_tree_exchange_argument.cpp +++ b/tests/3-tree/test_tree_exchange_argument.cpp @@ -11,20 +11,20 @@ int rnd(int l, int r) { return dis(rng); } -void add_edge(vvi &adj, int u, int v) { - adj[u].pb(v); - adj[v].pb(u); +void add_edge(vector> &adj, int u, int v) { + adj[u].push_back(v); + adj[v].push_back(u); } -vvi gen_tree(int n) { - vvi adj(n + 1); +vector> gen_tree(int n) { + vector> adj(n + 1); for (int v = 2; v <= n; v++) add_edge(adj, v, rnd(1, v - 1)); return adj; } -vvi get_child(int n, const vvi &adj, int root) { - vvi ch(n + 1); - vi par(n + 1, -1); +vector> get_child(int n, const vector> &adj, int root) { + vector> ch(n + 1); + vector par(n + 1, -1); queue q; q.push(root); par[root] = 0; @@ -35,7 +35,7 @@ vvi get_child(int n, const vvi &adj, int root) { if (to == par[v]) continue; if (par[to] != -1) continue; par[to] = v; - ch[v].pb(to); + ch[v].push_back(to); q.push(to); } } @@ -43,34 +43,34 @@ vvi get_child(int n, const vvi &adj, int root) { return ch; } -ll brute_max(int n, const vvi &ch, const vl &w, const vl &t) { - vi indeg(n + 1, 0); +ll brute_max(int n, const vector> &ch, const vector &w, const vector &t) { + vector indeg(n + 1, 0); for (int v = 1; v <= n; v++) for (int to : ch[v]) indeg[to]++; - vi avail; + vector avail; for (int v = 1; v <= n; v++) - if (!indeg[v]) avail.pb(v); + if (!indeg[v]) avail.push_back(v); ll best = -(1LL << 62); - vi ord; + vector ord; ord.reserve(n); - function dfs = [&](vi &id, vi &av, - ll tm, ll cost) { + function &, vector &, ll, ll)> dfs = [&](vector &id, vector &av, + ll tm, ll cost) { if (sz(ord) == n) { best = max(best, cost); return; } for (int i = 0; i < sz(av); i++) { int v = av[i]; - ord.pb(v); - vi id2 = id; - vi av2 = av; + ord.push_back(v); + vector id2 = id; + vector av2 = av; av2.erase(av2.begin() + i); ll tm2 = tm + t[v]; ll cost2 = cost + w[v] * tm2; for (int to : ch[v]) { id2[to]--; - if (!id2[to]) av2.pb(to); + if (!id2[to]) av2.push_back(to); } dfs(id2, av2, tm2, cost2); ord.pop_back(); @@ -80,7 +80,7 @@ ll brute_max(int n, const vvi &ch, const vl &w, const vl &t) { return best; } -void check_one(const vvi &adj, int root, const vl &w, const vl &t) { +void check_one(const vector> &adj, int root, const vector &w, const vector &t) { int n = sz(adj) - 1; auto ch = get_child(n, adj, root); ll exp = brute_max(n, ch, w, t); @@ -102,11 +102,11 @@ void check_one(const vvi &adj, int root, const vl &w, const vl &t) { void t_fix() { { int n = 3; - vvi adj(n + 1); + vector> adj(n + 1); add_edge(adj, 1, 2); add_edge(adj, 1, 3); - vl w = {0, 1, 2, 3}; - vl t = {0, 1, 1, 1}; + vector w = {0, 1, 2, 3}; + vector t = {0, 1, 1, 1}; check_one(adj, 1, w, t); } } @@ -116,7 +116,7 @@ void t_rnd() { int n = rnd(1, 9); auto adj = gen_tree(n); int root = rnd(1, n); - vl w(n + 1), t(n + 1); + vector w(n + 1), t(n + 1); for (int i = 1; i <= n; i++) { w[i] = rnd(0, 7); t[i] = rnd(1, 4); diff --git a/tests/4-optimizations/test_flow.cpp b/tests/4-optimizations/test_flow.cpp index 4598806..055b53b 100644 --- a/tests/4-optimizations/test_flow.cpp +++ b/tests/4-optimizations/test_flow.cpp @@ -25,14 +25,14 @@ struct ek_flow { void add_edge(int u, int v, ll cap) { edge a{v, sz(g[v]), cap}; edge b{u, sz(g[u]), 0}; - g[u].pb(a); - g[v].pb(b); + g[u].push_back(a); + g[v].push_back(b); } ll max_flow(int s, int t) { if (s == t) return 0; ll flow = 0; while (1) { - vi pv(n, -1), pe(n, -1); + vector pv(n, -1), pe(n, -1); queue q; q.push(s); pv[s] = s; @@ -62,8 +62,8 @@ struct ek_flow { } }; -int brute_match(int n_l, int n_r, const vvi &g) { - vvi dp(n_l + 1, vi(1 << n_r, -1)); +int brute_match(int n_l, int n_r, const vector> &g) { + vector> dp(n_l + 1, vector(1 << n_r, -1)); function go = [&](int i, int mask) { if (i == n_l) return 0; int &ret = dp[i][mask]; @@ -90,15 +90,15 @@ struct mcmf_spfa { void add_edge(int u, int v, ll cap, ll cost) { edge a{v, sz(g[v]), cap, cost}; edge b{u, sz(g[u]), 0, -cost}; - g[u].pb(a); - g[v].pb(b); + g[u].push_back(a); + g[v].push_back(b); } pll min_cost_mf(int s, int t, ll max_f) { const ll INF = (1LL << 62); ll flow = 0, cost = 0; while (flow < max_f) { - vl dist(n, INF); - vi pv(n, -1), pe(n, -1); + vector dist(n, INF); + vector pv(n, -1), pe(n, -1); queue q; vector in_q(n, 0); dist[s] = 0; @@ -145,11 +145,11 @@ struct lr_res { lr_res brute_lr(int n, int s, int t, const vector> &es) { int m = sz(es); - vi f(m, 0); + vector f(m, 0); ll best_f = -(1LL << 62), best_c = (1LL << 62); function dfs = [&](int i) { if (i == m) { - vi bal(n, 0); + vector bal(n, 0); ll cost = 0; for (int k = 0; k < m; k++) { auto [u, v, lo, hi, c] = es[k]; @@ -207,10 +207,10 @@ void t_hk() { for (int it = 0; it < 300; it++) { int n_l = rnd(0, 10), n_r = rnd(0, 10); hk bm(n_l, n_r); - vvi g(n_l); + vector> g(n_l); for (int l = 0; l < n_l; l++) for (int r = 0; r < n_r; r++) - if (rnd(0, 1)) bm.add_edge(l, r), g[l].pb(r); + if (rnd(0, 1)) bm.add_edge(l, r), g[l].push_back(r); assert(bm.max_matching() == brute_match(n_l, n_r, g)); } } @@ -229,7 +229,7 @@ void t_mcmf() { ll cap = rnd(0, 3); ll cost = rnd(-5, 5); nonneg &= (cost >= 0); - es.pb({u, v, cap, cost}); + es.push_back({u, v, cap, cost}); } mcmf mf1(n), mf2(n); mcmf_spfa na; @@ -260,7 +260,7 @@ void t_lr_dinic() { if (u == v) continue; int lo = rnd(0, 2); int hi = lo + rnd(0, 2); - es.pb({u, v, lo, hi, 0}); + es.push_back({u, v, lo, hi, 0}); f.add_edge(u, v, lo, hi); } auto exp = brute_lr(n, s, t, es); @@ -285,7 +285,7 @@ void t_lr_mcmf() { int lo = rnd(0, 2); int hi = lo + rnd(0, 2); int c = rnd(0, 5); - es.pb({u, v, lo, hi, c}); + es.push_back({u, v, lo, hi, c}); f.add_edge(u, v, lo, hi, c); } auto exp = brute_lr(n, s, t, es); diff --git a/tests/4-optimizations/test_hungarian.cpp b/tests/4-optimizations/test_hungarian.cpp index 4f880f4..bbd518e 100644 --- a/tests/4-optimizations/test_hungarian.cpp +++ b/tests/4-optimizations/test_hungarian.cpp @@ -11,10 +11,10 @@ int rnd(int l, int r) { return dis(rng); } -pair brute(int n, int m, const vvl &a) { +pair> brute(int n, int m, const vector> &a) { ll best = (1LL << 62); - vi best_m(n + 1, 0); - vi cur(n + 1, 0); + vector best_m(n + 1, 0); + vector cur(n + 1, 0); vector used(m + 1, 0); function dfs = [&](int i, ll cost) { if (i == n + 1) { @@ -35,7 +35,7 @@ pair brute(int n, int m, const vvl &a) { void t_fix() { int n = 1, m = 1; - vvl a(n + 1, vl(m + 1, 0)); + vector> a(n + 1, vector(m + 1, 0)); a[1][1] = 7; hungarian hu; auto [cost, match_l] = hu.run(n, m, a); @@ -47,7 +47,7 @@ void t_rnd() { for (int it = 0; it < 200; it++) { int n = rnd(1, 6); int m = rnd(n, 7); - vvl a(n + 1, vl(m + 1, 0)); + vector> a(n + 1, vector(m + 1, 0)); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) a[i][j] = rnd(-5, 7); hungarian hu; diff --git a/tests/5-string/test_aho_corasick.cpp b/tests/5-string/test_aho_corasick.cpp index 7b80c01..96c243b 100644 --- a/tests/5-string/test_aho_corasick.cpp +++ b/tests/5-string/test_aho_corasick.cpp @@ -12,7 +12,7 @@ int rnd(int l, int r) { } string rnd_s(int n) { string s; - for (int i = 0; i < n; i++) s.pb('a' + rnd(0, 2)); + for (int i = 0; i < n; i++) s.push_back('a' + rnd(0, 2)); return s; } @@ -41,7 +41,7 @@ void t_rnd() { aho_corasick ac; for (int i = 0; i < n; i++) { string p = rnd_s(rnd(1, 6)); - ps.pb(p); + ps.push_back(p); ac.add(p); } ac.build(); diff --git a/tests/5-string/test_kmp_algorithm.cpp b/tests/5-string/test_kmp_algorithm.cpp index 2869571..9cb328e 100644 --- a/tests/5-string/test_kmp_algorithm.cpp +++ b/tests/5-string/test_kmp_algorithm.cpp @@ -12,21 +12,21 @@ int rnd(int l, int r) { } string rnd_s(int n) { string s; - for (int i = 0; i < n; i++) s.pb('a' + rnd(0, 2)); + for (int i = 0; i < n; i++) s.push_back('a' + rnd(0, 2)); return s; } -vi na_match(const string &t, const string &p) { - vi res; +vector na_match(const string &t, const string &p) { + vector res; if (p.empty()) return res; for (int i = 0; i + sz(p) <= sz(t); i++) - if (!t.compare(i, sz(p), p)) res.pb(i); + if (!t.compare(i, sz(p), p)) res.push_back(i); return res; } void t_fix() { - assert((kmp_match("ababa", "aba") == vi{0, 2})); - assert((kmp_match("aaaaa", "aa") == vi{0, 1, 2, 3})); + assert((kmp_match("ababa", "aba") == vector{0, 2})); + assert((kmp_match("aaaaa", "aa") == vector{0, 1, 2, 3})); } void t_rnd() { diff --git a/tests/5-string/test_manachers_algorithm.cpp b/tests/5-string/test_manachers_algorithm.cpp index 0d51ac9..83a44bf 100644 --- a/tests/5-string/test_manachers_algorithm.cpp +++ b/tests/5-string/test_manachers_algorithm.cpp @@ -12,7 +12,7 @@ int rnd(int l, int r) { } string rnd_s(int n) { string s; - for (int i = 0; i < n; i++) s.pb('a' + rnd(0, 2)); + for (int i = 0; i < n; i++) s.push_back('a' + rnd(0, 2)); return s; } diff --git a/tests/5-string/test_rabin_karp_algorithm.cpp b/tests/5-string/test_rabin_karp_algorithm.cpp index 9ff82db..e50f849 100644 --- a/tests/5-string/test_rabin_karp_algorithm.cpp +++ b/tests/5-string/test_rabin_karp_algorithm.cpp @@ -12,15 +12,15 @@ int rnd(int l, int r) { } string rnd_s(int n) { string s; - for (int i = 0; i < n; i++) s.pb('a' + rnd(0, 2)); + for (int i = 0; i < n; i++) s.push_back('a' + rnd(0, 2)); return s; } -vi na_match(const string &t, const string &p) { - vi res; +vector na_match(const string &t, const string &p) { + vector res; if (p.empty()) return res; for (int i = 0; i + sz(p) <= sz(t); i++) - if (!t.compare(i, sz(p), p)) res.pb(i); + if (!t.compare(i, sz(p), p)) res.push_back(i); return res; } diff --git a/tests/5-string/test_suffix_array.cpp b/tests/5-string/test_suffix_array.cpp index bd214dd..d96bcfb 100644 --- a/tests/5-string/test_suffix_array.cpp +++ b/tests/5-string/test_suffix_array.cpp @@ -12,7 +12,7 @@ int rnd(int l, int r) { } string rnd_s(int n) { string s; - for (int i = 0; i < n; i++) s.pb('a' + rnd(0, 2)); + for (int i = 0; i < n; i++) s.push_back('a' + rnd(0, 2)); return s; } @@ -39,11 +39,11 @@ void check_one(const string &s) { assert(sa.lcp.empty()); return; } - vi exp(n); + vector exp(n); iota(all(exp), 0); sort(all(exp), [&](int i, int j) { return suf_lt(s, i, j); }); assert(sa.sa == exp); - vi exp_lcp(n, 0); + vector exp_lcp(n, 0); for (int i = 1; i < n; i++) exp_lcp[i] = lcp2(s, exp[i], exp[i - 1]); assert(sa.lcp == exp_lcp); } diff --git a/tests/5-string/test_trie.cpp b/tests/5-string/test_trie.cpp index 1673435..8dd9184 100644 --- a/tests/5-string/test_trie.cpp +++ b/tests/5-string/test_trie.cpp @@ -12,7 +12,7 @@ int rnd(int l, int r) { } string rnd_s(int n) { string s; - for (int i = 0; i < n; i++) s.pb('a' + rnd(0, 2)); + for (int i = 0; i < n; i++) s.push_back('a' + rnd(0, 2)); return s; } diff --git a/tests/5-string/test_z_algorithm.cpp b/tests/5-string/test_z_algorithm.cpp index ca04a38..23a855c 100644 --- a/tests/5-string/test_z_algorithm.cpp +++ b/tests/5-string/test_z_algorithm.cpp @@ -12,13 +12,13 @@ int rnd(int l, int r) { } string rnd_s(int n) { string s; - for (int i = 0; i < n; i++) s.pb('a' + rnd(0, 2)); + for (int i = 0; i < n; i++) s.push_back('a' + rnd(0, 2)); return s; } -vi na_z(const string &s) { +vector na_z(const string &s) { int n = sz(s); - vi z(n); + vector z(n); for (int i = 0; i < n; i++) { int k = 0; while (i + k < n && s[k] == s[i + k]) k++; diff --git a/tests/6-geometry/test_bulldozer_trick.cpp b/tests/6-geometry/test_bulldozer_trick.cpp index ddc07b5..489ba3a 100644 --- a/tests/6-geometry/test_bulldozer_trick.cpp +++ b/tests/6-geometry/test_bulldozer_trick.cpp @@ -15,33 +15,33 @@ vector uniq_ang(vector v) { sort(all(v)); vector u; for (auto &x : v) { - if (u.empty() || fabsl(u.back() - x) > 1e-12) u.pb(x); + if (u.empty() || fabsl(u.back() - x) > 1e-12) u.push_back(x); } return u; } -vi perm(const vector &p, map &id) { - vi res; +vector perm(const vector &p, map &id) { + vector res; res.reserve(sz(p)); - for (auto &v : p) res.pb(id[{v.x, v.y}]); + for (auto &v : p) res.push_back(id[{v.x, v.y}]); return res; } -vi proj_ord(const vector &p, map &id, ld ang) { +vector proj_ord(const vector &p, map &id, ld ang) { ld cs = cosl(ang), sn = sinl(ang); vector> arr; arr.reserve(sz(p)); for (auto &v : p) { ld pr = (ld)v.x * cs + (ld)v.y * sn; - arr.pb({pr, id[{v.x, v.y}]}); + arr.push_back({pr, id[{v.x, v.y}]}); } sort(all(arr), [&](auto &a, auto &b) { if (fabsl(a.fr - b.fr) > 1e-18) return a.fr < b.fr; return a.sc < b.sc; }); - vi ord; + vector ord; ord.reserve(sz(p)); - for (auto &x : arr) ord.pb(x.sc); + for (auto &x : arr) ord.push_back(x.sc); return ord; } @@ -55,12 +55,12 @@ void test_bulldozer_small() { pt v{rnd(-10, 10), rnd(-10, 10)}; if (id.count({v.x, v.y})) continue; id[{v.x, v.y}] = sz(pts); - pts.pb(v); + pts.push_back(v); } - vvi got; + vector> got; vector cur = pts; - bulldozer(cur, [&](const vector &p) { got.pb(perm(p, id)); }); + bulldozer(cur, [&](const vector &p) { got.push_back(perm(p, id)); }); vector th; for (int i = 0; i < n; i++) { @@ -72,25 +72,25 @@ void test_bulldozer_small() { ld t = a + PI / 2; t = fmodl(t, PI); if (t < 0) t += PI; - th.pb(t); + th.push_back(t); } } th = uniq_ang(th); vector bnd; - bnd.pb(0); + bnd.push_back(0); for (auto &t : th) { - if (t > 1e-12 && t < PI - 1e-12) bnd.pb(t); + if (t > 1e-12 && t < PI - 1e-12) bnd.push_back(t); } - bnd.pb(PI); + bnd.push_back(PI); bnd = uniq_ang(bnd); - vvi exp; + vector> exp; vector st = pts; sort(all(st)); for (int i = 0; i + 1 < sz(bnd); i++) { ld mid = (bnd[i] + bnd[i + 1]) / 2; - exp.pb(proj_ord(st, id, mid)); + exp.push_back(proj_ord(st, id, mid)); } assert(got == exp); } diff --git a/tests/6-geometry/test_convex_hull.cpp b/tests/6-geometry/test_convex_hull.cpp index 62199b8..4232600 100644 --- a/tests/6-geometry/test_convex_hull.cpp +++ b/tests/6-geometry/test_convex_hull.cpp @@ -37,7 +37,7 @@ vector jarvis(vector p) { vector h; int cur = st; while (1) { - h.pb(p[cur]); + h.push_back(p[cur]); int nxt = (cur == 0 ? 1 : 0); for (int i = 0; i < n; i++) if (i != cur) { @@ -92,7 +92,7 @@ void test_hull_random() { int n = (int)rnd(1, 50); vector p; p.reserve(n); - for (int i = 0; i < n; i++) p.pb({rnd(-20, 20), rnd(-20, 20)}); + for (int i = 0; i < n; i++) p.push_back({rnd(-20, 20), rnd(-20, 20)}); auto h1 = convex_hull(p); auto h2 = jarvis(p); auto s1 = uniq_pts(h1); diff --git a/tests/6-geometry/test_half_plane_intersection.cpp b/tests/6-geometry/test_half_plane_intersection.cpp index 979bda8..3a66732 100644 --- a/tests/6-geometry/test_half_plane_intersection.cpp +++ b/tests/6-geometry/test_half_plane_intersection.cpp @@ -27,10 +27,10 @@ bool in_hp(const hp_line &l, const ptd &p) { void test_hpi_square() { vector ln; - ln.pb({{0, 1}, {0, 0}}); // x >= 0 - ln.pb({{1, 0}, {1, 1}}); // x <= 1 - ln.pb({{0, 0}, {1, 0}}); // y >= 0 - ln.pb({{1, 1}, {0, 1}}); // y <= 1 + ln.push_back({{0, 1}, {0, 0}}); // x >= 0 + ln.push_back({{1, 0}, {1, 1}}); // x <= 1 + ln.push_back({{0, 0}, {1, 0}}); // y >= 0 + ln.push_back({{1, 1}, {0, 1}}); // y <= 1 auto poly = hpi(ln); assert(sz(poly) == 4); assert(fabsl(area_poly(poly) - 1.0L) < 1e-7); @@ -41,9 +41,9 @@ void test_hpi_square() { void test_hpi_triangle() { vector ln; - ln.pb({{0, 1}, {0, 0}}); // x >= 0 - ln.pb({{0, 0}, {1, 0}}); // y >= 0 - ln.pb({{1, 0}, {0, 1}}); // x + y <= 1 + ln.push_back({{0, 1}, {0, 0}}); // x >= 0 + ln.push_back({{0, 0}, {1, 0}}); // y >= 0 + ln.push_back({{1, 0}, {0, 1}}); // x + y <= 1 auto poly = hpi(ln); assert(sz(poly) == 3); assert(fabsl(area_poly(poly) - 0.5L) < 1e-7); @@ -54,8 +54,8 @@ void test_hpi_triangle() { void test_hpi_empty() { vector ln; - ln.pb({{0, 1}, {0, 0}}); // x >= 0 - ln.pb({{-1, 0}, {-1, 1}}); // x <= -1 + ln.push_back({{0, 1}, {0, 0}}); // x >= 0 + ln.push_back({{-1, 0}, {-1, 1}}); // x <= -1 auto poly = hpi(ln); assert(poly.empty()); } @@ -65,15 +65,15 @@ void test_hpi_random_convex() { int n = (int)rnd(10, 30); vector p; p.reserve(n); - for (int i = 0; i < n; i++) p.pb({rnd(-20, 20), rnd(-20, 20)}); + for (int i = 0; i < n; i++) p.push_back({rnd(-20, 20), rnd(-20, 20)}); auto h = convex_hull(p); if (sz(h) < 3) continue; vector hp; - for (auto &v : h) hp.pb({(ld)v.x, (ld)v.y}); + for (auto &v : h) hp.push_back({(ld)v.x, (ld)v.y}); vector ln; for (int i = 0; i < sz(hp); i++) { - ln.pb({hp[i], hp[(i + 1) % sz(hp)]}); + ln.push_back({hp[i], hp[(i + 1) % sz(hp)]}); } auto poly = hpi(ln); assert(sz(poly) == sz(hp)); diff --git a/tests/6-geometry/test_minimum_enclosing_circle.cpp b/tests/6-geometry/test_minimum_enclosing_circle.cpp index eaefbfa..e4e8110 100644 --- a/tests/6-geometry/test_minimum_enclosing_circle.cpp +++ b/tests/6-geometry/test_minimum_enclosing_circle.cpp @@ -89,7 +89,7 @@ void test_mec_random_brute() { p.reserve(n); for (int i = 0; i < n; i++) { ptd v{(ld)rnd(-5, 5), (ld)rnd(-5, 5)}; - p.pb(v); + p.push_back(v); } auto got = min_circle(p); auto exp = brute_mec(p); diff --git a/tests/6-geometry/test_ray_casting.cpp b/tests/6-geometry/test_ray_casting.cpp index 19fd397..0e959ad 100644 --- a/tests/6-geometry/test_ray_casting.cpp +++ b/tests/6-geometry/test_ray_casting.cpp @@ -43,7 +43,7 @@ void test_in_poly_random_convex() { int n = (int)rnd(3, 40); vector p; p.reserve(n); - for (int i = 0; i < n; i++) p.pb({rnd(-20, 20), rnd(-20, 20)}); + for (int i = 0; i < n; i++) p.push_back({rnd(-20, 20), rnd(-20, 20)}); auto h = convex_hull(p); if (sz(h) < 3) continue; diff --git a/tests/6-geometry/test_rotating_callipers.cpp b/tests/6-geometry/test_rotating_callipers.cpp index e81555c..6bee9b2 100644 --- a/tests/6-geometry/test_rotating_callipers.cpp +++ b/tests/6-geometry/test_rotating_callipers.cpp @@ -34,7 +34,7 @@ void test_diam_random() { int n = (int)rnd(1, 50); vector p; p.reserve(n); - for (int i = 0; i < n; i++) p.pb({rnd(-30, 30), rnd(-30, 30)}); + for (int i = 0; i < n; i++) p.push_back({rnd(-30, 30), rnd(-30, 30)}); auto h = convex_hull(p); if (sz(h) == 0) continue; auto res = hull_diam(h); diff --git a/tests/6-geometry/test_sort_by_angular.cpp b/tests/6-geometry/test_sort_by_angular.cpp index 7a8e361..263b811 100644 --- a/tests/6-geometry/test_sort_by_angular.cpp +++ b/tests/6-geometry/test_sort_by_angular.cpp @@ -45,7 +45,7 @@ void test_sort_ang_random() { pt a = u - o, b = v - o; if (cross(a, b) == 0) ok = 0; } - if (ok) p.pb(v); + if (ok) p.push_back(v); } assert(sz(p) == n); diff --git a/tests/7-math/test_comb_cat_der.cpp b/tests/7-math/test_comb_cat_der.cpp index 043e9af..410dea5 100644 --- a/tests/7-math/test_comb_cat_der.cpp +++ b/tests/7-math/test_comb_cat_der.cpp @@ -5,16 +5,16 @@ // constraint: small n. // usage: g++ -std=c++17 test_comb_cat_der.cpp && ./a.out -vl cat_ref(int n) { - vl dp(n + 1, 0); +vector cat_ref(int n) { + vector dp(n + 1, 0); dp[0] = 1; for (int i = 1; i <= n; i++) for (int j = 0; j < i; j++) dp[i] += dp[j] * dp[i - 1 - j]; return dp; } -vl der_ref(int n) { - vl dp(max(3, n + 1), 0); +vector der_ref(int n) { + vector dp(max(3, n + 1), 0); dp[0] = 1; dp[1] = 0; dp[2] = 1; diff --git a/tests/7-math/test_conv_fft.cpp b/tests/7-math/test_conv_fft.cpp index c81b596..543bdea 100644 --- a/tests/7-math/test_conv_fft.cpp +++ b/tests/7-math/test_conv_fft.cpp @@ -11,18 +11,18 @@ int rnd_int(int l, int r) { return dis(rng); } -vl conv_ref(const vl &a, const vl &b) { +vector conv_ref(const vector &a, const vector &b) { int n = sz(a), m = sz(b); - vl c(n + m - 1, 0); + vector c(n + m - 1, 0); for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) c[i + j] += a[i] * b[j]; return c; } -vl conv_mod_ref(const vl &a, const vl &b, ll mod) { +vector conv_mod_ref(const vector &a, const vector &b, ll mod) { int n = sz(a), m = sz(b); - if (mod == 1) return vl(n + m - 1, 0); - vl c(n + m - 1, 0); + if (mod == 1) return vector(n + m - 1, 0); + vector c(n + m - 1, 0); for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { ll v = (ll)((__int128)a[i] * b[j] % mod); @@ -38,7 +38,7 @@ void test_fft() { for (int it = 0; it < 200; it++) { int n = rnd_int(1, 20); int m = rnd_int(1, 20); - vl a(n), b(m); + vector a(n), b(m); for (int i = 0; i < n; i++) a[i] = rnd_int(-5, 5); for (int i = 0; i < m; i++) b[i] = rnd_int(-5, 5); auto ref = conv_ref(a, b); @@ -48,7 +48,7 @@ void test_fft() { for (int it = 0; it < 100; it++) { int n = rnd_int(1, 60); int m = rnd_int(1, 60); - vl a(n), b(m); + vector a(n), b(m); for (int i = 0; i < n; i++) a[i] = rnd_int(-100, 100); for (int i = 0; i < m; i++) b[i] = rnd_int(-100, 100); auto ref = conv_ref(a, b); @@ -63,14 +63,14 @@ void test_fft_mod() { for (int it = 0; it < 200; it++) { int n = rnd_int(1, 20); int m = rnd_int(1, 20); - vl a(n), b(m); + vector a(n), b(m); for (int i = 0; i < n; i++) a[i] = rnd_int(0, 1000); for (int i = 0; i < m; i++) b[i] = rnd_int(0, 1000); auto ref = conv_mod_ref(a, b, mod); auto got = fft_conv::mul_mod(a, b, mod); for (int i = 0; i < sz(ref); i++) assert(got[i] == ref[i]); } - auto all0 = fft_conv::mul_mod(vl(5, 0), vl(7, 0), mod); + auto all0 = fft_conv::mul_mod(vector(5, 0), vector(7, 0), mod); for (ll v : all0) assert(v == 0); } @@ -80,7 +80,7 @@ void test_ntt() { for (int it = 0; it < 200; it++) { int n = rnd_int(1, 20); int m = rnd_int(1, 20); - vl a(n), b(m); + vector a(n), b(m); for (int i = 0; i < n; i++) a[i] = rnd_int(0, mod - 1); for (int i = 0; i < m; i++) b[i] = rnd_int(0, mod - 1); auto ref = conv_mod_ref(a, b, mod); @@ -95,7 +95,7 @@ void test_ntt_any() { for (int it = 0; it < 200; it++) { int n = rnd_int(1, 20); int m = rnd_int(1, 20); - vl a(n), b(m); + vector a(n), b(m); for (int i = 0; i < n; i++) a[i] = rnd_int(0, 1000); for (int i = 0; i < m; i++) b[i] = rnd_int(0, 1000); auto ref = conv_mod_ref(a, b, mod); diff --git a/tests/7-math/test_linalg_gauss.cpp b/tests/7-math/test_linalg_gauss.cpp index 25c71a4..1c314e1 100644 --- a/tests/7-math/test_linalg_gauss.cpp +++ b/tests/7-math/test_linalg_gauss.cpp @@ -38,8 +38,8 @@ void test_gauss_real() { void test_gauss_mod() { int n = 6, m = 6; int mod = 101; - vvi A(n, vi(m)); - vi x(m), b(n); + vector> A(n, vector(m)); + vector x(m), b(n); for (int i = 0; i < m; i++) x[i] = rnd_int(0, mod - 1); for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) A[i][j] = rnd_int(0, mod - 1); @@ -48,7 +48,7 @@ void test_gauss_mod() { for (int j = 0; j < m; j++) sum += (ll)A[i][j] * x[j]; b[i] = sum % mod; } - vvi aug(n, vi(m + 1)); + vector> aug(n, vector(m + 1)); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) aug[i][j] = A[i][j]; aug[i][m] = b[i]; @@ -61,7 +61,7 @@ void test_gauss_mod() { assert(sum % mod == b[i]); } - vvi bad = { + vector> bad = { {1, 0, 0}, {1, 0, 1}, }; @@ -71,7 +71,7 @@ void test_gauss_mod() { void test_gauss_xor() { int n = 40, m = 20; - vi x(m); + vector x(m); for (int i = 0; i < m; i++) x[i] = rnd_int(0, 1); vector> aug(n); for (int i = 0; i < n; i++) { diff --git a/tests/7-math/test_linalg_mat.cpp b/tests/7-math/test_linalg_mat.cpp index 6211ddc..4075ee0 100644 --- a/tests/7-math/test_linalg_mat.cpp +++ b/tests/7-math/test_linalg_mat.cpp @@ -21,9 +21,9 @@ ll fib_ref(int n, ll mod) { return a; } -vvl mul_ref(const vvl &a, const vvl &b, ll mod) { +vector> mul_ref(const vector> &a, const vector> &b, ll mod) { int n = sz(a), m = sz(b[0]), k = sz(a[0]); - vvl r(n, vl(m, 0)); + vector> r(n, vector(m, 0)); for (int i = 0; i < n; i++) for (int t = 0; t < k; t++) for (int j = 0; j < m; j++) { diff --git a/tests/7-math/test_misc_sqrt.cpp b/tests/7-math/test_misc_sqrt.cpp index 803c1b8..5304da1 100644 --- a/tests/7-math/test_misc_sqrt.cpp +++ b/tests/7-math/test_misc_sqrt.cpp @@ -18,30 +18,30 @@ bool is_prime_ref(ll x) { return 1; } -vl div_ref(ll x) { - vl d; +vector div_ref(ll x) { + vector d; for (ll i = 1; i <= x; i++) - if (x % i == 0) d.pb(i); + if (x % i == 0) d.push_back(i); return d; } -vl fac_ref(ll x) { - vl p; +vector fac_ref(ll x) { + vector p; for (ll i = 2; i <= x / i; i++) { while (x % i == 0) { - p.pb(i); + p.push_back(i); x /= i; } } - if (x > 1) p.pb(x); + if (x > 1) p.push_back(x); return p; } int main() { - assert(sqrt_alg::divisors(1) == vl({1})); + assert(sqrt_alg::divisors(1) == vector({1})); assert(sqrt_alg::prime_fac(1).empty()); - assert(sqrt_alg::divisors(36) == vl({1, 2, 3, 4, 6, 9, 12, 18, 36})); - assert(sqrt_alg::prime_fac(36) == vl({2, 2, 3, 3})); + assert(sqrt_alg::divisors(36) == vector({1, 2, 3, 4, 6, 9, 12, 18, 36})); + assert(sqrt_alg::prime_fac(36) == vector({2, 2, 3, 3})); for (int it = 0; it < 1000; it++) { ll x = rnd_ll(1, 5000); auto d1 = sqrt_alg::divisors(x); diff --git a/tests/7-math/test_nt_crt.cpp b/tests/7-math/test_nt_crt.cpp index ab2fe5e..2c45e14 100644 --- a/tests/7-math/test_nt_crt.cpp +++ b/tests/7-math/test_nt_crt.cpp @@ -57,7 +57,7 @@ void test_merge_all() { for (int i = 0; i < k; i++) { ll m = rnd(1, 30); ll r = rnd(-30, 30); - cs.pb({r, m}); + cs.push_back({r, m}); } pll ans = crt::merge_all(cs); ll brute = brute_crt(cs); diff --git a/tests/7-math/test_nt_mr_rho.cpp b/tests/7-math/test_nt_mr_rho.cpp index ee01015..510210f 100644 --- a/tests/7-math/test_nt_mr_rho.cpp +++ b/tests/7-math/test_nt_mr_rho.cpp @@ -18,15 +18,15 @@ bool is_prime_ref(ll x) { return 1; } -vl fac_ref(ll x) { - vl f; +vector fac_ref(ll x) { + vector f; for (ll p = 2; p * p <= x; p++) { while (x % p == 0) { - f.pb(p); + f.push_back(p); x /= p; } } - if (x > 1) f.pb(x); + if (x > 1) f.push_back(x); sort(all(f)); return f; } @@ -56,15 +56,15 @@ void test_factor() { assert(pollard_rho::factor(1).empty()); assert(pollard_rho::factor(0).empty()); auto fneg = pollard_rho::factor(-12); - assert(fneg == vl({2, 2, 3})); + assert(fneg == vector({2, 2, 3})); auto fp = pollard_rho::factor(1000000007LL); - assert(fp == vl({1000000007LL})); + assert(fp == vector({1000000007LL})); ll p = 1000003, q = 1000033; auto fs = pollard_rho::factor(p * q); - assert(fs == vl({p, q})); + assert(fs == vector({p, q})); ll big = 1000000007LL * 1000000009LL; auto fb = pollard_rho::factor(big); - assert(fb == vl({1000000007LL, 1000000009LL})); + assert(fb == vector({1000000007LL, 1000000009LL})); } int main() { diff --git a/tests/7-math/test_nt_sieve.cpp b/tests/7-math/test_nt_sieve.cpp index de243de..5661cf1 100644 --- a/tests/7-math/test_nt_sieve.cpp +++ b/tests/7-math/test_nt_sieve.cpp @@ -45,12 +45,12 @@ int phi_ref(int x) { return ret; } -vi divisors(int x) { - vi d; +vector divisors(int x) { + vector d; for (int i = 1; 1LL * i * i <= x; i++) { if (x % i) continue; - d.pb(i); - if (i * i != x) d.pb(x / i); + d.push_back(i); + if (i * i != x) d.push_back(x / i); } return d; } diff --git a/tests/8-misc/test_dp_opt.cpp b/tests/8-misc/test_dp_opt.cpp index f9380df..1c8ea3e 100644 --- a/tests/8-misc/test_dp_opt.cpp +++ b/tests/8-misc/test_dp_opt.cpp @@ -13,7 +13,7 @@ ll rnd(ll l, ll r) { void test_cht() { int n = 200, q = 200; - vl m(n), b(n); + vector m(n), b(n); ll cur = 1000; for (int i = 0; i < n; i++) { cur -= rnd(0, 5); @@ -32,13 +32,13 @@ void test_cht() { void test_knuth() { int n = 40; - vl a(n); + vector a(n); for (int i = 0; i < n; i++) a[i] = rnd(0, 10); - vl ps(n + 1, 0); + vector ps(n + 1, 0); for (int i = 0; i < n; i++) ps[i + 1] = ps[i] + a[i]; auto cost = [&](int i, int j) { return ps[j + 1] - ps[i]; }; const ll INF = (1LL << 62); - vvl dp(n, vl(n, 0)); + vector> dp(n, vector(n, 0)); for (int len = 2; len <= n; len++) { for (int i = 0; i + len - 1 < n; i++) { int j = i + len - 1; @@ -56,7 +56,7 @@ void test_knuth() { void test_dnc() { int n = 50, k = 4; - vl base(n, 0); + vector base(n, 0); auto cost = [&](int j, int i) { ll d = i - j; return d * d; @@ -64,7 +64,7 @@ void test_dnc() { dnc_opt dc; dc.run(k, n, base, cost); const ll INF = (1LL << 62); - vvl dp(k + 1, vl(n, INF)); + vector> dp(k + 1, vector(n, INF)); dp[0] = base; for (int g = 1; g <= k; g++) { for (int i = 0; i < n; i++) { @@ -73,17 +73,17 @@ void test_dnc() { } } } - const vl &got = dc.dp(); + const vector &got = dc.dp(); for (int i = 0; i < n; i++) assert(got[i] == dp[k][i]); } -ll slope_naive(const vl &a) { +ll slope_naive(const vector &a) { int n = sz(a); ll mn = *min_element(all(a)) - n; ll mx = *max_element(all(a)) + n; int m = (int)(mx - mn + 1); const ll INF = (1LL << 62); - vl dp_prev(m, INF), dp_cur(m, INF); + vector dp_prev(m, INF), dp_cur(m, INF); for (int v = 0; v < m; v++) dp_prev[v] = llabs(a[0] - (mn + v)); for (int i = 1; i < n; i++) { ll best = INF; @@ -99,7 +99,7 @@ ll slope_naive(const vl &a) { void test_slope_trick() { for (int it = 0; it < 200; it++) { int n = (int)rnd(1, 8); - vl a(n); + vector a(n); for (int i = 0; i < n; i++) a[i] = rnd(-5, 5); assert(slope_trick(a) == slope_naive(a)); } diff --git a/tests/8-misc/test_kitamasa.cpp b/tests/8-misc/test_kitamasa.cpp index db7bf59..88fc9c4 100644 --- a/tests/8-misc/test_kitamasa.cpp +++ b/tests/8-misc/test_kitamasa.cpp @@ -11,16 +11,16 @@ ll rnd(ll l, ll r) { return dis(rng); } -ll naive_rec(const vl &coef, const vl &init, ll n, ll mod) { +ll naive_rec(const vector &coef, const vector &init, ll n, ll mod) { int k = sz(coef); - vl a = init; + vector a = init; if (n < k) return mod_norm(a[n], mod); for (ll i = k; i <= n; i++) { ll v = 0; for (int j = 1; j <= k; j++) { v = mod_norm(v + (__int128)coef[j - 1] * a[i - j], mod); } - a.pb(v); + a.push_back(v); } return a[n]; } @@ -29,7 +29,7 @@ void test_random() { const ll mod = 1000000007LL; for (int it = 0; it < 200; it++) { int k = (int)rnd(1, 6); - vl coef(k), init(k); + vector coef(k), init(k); for (int i = 0; i < k; i++) { coef[i] = rnd(0, mod - 1); init[i] = rnd(0, mod - 1); diff --git a/tests/8-misc/test_lis_in_o_nlogn.cpp b/tests/8-misc/test_lis_in_o_nlogn.cpp index 56cd208..5bd5a7b 100644 --- a/tests/8-misc/test_lis_in_o_nlogn.cpp +++ b/tests/8-misc/test_lis_in_o_nlogn.cpp @@ -11,9 +11,9 @@ ll rnd(ll l, ll r) { return dis(rng); } -int lis_naive(const vl &a) { +int lis_naive(const vector &a) { int n = sz(a); - vi dp(n, 1); + vector dp(n, 1); int best = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < i; j++) { @@ -24,7 +24,7 @@ int lis_naive(const vl &a) { return best; } -bool is_subseq(const vl &a, const vl &b) { +bool is_subseq(const vector &a, const vector &b) { int i = 0, j = 0; while (i < sz(a) && j < sz(b)) { if (a[i] == b[j]) j++; @@ -33,7 +33,7 @@ bool is_subseq(const vl &a, const vl &b) { return j == sz(b); } -bool is_strict_inc(const vl &a) { +bool is_strict_inc(const vector &a) { for (int i = 1; i < sz(a); i++) if (a[i - 1] >= a[i]) return false; return true; @@ -42,11 +42,11 @@ bool is_strict_inc(const vl &a) { void test_random() { for (int it = 0; it < 200; it++) { int n = (int)rnd(1, 60); - vl a(n); + vector a(n); for (int i = 0; i < n; i++) a[i] = rnd(-10, 10); int exp = lis_naive(a); assert(lis_len(a) == exp); - vl seq = lis_seq(a); + vector seq = lis_seq(a); assert(sz(seq) == exp); assert(is_subseq(a, seq)); assert(is_strict_inc(seq)); diff --git a/tests/8-misc/test_simd.cpp b/tests/8-misc/test_simd.cpp index f2a4da9..c1b7859 100644 --- a/tests/8-misc/test_simd.cpp +++ b/tests/8-misc/test_simd.cpp @@ -13,7 +13,7 @@ int rnd_int(int l, int r) { void test_i32() { int n = 257; - vi a(n), b(n), c(n), d(n); + vector a(n), b(n), c(n), d(n); for (int i = 0; i < n; i++) { a[i] = rnd_int(-1000, 1000); b[i] = rnd_int(-1000, 1000); diff --git a/tests/8-misc/test_sqrt_decomposition_mos_algorithm.cpp b/tests/8-misc/test_sqrt_decomposition_mos_algorithm.cpp index 48da46b..022118a 100644 --- a/tests/8-misc/test_sqrt_decomposition_mos_algorithm.cpp +++ b/tests/8-misc/test_sqrt_decomposition_mos_algorithm.cpp @@ -13,7 +13,7 @@ int rnd_int(int l, int r) { void test_distinct() { int n = 200, qn = 200; - vi a(n); + vector a(n); for (int i = 0; i < n; i++) a[i] = rnd_int(0, 30); vector qs(qn); @@ -23,9 +23,9 @@ void test_distinct() { qs[i] = {l, r}; } - vi naive(qn, 0), ans(qn, 0); + vector naive(qn, 0), ans(qn, 0); for (int i = 0; i < qn; i++) { - vi cnt(31, 0); + vector cnt(31, 0); int cur = 0; for (int j = qs[i].fr; j <= qs[i].sc; j++) { if (cnt[a[j]]++ == 0) cur++; @@ -36,7 +36,7 @@ void test_distinct() { mo solver(n); for (int i = 0; i < qn; i++) solver.add_query(qs[i].fr, qs[i].sc, i); - vi cnt(31, 0); + vector cnt(31, 0); int cur = 0; auto add = [&](int idx) { if (cnt[a[idx]]++ == 0) cur++; diff --git a/tests/8-misc/test_system_of_difference_constraints.cpp b/tests/8-misc/test_system_of_difference_constraints.cpp index b9951cd..d536a65 100644 --- a/tests/8-misc/test_system_of_difference_constraints.cpp +++ b/tests/8-misc/test_system_of_difference_constraints.cpp @@ -13,7 +13,7 @@ int rnd_int(int l, int r) { bool has_neg_cycle(int n, const vector> &edges) { const ll INF = (1LL << 60); - vvl d(n, vl(n, INF)); + vector> d(n, vector(n, INF)); for (int i = 0; i < n; i++) d[i][i] = 0; for (auto [u, v, w] : edges) d[u][v] = min(d[u][v], w); for (int k = 0; k < n; k++) { @@ -42,13 +42,13 @@ void test_random() { int v = rnd_int(0, n - 1); ll w = rnd_int(-5, 5); dc.add_le(u, v, w); - edges.pb({u, v, w}); + edges.push_back({u, v, w}); } bool ok = dc.solve(); bool neg = has_neg_cycle(n, edges); assert(ok == !neg); if (ok) { - vl x = dc.val(); + vector x = dc.val(); for (auto [u, v, w] : edges) { assert(x[v] <= x[u] + w); }