Skip to content

Commit

Permalink
More uniform header comments
Browse files Browse the repository at this point in the history
  • Loading branch information
simonlindholm committed Nov 2, 2020
1 parent 6c324e8 commit 89fd4e3
Show file tree
Hide file tree
Showing 39 changed files with 46 additions and 47 deletions.
1 change: 0 additions & 1 deletion content/data-structures/RMQ.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Date: 2015-02-06
* License: CC0
* Source: Folklore
* Status: Tested at Petrozavodsk
* Description: Range Minimum Queries on an array. Returns
* min(V[a], V[a + 1], ... V[b - 1]) in constant time.
* Usage:
Expand Down
4 changes: 2 additions & 2 deletions content/data-structures/SubMatrix.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/**
* Date: 2014-11-28
* Author: Johan Sannemo
* Date: 2014-11-28
* License: CC0
* Source: Folklore
* Status: Tested on Kattis
* Description: Calculate submatrix sums quickly, given upper-left and lower-right corners (half-open).
* Usage:
* SubMatrix<int> m(matrix);
* m.sum(0, 0, 2, 2); // top left 4 elements
* Time: O(N^2 + Q)
* Status: Tested on Kattis
*/
#pragma once

Expand Down
1 change: 1 addition & 0 deletions content/data-structures/UnionFindRollback.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* If undo is not needed, skip st, time() and rollback().
* Usage: int t = uf.time(); ...; uf.rollback(t);
* Time: $O(\log(N))$
* Status: tested as part of DirectedMST.h
*/
#pragma once

Expand Down
4 changes: 2 additions & 2 deletions content/geometry/CirclePolygonIntersection.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* Source: https://github.com/spaghetti-source/algorithm/blob/master/geometry/_geom.cc#L744
* Description: Returns the area of the intersection of a circle with a
* ccw polygon.
* Status: Tested on GNYR 2019 Gerrymandering, stress-tested
* Time: O(n)
*/
* Status: Tested on GNYR 2019 Gerrymandering, stress-tested
*/
#pragma once

#include "../../content/geometry/Point.h"
Expand Down
2 changes: 1 addition & 1 deletion content/geometry/ConvexHull.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Points on the edge of the hull between two other points are not considered part
\includegraphics[width=\textwidth]{content/geometry/ConvexHull}
\vspace{-6mm}
\end{minipage}
* Status: stress-tested, tested with Kattis problems convexhull
* Time: O(n \log n)
* Status: stress-tested, tested with kattis:convexhull
*/
#pragma once

Expand Down
2 changes: 1 addition & 1 deletion content/geometry/DelaunayTriangulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* Description: Computes the Delaunay triangulation of a set of points.
* Each circumcircle contains none of the input points.
* If any three points are collinear or any four are on the same circle, behavior is undefined.
* Status: stress-tested
* Time: O(n^2)
* Status: stress-tested
*/
#pragma once

Expand Down
2 changes: 1 addition & 1 deletion content/geometry/HullDiameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Source: https://codeforces.com/blog/entry/48868
* Description: Returns the two points with max distance on a convex hull (ccw,
* no duplicate/collinear points).
* Status: Stress-tested, submitted on kattis roberthood
* Status: stress-tested, tested on kattis:roberthood
*/
#pragma once
#include "Point.h"
Expand Down
2 changes: 1 addition & 1 deletion content/geometry/InsidePolygon.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
* it returns false for points on the boundary. The algorithm uses
* products in intermediate steps so watch out for overflow.
* Time: O(n)
* Status: stress-tested and Kattis problem pointinpolygon
* Usage:
* vector<P> v = {P{4,4}, P{1,2}, P{2,1}};
* bool in = inPolygon(v, P{3, 3}, false);
* Status: stress-tested and tested on kattis:pointinpolygon
*/
#pragma once

Expand Down
2 changes: 1 addition & 1 deletion content/geometry/LineHullIntersection.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* In the last case, if a corner $i$ is crossed, this is treated as happening on side $(i, i+1)$.
* The points are returned in the same order as the line hits the polygon.
* \texttt{extrVertex} returns the point of a hull with the max projection onto a line.
* Status: stress-tested
* Time: O(\log n)
* Status: stress-tested
*/
#pragma once

Expand Down
2 changes: 1 addition & 1 deletion content/geometry/PolygonArea.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Source: tinyKACTL
* Description: Returns twice the signed area of a polygon.
* Clockwise enumeration gives negative area. Watch out for overflow if using int as T!
* Status: Tested with unitTest, Kattis problems polygonarea and wrapping and UVa Online Judge Problem: 109 - SCUD Busters
* Status: Stress-tested and tested on kattis:polygonarea
*/
#pragma once

Expand Down
2 changes: 1 addition & 1 deletion content/geometry/PolygonCut.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
\includegraphics[width=\textwidth]{content/geometry/PolygonCut}
\vspace{-6mm}
\end{minipage}
* Status: tested but not extensively
* Usage:
* vector<P> p = ...;
* p = polygonCut(p, P(0,0), P(1,0));
* Status: tested but not extensively
*/
#pragma once

Expand Down
2 changes: 1 addition & 1 deletion content/geometry/PolygonUnion.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* Description: Calculates the area of the union of $n$ polygons (not necessarily
* convex). The points within each polygon must be given in CCW order.
* (Epsilon checks may optionally be added to sideOf/sgn, but shouldn't be needed.)
* Status: stress-tested, Submitted on ECNA 2017 Problem A
* Time: $O(N^2)$, where $N$ is the total number of points
* Status: stress-tested, Submitted on ECNA 2017 Problem A
*/
#pragma once

Expand Down
2 changes: 1 addition & 1 deletion content/geometry/SegmentDistance.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ Returns the shortest distance between point p and the line segment from point s
\vspace{-10mm}
\includegraphics[width=\textwidth]{content/geometry/SegmentDistance}
\end{minipage}
* Status: tested
* Usage:
* Point<double> a, b(2,2), p(1,1);
* bool onSegment = segDist(a,b,p) < 1e-10;
* Status: tested
*/
#pragma once

Expand Down
2 changes: 1 addition & 1 deletion content/geometry/SegmentIntersection.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Products of three coordinates are used in intermediate steps so watch out for ov
\begin{minipage}{15mm}
\includegraphics[width=\textwidth]{content/geometry/SegmentIntersection}
\end{minipage}
* Status: Well tested with stress-test and with Kattis problem intersection.
* Usage:
* vector<P> inter = segInter(s1,e1,s2,e2);
* if (sz(inter)==1)
* cout << "segments intersect at " << inter[0] << endl;
* Status: stress-tested, tested on kattis:intersection
*/
#pragma once

Expand Down
2 changes: 1 addition & 1 deletion content/geometry/lineIntersection.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Products of three coordinates are used in intermediate steps so watch out for ov
\begin{minipage}{15mm}
\includegraphics[width=\textwidth]{content/geometry/lineIntersection}
\end{minipage}
* Status: stress-tested, and tested through half-plane tests
* Usage:
* auto res = lineInter(s1,e1,s2,e2);
* if (res.first == 1)
* cout << "intersection point at " << res.second << endl;
* Status: stress-tested, and tested through half-plane tests
*/
#pragma once

Expand Down
2 changes: 1 addition & 1 deletion content/geometry/sideOf.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* License: CC0
* Source:
* Description: Returns where $p$ is as seen from $s$ towards $e$. 1/0/-1 $\Leftrightarrow$ left/on line/right. If the optional argument $eps$ is given 0 is returned if $p$ is within distance $eps$ from the line. P is supposed to be Point<T> where T is e.g. double or long long. It uses products in intermediate steps so watch out for overflow if using int or long long.
* Status: tested
* Usage:
* bool left = sideOf(p1,p2,q)==1;
* Status: tested
*/
#pragma once

Expand Down
4 changes: 1 addition & 3 deletions content/geometry/sphericalDistance.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
* License: CC0
* Source: My geometric reasoning
* Description: Returns the shortest distance on the sphere with radius radius between the points with azimuthal angles (longitude) f1 ($\phi_1$) and f2 ($\phi_2$) from x axis and zenith angles (latitude) t1 ($\theta_1$) and t2 ($\theta_2$) from z axis (0 = north pole). All angles measured in radians. The algorithm starts by converting the spherical coordinates to cartesian coordinates so if that is what you have you can use only the two last rows. dx*radius is then the difference between the two points in the x direction and d*radius is the total distance between the points.
* Status: somewhat tested locally
tested with Kattis problem airlinehub
to be tested with UVa 535
* Status: tested on kattis:airlinehub
*/
#pragma once

Expand Down
4 changes: 2 additions & 2 deletions content/graph/BiconnectedComponents.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
* are at least two distinct paths between any two nodes. Note that a node can
* be in several components. An edge which is not in a component is a bridge,
* i.e., not part of any cycle.
* Time: O(E + V)
* Status: tested during MIPT ICPC Workshop 2017
* Usage:
* int eid = 0; ed.resize(N);
* for each edge (a,b) {
* ed[a].emplace_back(b, eid);
* ed[b].emplace_back(a, eid++); }
* bicomps([\&](const vi\& edgelist) {...});
* Time: O(E + V)
* Status: tested during MIPT ICPC Workshop 2017
*/
#pragma once

Expand Down
2 changes: 1 addition & 1 deletion content/graph/CompressTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* Author: Simon Lindholm
* Date: 2016-01-14
* License: CC0
* Status: Tested at CodeForces
* Description: Given a rooted tree and a subset S of nodes, compute the minimal
* subtree that contains all the nodes by adding all (at most $|S|-1$)
* pairwise LCA's and compressing edges.
* Returns a list of (par, orig\_index) representing a tree rooted at 0.
* The root points to itself.
* Time: $O(|S| \log |S|)$
* Status: Tested at CodeForces
*/
#pragma once

Expand Down
2 changes: 1 addition & 1 deletion content/graph/MinCostMaxFlow.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: Min-cost max-flow. cap[i][j] != cap[j][i] is allowed; double edges are not.
* If costs can be negative, call setpi before maxflow, but note that negative cost cycles are not supported.
* To obtain the actual flow, look at positive values only.
* Status: Tested on kattis mincostmaxflow, stress-tested against another implementation
* Status: Tested on kattis:mincostmaxflow, stress-tested against another implementation
* Time: Approximately O(E^2)
*/
#pragma once
Expand Down
4 changes: 2 additions & 2 deletions content/graph/SCC.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
* Description: Finds strongly connected components in a
* directed graph. If vertices $u, v$ belong to the same component,
* we can reach $u$ from $v$ and vice versa.
* Time: O(E + V)
* Status: Bruteforce-tested for N <= 5
* Usage: scc(graph, [\&](vi\& v) { ... }) visits all components
* in reverse topological order. comp[i] holds the component
* index of a node (a component only has edges to components with
* lower index). ncomps will contain the number of components.
* Time: O(E + V)
* Status: Bruteforce-tested for N <= 5
*/
#pragma once

Expand Down
2 changes: 1 addition & 1 deletion content/graph/WeightedMatching.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Author: Benjamin Qi, Chilli
* Author: Benjamin Qi, chilli
* Date: 2020-04-04
* License: CC0
* Source: https://github.com/bqi343/USACO/blob/master/Implementations/content/graphs%20(12)/Matching/Hungarian.h
Expand Down
2 changes: 1 addition & 1 deletion content/number-theory/CRT.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* \texttt{crt(a, m, b, n)} computes $x$ such that $x\equiv a \pmod m$, $x\equiv b \pmod n$.
* If $|a| < m$ and $|b| < n$, $x$ will obey $0 \le x < \text{lcm}(m, n)$.
* Assumes $mn < 2^{62}$.
* Status: Works
* Time: $\log(n)$
* Status: Works
*/
#pragma once

Expand Down
2 changes: 1 addition & 1 deletion content/number-theory/Eratosthenes.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* License: CC0
* Source: http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
* Description: Prime sieve for generating all primes up to a certain limit. isprime$[i]$ is true iff $i$ is a prime.
* Status: Tested
* Time: lim=100'000'000 $\approx$ 0.8 s. Runs 30\% faster if only odd indices are stored.
* Status: Tested
*/
#pragma once

Expand Down
2 changes: 1 addition & 1 deletion content/number-theory/FastEratosthenes.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Date: 2020-04-12
* License: CC0
* Description: Prime sieve for generating all primes smaller than LIM.
* Status: Stress-tested
* Time: LIM=1e9 $\approx$ 1.5s
* Status: Stress-tested
* Details: Despite its n log log n complexity, segmented sieve is still faster
* than other options, including bitset sieves and linear sieves. This is
* primarily due to its low memory usage, which reduces cache misses. This
Expand Down
2 changes: 1 addition & 1 deletion content/number-theory/ModSum.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*
* \texttt{modsum(to, c, k, m)} = $\sum_{i=0}^{\mathrm{to}-1}{(ki+c) \% m}$.
* \texttt{divsum} is similar but for floored division.
* Status: Tested for |k|,|c|,to,m <= 50, and on "aladin" on kattis.
* Time: $\log(m)$, with a large constant.
* Status: Tested for all |k|,|c|,to,m <= 50, and on kattis:aladin
*/
#pragma once

Expand Down
2 changes: 1 addition & 1 deletion content/numerical/Determinant.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* License: CC0
* Source: folklore
* Description: Calculates determinant of a matrix. Destroys the matrix.
* Status: somewhat tested
* Time: $O(N^3)$
* Status: somewhat tested
*/
#pragma once

Expand Down
2 changes: 1 addition & 1 deletion content/numerical/GoldenSectionSearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
* License: CC0
* Source: Numeriska algoritmer med matlab, Gerd Eriksson, NADA, KTH
* Description: Finds the argument minimizing the function $f$ in the interval $[a,b]$ assuming $f$ is unimodal on the interval, i.e. has only one local minimum. The maximum error in the result is $eps$. Works equally well for maximization with a small change in the code. See TernarySearch.h in the Various chapter for a discrete version.
* Status: tested
* Usage:
double func(double x) { return 4+x+.3*x*x; }
double xmin = gss(-1000,1000,func);
* Time: O(\log((b-a) / \epsilon))
* Status: tested
*/
#pragma once

Expand Down
2 changes: 1 addition & 1 deletion content/numerical/IntDeterminant.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Source: somewhere on github
* Description: Calculates determinant using modular arithmetics.
* Modulos can also be removed to get a pure-integer version.
* Status: bruteforce-tested for N <= 3, mod <= 7
* Time: $O(N^3)$
* Status: bruteforce-tested for N <= 3, mod <= 7
*/
#pragma once

Expand Down
2 changes: 1 addition & 1 deletion content/numerical/IntegrateAdaptive.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
* License: CC0
* Source: Wikipedia
* Description: Fast integration using an adaptive Simpson's rule.
* Status: mostly untested
* Usage:
double sphereVolume = quad(-1, 1, [](double x) {
return quad(-1, 1, [\&](double y) {
return quad(-1, 1, [\&](double z) {
return x*x + y*y + z*z < 1; });});});
* Status: mostly untested
*/
#pragma once

Expand Down
3 changes: 2 additions & 1 deletion content/strings/KMP.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/**
* Author: Johan Sannemo
* Date: 2016-12-15
* License: CC0
* Description: pi[x] computes the length of the longest prefix of s that ends at x, other than s[0...x] itself (abacaba -> 0010123).
* Can be used to find all occurrences of a string.
* Time: O(n)
* Status: Tested on Kattis, stringmatching
* Status: Tested on kattis:stringmatching
*/
#pragma once

Expand Down
2 changes: 1 addition & 1 deletion content/strings/MinRotation.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* Source: https://github.com/stjepang/snippets/blob/master/min_rotation.cpp
* Description: Finds the lexicographically smallest rotation of a string.
* Time: O(N)
* Status: Stress-tested
* Usage:
* rotate(v.begin(), v.begin()+minRotation(v), v.end());
* Status: Stress-tested
*/
#pragma once

Expand Down
2 changes: 1 addition & 1 deletion content/various/DivideAndConquerDP.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* License: CC0
* Source: Codeforces
* Description: Given $a[i] = \min_{lo(i) \le k < hi(i)}(f(i, k))$ where the (minimal) optimal $k$ increases with $i$, computes $a[i]$ for $i = L..R-1$.
* Status: tested on http://codeforces.com/contest/321/problem/E
* Time: O((N + (hi-lo)) \log N)
* Status: tested on http://codeforces.com/contest/321/problem/E
*/
#pragma once

Expand Down
4 changes: 2 additions & 2 deletions content/various/FastInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* Description: Returns an integer. Usage requires your program to pipe in
* input from file. Can replace calls to gc() with getchar\_unlocked() if extra
* speed isn't necessary (60\% slowdown).
* Status: tested on SPOJ INTEST, unit tested
* Time: About 5x as fast as cin/scanf.
* Usage: ./a.out < input.txt
* Time: About 5x as fast as cin/scanf.
* Status: tested on SPOJ INTEST, unit tested
*/
#pragma once

Expand Down
2 changes: 1 addition & 1 deletion content/various/IntervalContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Description: Add and remove intervals from a set of disjoint intervals.
* Will merge the added interval with any overlapping intervals in the set when adding.
* Intervals are [inclusive, exclusive).
* Status: stress-tested
* Time: O(\log N)
* Status: stress-tested
*/
#pragma once

Expand Down
Loading

0 comments on commit 89fd4e3

Please sign in to comment.