A personal C++ library for competitive programming.
- C++20 or later
- GCC
- Windows for the helper tools in
bin/
sponge_library/
├── build.bat
├── README.md
├── LICENSE
├── include/
│ └── sponge/
├── src/
│ ├── compile.cpp
│ ├── run.cpp
│ └── expander.cpp
└── bin/
├── compile.exe
├── run.exe
└── expander.exe
The library contains implementations of commonly used algorithms and data structures, including graph algorithms, flows, segment trees, trees, modular arithmetic, matrices, polynomials, strings, and more.
Add include/ to the compiler's include path:
g++ main.cpp -std=c++20 -O2 -I/path/to/sponge_library/includeThen include the modules you need:
#include <sponge/core.hpp>
#include <sponge/segtree.hpp>
#include <sponge/modint.hpp>
using namespace sponge;Or simply include the whole library:
#include <sponge/all.hpp>
using namespace sponge;Prebuilt Windows executables are available in bin/.
It is recommended to add sponge_library/bin to PATH so that the tools can be used directly from anywhere.
The helper tools can be built from source using build.bat:
build.batThis compiles compile, run, and expander from the sources in src/ and places the resulting executables in bin/.
A GCC toolchain with g++ available in PATH is required.
compile is a small wrapper around g++ for quickly compiling competitive programming code.
compile main.cppThe .cpp extension can be omitted:
compile mainIt automatically locates ../include relative to compile.exe, so the library can be moved without modifying any absolute paths.
Additional arguments are passed to g++:
compile main -DDEBUGThe resulting executable is written next to the source file.
run is used to quickly execute a compiled solution.
run mainIt is intended for convenient local testing during competitive programming.
expander expands #include <sponge/...> directives recursively and produces a standalone source file suitable for submission to online judges.
expander main.cppUse
expander --helpfor all available options.
Write a solution using Sponge Library:
#include <sponge/all.hpp>
using namespace sponge;
int main()
{
// ...
}Compile it:
compile mainTest it locally:
run mainBefore submitting, expand the library headers:
expander main.cppThis project is licensed under the MIT License.