Skip to content

Commit 3eeccbd

Browse files
cameroncusterCameron Custer
andauthored
docs: fix wrong examples and time/space claims (#237)
* docs: state unwritten contracts in doc comments * docs: fix wrong examples and time/space claims * docs: remove overflow note from matrix_mult per review --------- Co-authored-by: Cameron Custer <cam@augmentcode.com>
1 parent c3b34f2 commit 3eeccbd

18 files changed

Lines changed: 24 additions & 12 deletions

library/convolution/min_plus_convolution_convex_and_arbitrary.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! @param convex,arbitrary arrays where convex satisfies
33
//! convex[i+1]-convex[i] <= convex[i+2]-convex[i+1]
44
//! @returns array `res` where `res[k]` = the min of
5-
//! (a[i]+b[j]) for all pairs (i,j) where i+j==k
5+
//! (convex[j]+arbitrary[i]) over pairs with i+j==k
66
//! @time O((n + m) log (n + m))
77
//! @space O(n + m)
88
vi min_plus(const vi& convex, const vi& arbitrary) {

library/data_structures_[l,r)/bit.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
//! // sum = a[0] + a[1] + ... + a[r - 1]
66
//! });
77
//! int r = bit.walk2(sum);
8-
//! // Returns min r s.t. sum of [0,r] >= sum
9-
//! // Returns n if sum of [0,n-1] < sum
8+
//! // Returns min r s.t. sum of [0,r+1) >= sum
9+
//! // Returns n if sum of [0,n) < sum
1010
//! // Returns -1 if sum <= 0
1111
//! @endcode
1212
//! @time O(n + q log n)

library/graphs/dijkstra.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//! auto d = dijkstra(g, source);
55
//! @endcode
66
//! d[v] = min dist from source->..->v
7+
//! requires weights >= 0
78
//! @time O(n + (m log m))
89
//! @space O(n + m)
910
vector<ll> dijkstra(const auto& g, int s) {

library/graphs/min_vertex_cover.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
//! auto [mvc_l, mvc_r] = cover(g, r);
1010
//! // mvc_l[u] == 1 iff u in mvc
1111
//! @endcode
12-
//! @time O(n + q * log n)
13-
//! @space O(n * \alpha(n))
12+
//! @time O(n + m)
13+
//! @space O(n)
1414
pair<vi, vi> cover(const vector<vi>& g, vi& r) {
1515
int n = sz(g), t = 0;
1616
vi cl(n), cr(sz(r)), q(n);

library/graphs/uncommon/enumerate_triangles.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
//! //u, v, w form a triangle
66
//! });
77
//! @endcode
8+
//! requires no self loops or multi edges
89
//! @time O(n + m ^ (3/2))
910
//! @space O(n + m)
1011
void enumerate_triangles(const vector<pii>& edges, int n,

library/loops/submasks.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22
//! loops over submasks in decreasing order
3+
//! excludes the empty submask
34
//! @param mask a submask of 2^n-1
45
//! @time O(3^n) to iterate every submask
56
//! of every mask of size n

library/math/derangements.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//! auto der = derangements(n, mod);
55
//! @endcode
66
//! der[i] = number of permutations p with p[i]!=i
7+
//! requires n >= 1
78
//! @time O(n)
89
//! @space O(n)
910
vector<ll> derangements(int n, int mod) {

library/math/matrix_related/row_reduce.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//! columns [0,cols) of mat represent a matrix
77
//! columns [cols,m) of mat are also
88
//! affected by row operations
9+
//! requires mod is prime
910
//! @time O(n * m * min(cols, n))
1011
//! @space O(1)
1112
pii row_reduce(vector<vi>& mat, int cols) {

library/math/mod_division.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//! @code
44
//! int quotient = mod_div(x, y); // returns x * y^-1
55
//! @endcode
6+
//! requires gcd(y, mod) == 1
67
//! @time O(log(y))
78
//! @space O(1)
89
const int mod = 998244353;

library/math/num_distinct_subsequences.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22
//! returns the number of distinct subsequences
3-
//! of a, including the empty subsquence
3+
//! of a, including the empty subsequence
44
//! @time O(n log n)
55
//! @space O(n)
66
int num_subsequences(const vi& a, int mod) {

0 commit comments

Comments
 (0)