My code library for competitive programming.
powered by competitive-verifier/competitive-verifier & Tiphereth-A/TINplate.
Documentation Site
·
Report Bug & Request Feature
·
Latest Release
·
Citation File
CP-lib is a header-only C++ code library designed for competitive programming with 450+ implementations of algorithms and data structures commonly used in competitive programming contests.
The repository solves several key problems for competitive programmers:
Requirements:
The project uses Python for management scripts. Install dependencies using uv.
Optional dependency groups:
pycodestyle)pygments for syntax highlighting)competitive-verifier)oj-bundle for submitting to OJs (online-judge-verify-helper)For LaTeX compiling:
make download-fonts to download required fonts (see .github/workflows/verify.yml)# Clone the repository
git clone -c core.symlinks=true [email protected]:Tiphereth-A/CP-lib.git
cd CP-lib
# Install Python dev dependencies
uv sync --frozen --group dev
uv run pre-commit install
# Install Python dependencies
uv sync --frozen
# Install verify group for using `oj-verify` if needed
uv sync --frozen --group verify
# Install bundle group for using `oj-bundle` if needed
# Warning: NEVER use `oj-verify` from `online-judge-verify-helper`
uv sync --frozen --group bundle
# Verify installation
python3 manager.py --help
# Run all C++ benchmarks locally (writes .cp-lib/benchmark_result.json)
python3 manager.py benchmark
The manager.py script provides several commands for managing the repository, see python manager.py --help for details.
Q: How can I submit the code using headers of this repo to any OJ
A: Use oj-bundle to auto-expansion your code, it has been included in verify group of Python dependencies already.
You can also find a bundled button at any code pages of documentation site, click the button then you will get the expanded code.
Q: PDF generation is slow
A: This is normal for large LaTeX documents, the expected time used in PDF generation is about 6 minutes in GitHub Action.
This library is verified against problems from:
Thank you to all contributors who have helped improve this library! See the Contributors page.
This library is inspired by and builds upon the work of the competitive programming community, including:
See notebook.bib for details.
If you use this library in academic work, please cite it using the provided CITATION.bib file.