Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/contest/random.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! uint64_t x1 = rng();
//! mt19937 rng; // fixed seed for debugging
//! int x2 = rnd(0, 1); //random number in [0,1]
//! ll x3 = rnd(ll(1), ll(1e18));
//! int64_t x3 = rnd(int64_t(1), int64_t(1e18));
//! @endcode
mt19937 rng(
chrono::steady_clock::now().time_since_epoch().count());
Expand Down
2 changes: 1 addition & 1 deletion library/convolution/gcd_convolution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! @code
//! auto gcd_conv = gcd_convolution(a, b);
//! @endcode
//! sz(a)==sz(b)
//! ssize(a)==ssize(b)
//! gcd_conv[k] = sum of (a[i]*b[j])
//! for all pairs (i,j) where gcd(i,j)==k
//! @time O(n log n)
Expand Down
2 changes: 1 addition & 1 deletion library/convolution/lcm_convolution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! @code
//! auto lcm_conv = lcm_convolution(a, b);
//! @endcode
//! sz(a)==sz(b)
//! ssize(a)==ssize(b)
//! lcm_conv[k] = sum of (a[i]*b[j])
//! for all pairs (i,j) where lcm(i,j)==k
//! @time O(n log n)
Expand Down
4 changes: 2 additions & 2 deletions library/convolution/xor_convolution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include "../math/mod_division.hpp"
//! https://codeforces.com/blog/entry/127823
//! @code
//! vi c = xor_conv(a, b);
//! // must have sz(a) == sz(b) == a power of 2
//! vector<int> c = xor_conv(a, b);
//! // must have ssize(a) == ssize(b) == a power of 2
//! // c[k] = sum of a[i]*b[j] where i^j==k
//! @endcode
//! @time O(n log n)
Expand Down
2 changes: 1 addition & 1 deletion library/data_structures_[l,r)/bit.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
//! @code
//! BIT bit(n);
//! bit.walk([&](int r, ll sum) -> bool {
//! bit.walk([&](int r, int64_t sum) -> bool {
//! // sum = a[0] + a[1] + ... + a[r - 1]
//! });
//! int r = bit.walk2(sum);
Expand Down
4 changes: 2 additions & 2 deletions library/data_structures_[l,r)/seg_tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
//! });
//! tree st(n, LLONG_MAX, ranges::min);
//! int m1 = st.max_right(l, r,
//! [&](int m, ll value) -> bool {
//! [&](int m, int64_t value) -> bool {
//! // l < m <= r
//! // value = op(a[l], a[l+1], ..., a[m-1])
//! }); // max m such that f holds; l if none
//! int m2 = st.min_left(l, r,
//! [&](int m, ll value) -> bool {
//! [&](int m, int64_t value) -> bool {
//! // l <= m < r
//! // value = op(a[m], ..., a[r-2], a[r-1])
//! }); // min m such that f holds; r if none
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once
//! @code
//! seg_tree st(n);
//! st.find_first(l, r, [&](ll x, int tl, int tr) ->
//! bool {
//! });
//! st.find_first(l, r,
//! [&](int64_t x, int tl, int tr) -> bool {
//! });
//! @endcode
//! @param l,r defines range [l, r)
//! @param f defines a function that returns 1 if the
Expand Down
6 changes: 3 additions & 3 deletions library/data_structures_[l,r)/seg_tree_uncommon/find_last.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once
//! @code
//! seg_tree st(n);
//! st.find_last(l, r, [&](ll x, int tl, int tr) ->
//! bool {
//! });
//! st.find_last(l, r,
//! [&](int64_t x, int tl, int tr) -> bool {
//! });
//! @endcode
//! @param l,r defines range [l, r)
//! @param f defines a function that returns 1 if the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "wavelet_bit_vec.hpp"
//! https://nyaannyaan.github.io/library/data-structure-2d/wavelet-matrix.hpp
//! @code
//! vector<ll> a(n);
//! vector<int64_t> a(n);
//! wavelet_matrix wm(a, 30); // 0 <= a[i] < (1<<30)
//! wm.kth(l, r, k); //(k+1)th smallest number in [l,r)
//! wm.kth(l, r, 0); //min in [l,r)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! [p[v].mn_idx, p[v].mn_idx+p[v].len) index range
//! [p[v].mn_num, p[v].mn_num+p[v].len) number range
//! indexes [0, n) of ch are leaves
//! indexes [n, sz(ch)) of ch are internal nodes
//! indexes [n, ssize(ch)) of ch are internal nodes
//! @time O(n)
//! @space O(n)
struct perm_tree {
Expand Down
2 changes: 1 addition & 1 deletion library/data_structures_[l,r]/bit.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
//! @code
//! BIT bit(n);
//! bit.walk([&](int r, ll sum) -> bool {
//! bit.walk([&](int r, int64_t sum) -> bool {
//! // sum = a[0] + a[1] + ... + a[r]
//! });
//! int r = bit.walk2(sum);
Expand Down
4 changes: 2 additions & 2 deletions library/data_structures_[l,r]/seg_tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
//! });
//! tree st(n, LLONG_MAX, ranges::min);
//! int m1 = st.max_right(l, r,
//! [&](int m, ll value) -> bool {
//! [&](int m, int64_t value) -> bool {
//! // l <= m <= r
//! // value = op(a[l], a[l+1], ..., a[m])
//! }); // min m such that f fails; r+1 if none
//! int m2 = st.min_left(l, r,
//! [&](int m, ll value) -> bool {
//! [&](int m, int64_t value) -> bool {
//! // l <= m <= r
//! // value = op(a[m], ..., a[r-1], a[r])
//! }); // max m such that f fails; l-1 if none
Expand Down
2 changes: 1 addition & 1 deletion library/dsu/dsu_weighted.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! dsu_weighted dsu(n);
//! dsu.join(u, v, w);
//! // we now know a[u] = a[v] + w
//! ll w = dsu.diff(u, v);
//! int64_t w = dsu.diff(u, v);
//! // satisfies a[u] = a[v] + w based on prior joins
//! @endcode
//! @time O(n + q * \alpha(n))
Expand Down
2 changes: 1 addition & 1 deletion library/dsu/range_parallel_equivalence_classes.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include "dsu.hpp"
//! @code
//! vector<vector<pii>> joins(n + 1);
//! vector<vector<pair<int, int>>> joins(n + 1);
//! joins[len].emplace_back(u, v);
//! // it does:
//! // dsu.join(u + 0, v + 0);
Expand Down
2 changes: 1 addition & 1 deletion library/flow/hungarian.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
//! https://e-maxx.ru/algo/assignment_hungary
//! @code
//! vector cost(n+1,vector(m+1,ll(0)));
//! vector cost(n+1,vector(m+1,int64_t(0)));
//! auto [min_weight, l_to_r] = hungarian(cost);
//! @endcode
//! cost[i][j] = edge weight, 1<=i<=n<=m; 1<=j<=m
Expand Down
10 changes: 5 additions & 5 deletions library/graphs/bcc_callback.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
//! https://cp-algorithms.com/graph/cutpoints.html
//! @code
//! {
//! vector<vi> g(n);
//! vector<vector<int>> g(n);
//! DSU dsu(n);
//! vector<bool> vis(n);
//! bcc(g, [&](const vi& nodes) {
//! bcc(g, [&](const vector<int>& nodes) {
//! int cnt_edges = 0;
//! rep (i, 0, sz(nodes) - 1) {
//! for (int i = 0; i < ssize(nodes) - 1; i++) {
//! vis[nodes[i]] = 1;
//! for (int u : g[nodes[i]]) if (!vis[u]) {
//! // edge nodes[i] <=> u is in current BCC
Expand All @@ -21,7 +21,7 @@
//! for (int u : nodes) dsu.join(u, nodes[0]);
//! });
//! vector<basic_string<int>> bridge_tree(n);
//! rep (i, 0, n)
//! for (int i = 0; i < n; i++)
//! for (int u : g[i])
//! if (dsu.f(i) != dsu.f(u))
//! bridge_tree[dsu.f(i)] += dsu.f(u);
Expand All @@ -30,7 +30,7 @@
//! vector<basic_string<int>> g(n);
//! vector<basic_string<int>> block_vertex_tree(2 * n);
//! int bcc_id = n;
//! bcc(g, [&](const vi& nodes) {
//! bcc(g, [&](const vector<int>& nodes) {
//! for (int u : nodes) {
//! block_vertex_tree[u] += bcc_id;
//! block_vertex_tree[bcc_id] += u;
Expand Down
7 changes: 4 additions & 3 deletions library/graphs/euler_path.hpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#pragma once
//! @code
//! vector<basic_string<array<int, 2>>> g(n);
//! vector<pii> edges(m);
//! rep(i, 0, m) {
//! vector<pair<int, int>> edges(m);
//! for (int i = 0; i < m; i++) {
//! int u, v;
//! cin >> u >> v;
//! u--, v--;
//! g[u] += {v, i};
//! edges[i] = {u, v};
//! }
//! vector<pii> path = euler_path(g, m, source);
//! vector<pair<int, int>> path =
//! euler_path(g, m, source);
//! @endcode
//! @time O(n + m)
//! @space O(n + m)
Expand Down
4 changes: 2 additions & 2 deletions library/graphs/min_vertex_cover.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "../../kactl/content/graph/HopcroftKarp.h"
//! @code
//! int l_sz, r_sz;
//! vector<vi> g(l_sz);
//! vector<vector<int>> g(l_sz);
//! g[u].push_back(v); // 0 <= u < l_sz, 0 <= v < r_sz
//! vi r(r_sz, -1);
//! vector<int> r(r_sz, -1);
//! int match_sz = hopcroftKarp(g, r);
//! // r[v] != -1 iff edge r[v] <-> v in matching
//! auto [mvc_l, mvc_r] = cover(g, r);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//!
//! @code
//! auto [num_sccs, scc_id] = scc(g);
//! vector<pii> edges = extra_edges(g,
//! vector<pair<int, int>> edges = extra_edges(g,
//! num_sccs, scc_id);
//! @endcode
//! @param g,num_sccs,scc_id directed graph and its SCCs
Expand Down
2 changes: 1 addition & 1 deletion library/graphs/uncommon/bridges.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! https://cp-algorithms.com/graph/bridge-searching.html
//! @code
//! vector<basic_string<array<int, 2>>> g(n);
//! rep (i, 0, m) {
//! for (int i = 0; i < m; i++) {
//! int u, v;
//! cin >> u >> v;
//! u--, v--;
Expand Down
2 changes: 1 addition & 1 deletion library/graphs/uncommon/complement_graph_ccs.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
//! @code
//! vector<basic_string<int>> g;
//! vi cc_id = get_complement_graph_ccs(g);
//! vector<int> cc_id = get_complement_graph_ccs(g);
//! @endcode
//! 0<=cc_id[v]<number of connected components
//! in the complement graph
Expand Down
2 changes: 1 addition & 1 deletion library/graphs/uncommon/cuts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! https://cp-algorithms.com/graph/cutpoints.html
//! @code
//! vector<basic_string<array<int, 2>>> g(n);
//! rep (i, 0, m) {
//! for (int i = 0; i < m; i++) {
//! int u, v;
//! cin >> u >> v;
//! u--, v--;
Expand Down
3 changes: 2 additions & 1 deletion library/math/count_paths/count_paths_triangle.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#pragma once
#include "count_paths_rectangle.hpp"
//! https://noshi91.hatenablog.com/entry/2023/07/21/235339
//! @time O((n + m)log^2(n + m)): n = sz(h); m = h.back()
//! @time O((n + m)log^2(n + m)):
//! n = ssize(h); m = h.back()
//! @space O(n + m)
vl divide_and_conquer(vl h, vl bottom) {
{
Expand Down
2 changes: 1 addition & 1 deletion library/math/fibonacci.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! https://codeforces.com/blog/entry/14516
//! https://cp-algorithms.com/algebra/fibonacci-numbers.html#fast-doubling-method
//! @code
//! ll num = fib(n)[0];
//! int64_t num = fib(n)[0];
//! //n=0 -> num=0
//! //n=1 -> num=1
//! //n=2 -> num=1
Expand Down
3 changes: 2 additions & 1 deletion library/math/matrix_related/xor_basis_unordered.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
//! properties:
//! - shrink(v) == shrink(shrink(v))
//! - for x in b: (bit_floor(x) & shrink(v)) == 0
//! - for 0 <= i < j < sz(b): (bit_floor(b[i]) & b[j]) == 0
//! - for 0 <= i < j < ssize(b):
//! (bit_floor(b[i]) & b[j]) == 0
//! @time O(32)
//! @space O(32)
struct basis {
Expand Down
3 changes: 2 additions & 1 deletion library/monotonic_stack/monotonic_range.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#pragma once
#include "monotonic_stack.hpp"
//! @code
//! vi le = mono_st(a, less()), ri = mono_range(le);
//! vector<int> le = mono_st(a, less()),
//! ri = mono_range(le);
//! // less_equal(), greater(), greater_equal()
//! @endcode
//! when cmp == less():
Expand Down
2 changes: 1 addition & 1 deletion library/monotonic_stack/monotonic_stack.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
//! @code
//! vi le = mono_st(a, less());
//! vector<int> le = mono_st(a, less());
//! // less_equal(), greater(), greater_equal()
//! @endcode
//! when cmp == less():
Expand Down
4 changes: 2 additions & 2 deletions library/strings/kmp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
//! string s,t;
//! KMP kmp(t);
//! auto match = kmp.find_str(s);
//! vi s_vec,t_vec;
//! vector<int> s_vec,t_vec;
//! KMP kmp1(t_vec);
//! auto match2 = kmp1.find_str(s_vec);
//! @endcode
//! if match[i] == 1 then s[i,sz(t)) == t
//! if match[i] == 1 then s[i,ssize(t)) == t
//! @time O(|s| + |t|)
//! @space O(|s| + |t|)
// NOLINTNEXTLINE(readability-identifier-naming)
Expand Down
7 changes: 4 additions & 3 deletions library/strings/longest_common_subsequence/lcs_queries.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
#include "lcs_dp.hpp"
//! @code
//! string s,t;
//! vi lcs_len = lcs_queries(s, t, queries);
//! vi s_vec,t_vec;
//! vi lcs_len1 = lcs_queries(s_vec, t_vec, queries);
//! vector<int> lcs_len = lcs_queries(s, t, queries);
//! vector<int> s_vec,t_vec;
//! vector<int> lcs_len1 =
//! lcs_queries(s_vec, t_vec, queries);
//! @endcode
//! lcs_len[i] = size(LCS(
//! s[0,queries[i][0]),
Expand Down
2 changes: 1 addition & 1 deletion library/strings/manacher/manacher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! @code
//! string s;
//! auto man = manacher(s);
//! vi s_vec;
//! vector<int> s_vec;
//! auto man1 = manacher(s_vec);
//! @endcode
//!
Expand Down
2 changes: 1 addition & 1 deletion library/strings/suffix_array/find/find_string_bs.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
//! https://github.com/yosupo06/Algorithm/blob/master/src/string/suffixarray.hpp
//! returns range [l,r) such that:
//! - for all i in [l,r): t==s.substr(sa[i],sz(t))
//! - for all i in [l,r): t==s.substr(sa[i],ssize(t))
//! - `r-l` is the # of matches of t in s.
//! @time O(|t| * log(|s|))
//! @space O(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//! substrs.back()[0])
//! - doesn't work when substrs[i][0] == n
//! @returns see match
//! @time O(sz(substrs) * log(|s|))
//! @time O(ssize(substrs) * log(|s|))
//! @space O(1)
match find_substrs_concated(const vector<pii>& substrs) {
using dt = array<int, 3>;
Expand Down
2 changes: 1 addition & 1 deletion library/strings/suffix_array/find/match.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
//! for all i in [sa_le,sa_ri):
//! - t==s.substr(sa[i],sz(t))
//! - t==s.substr(sa[i],ssize(t))
//! - `sa_ri-sa_le` is the # of matches of t in s.
//!
//! if sa_le==sa_ri then:
Expand Down
2 changes: 1 addition & 1 deletion library/strings/suffix_array/suffix_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
//! // requires 0<=s[i]<max_num
//! string s;
//! auto [sa, sa_inv, lcp] = get_sa(s, 256);
//! vi s_vec;
//! vector<int> s_vec;
//! auto [sa1, sa_inv1, lcp1] = get_sa(s_vec, 100'001);
//! @endcode
//!
Expand Down
2 changes: 1 addition & 1 deletion library/strings/suffix_array/suffix_array_query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//! string s;
//! auto [sa, sa_inv, lcp] = get_sa(s, 256);
//! sa_query saq(s, sa, sa_inv, lcp);
//! vi s_vec;
//! vector<int> s_vec;
//! auto [sa1, sa_inv1, lcp1] = sa_short(s_vec);
//! sa_query saq1(s_vec, sa1, sa_inv1, lcp1);
//! @endcode
Expand Down
2 changes: 1 addition & 1 deletion library/strings/suffix_array/suffix_array_short.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! // requires s[i]>=0
//! string s;
//! auto [sa, sa_inv, lcp] = sa_short(s);
//! vi s_vec;
//! vector<int> s_vec;
//! auto [sa1, sa_inv1, lcp1] = sa_short(s_vec);
//! @endcode
//! about 2-3x slower than KACTL
Expand Down
Loading
Loading