Skip to content

Commit c59a2be

Browse files
author
Cameron Custer
committed
docs: state unwritten contracts in doc comments
1 parent c3b34f2 commit c59a2be

13 files changed

Lines changed: 15 additions & 2 deletions

File tree

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/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/matrix_mult.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22
//! https://codeforces.com/blog/entry/80195
3+
//! watch for overflow if T is an integer type
34
//! @time O(n * m * inner)
45
//! @space O(n * m)
56
template<class T>

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/strings/binary_trie.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
//! bt.update(num, 1); // insert
55
//! bt.update(num, -1); // erase
66
//! @endcode
7+
//! requires 0 <= num < 2^61
8+
//! walk requires a non-empty trie
79
//! @time O(q * mx_bit)
810
//! @space O(q * mx_bit)
911
const ll mx_bit = 1LL << 60;

library/strings/kmp.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
//! auto match2 = kmp1.find_str(s_vec);
1010
//! @endcode
1111
//! if match[i] == 1 then s[i,ssize(t)) == t
12+
//! requires t non-empty
1213
//! @time O(|s| + |t|)
1314
//! @space O(|s| + |t|)
1415
// NOLINTNEXTLINE(readability-identifier-naming)

library/trees/centroid_decomp.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//! vector<basic_string<int>> g(n);
55
//! vector<int> p = cd(g, [&](int c) {});
66
//! @endcode
7+
//! g is mutated (edges removed)
78
//! @time O(n log n)
89
//! @space O(n)
910
vi cd(auto& g, auto f) {

0 commit comments

Comments
 (0)