Skip to content
sgtlaughPublic

About

Algorithms and templates for competitive programming

Topics

Resources

Contributing

Stars

101 stars

Watchers

3 watching

Forks

Repository files navigation

Algovault

Algorithms, data structures and templates for competitive programming

CI license

  • A black box you can copy easily: simple, fast, and well-tested
  • C++17 for GCC, with a few in Python 3 that mostly run on PyPy too
  • Built for contests like Codeforces, AtCoder and ICPC

How To Use

  1. Copy a file into your solution, every C++ file compiles on its own
  2. Delete its main(), which only holds self-tests and a worked example
  3. Read the header at the top for the API, complexity and limits

For example, a Suffix Automaton answers substring questions in three calls:

SuffixAutomaton<> sa("banana");

sa.distinct_substrings();   // 15
sa.occurrences("ana");      // 2, overlapping
sa.contains("nab");         // false

Index

  • ✔ marks a template that passes a judge test, and links to one
  • ✔ next to a practice problem links an accepted solution built on the template, kept in practice/
Topics
Algebra Combinatorics Data Structures Dynamic Programming Geometry
Graphs Linear Algebra Number Theory Numerical Strings
Trees
More
Hacking Miscellaneous Python

Topics

Algebra

Practice problems

Combinatorics

Practice problems

Data Structures

Practice problems

Dynamic Programming

Practice problems

Geometry

Practice problems

Graphs

Practice problems

Linear Algebra

Practice problems

Number Theory

Practice problems

Numerical

Practice problems

Strings

Practice problems

Trees

Practice problems

More

Hacking

Practice problems

Miscellaneous

Practice problems

Python

Practice problems

Testing

Every template is checked four ways:

Layer Where Checks
Self-tests main() in each file Usage examples with known answers
Stress tests stress_tests/ Random inputs against an independent brute force
Repo checks run_tests.sh Every file has a stress test and an index entry, consistent style
Judge tests judge_tests/ Official Library Checker and Aizu test data at full size

How tests build

  • Self and stress tests: GCC 14
    • -fsanitize=address,undefined: AddressSanitizer and UndefinedBehaviorSanitizer
    • an 8 MB stack, as on most judges
    • -Werror: warnings as errors
  • Judge tests: -O2, like a judge

When they run

  • Every push: the self, stress and judge tests of the files it changes, plus the repo checks
  • Every night: all self and stress tests, then the stress tests again at 20x the iterations with a fresh seed
  • Every week: all judge tests from scratch

The commands to run everything locally are in CONTRIBUTING.md.

Contributing

  • Bug reports, fixes and new templates are welcome as issues or pull requests, see CONTRIBUTING.md for the conventions and the checks CI runs
  • The skills in .claude/skills/ apply them:
    • /crucible adds or refactors a template
    • /lucid keeps the docs consistent

License

MIT, see LICENSE

About

Algorithms and templates for competitive programming

Topics

Resources

Contributing

Stars

101 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages