icpc-algorithm-template
I built this C++ reference with Codex while preparing for ICPC and CCPC. It brings implementations, notes on where they break, tests, and a printable handbook into one place. My team earned bronze at the 2026 CCPC Leshan contest. This English page is a guide to the library; the full file-by-file catalog is in Chinese.
What’s in it
The catalog contains 196 C++ template files. Here is the chapter breakdown.
| Chapter | Files | Examples |
|---|---|---|
| Basics and techniques | 14 | Monotonic stacks and queues, two pointers, bit operations, multidimensional differences |
| Data structures | 38 | Segment trees, link-cut trees, wavelet trees, rollback DSU |
| Strings | 15 | KMP, Aho–Corasick, suffix structures, palindromic trees |
| Graph theory | 48 | Shortest paths, tree algorithms, matching, flows, Steiner trees |
| Mathematics | 39 | Number theory, combinatorics, matrices, polynomials, simplex |
| Dynamic programming | 18 | Knapsack, tree DP, digit DP, bitmask DP, Slope Trick |
| Search | 8 | DFS and BFS, meet-in-the-middle, A*, IDA*, DLX |
| Computational geometry | 13 | Convex hulls, half-plane intersection, circles, Minkowski sums |
| Implementation and debugging | 3 | Performance measurement, random tests, and interactive I/O |
Using and testing a template
Most files have no main. Take the module you need and check its indexing, capacity, initialization, modulus, and dependencies. Several files reuse global names, so combining whole directories into one program can cause conflicts. The source notes are in Chinese, and some modules use GNU C++ extensions.
The test suite has 190 C++ entry points that include the actual templates. It checks boundary cases, compares against independent implementations, and runs randomized tests. The LaTeX handbook shares the same code and text and uses a two-column A4 layout.
Repository and full file index · Complete file-by-file catalog in Chinese