This is my C++ algorithms library that I use for programming contests. It is currently a WIP since I am in the process of rewriting my old algorithms library. Note that some of this code is copied/adapted from other sources. I have tried to link the source within the code if not original.
-
Template : Has defines, typedefs and includes assumed for all algorithms
-
Combinatorics *
-
Data Structures
- Disjoint Set Union (DSU)
- Lazy Segment Tree
- Segment Tree
- Sparse Table
-
Dynamic Programming
- Convex Hull Trick (Line Container)
- SOS Convolutions
-
Geometry *
-
Graphs
- Centroid Decomposition
- Dijkstra
- Minimum Diameter Spanning Tree (MDST)
- 2SAT
- LCA (Binary Lifting)
- Strongly Connected Components
-
Linear Algebra
- Xor Basis
-
Number Theory *
-
Strings
- Prefix Function
- Rolling Hash
- Suffix Array
- Z Function
- Articulation Points and Bridges
- Biconnected Components and Block-Cut Tree
- Strongly Connected Components
- Topological Sort
- Least Common Ancestor (Binary Lifting)
- Chinese Remainder Theorem
- Modular Inverse, Exponentiation, Choose, Factorials
- Bellman-Ford
- Floyd Warshall
- KMP Automaton
- Montgomery Multiplication
- Moore's Voting Algorithm
- Mo's Algorithm
- Linear Sieve, Query Sieve
- Prim
- Kruskal
- Rerooting DP
- Trie
- Convex Hull
- Miller Rabin
- Pollard Rho
- Tonelli-Shanks
- Discrete Log (Baby Step Giant Step)
- Polynomial Library
- Modular Integer Library
- Big Integer Library
- Lagrange Multipliers (Alien's Trick)
- Euler Tour/Cycle (Hierholzer)
- Manacher's Algorithm
- Aho-Corasick
- Polar Sorting
- Segment/Line Intersections
- Nim Multiplication and Sprague-Grundy stuff?
- Binary GCD Algorithm