Skip to content

Latest commit

 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sponge Library

A personal C++ library for competitive programming.

Requirements

  • C++20 or later
  • GCC
  • Windows for the helper tools in bin/

Structure

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.

Usage

Add include/ to the compiler's include path:

g++ main.cpp -std=c++20 -O2 -I/path/to/sponge_library/include

Then 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;

Tools

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.

Building Tools

The helper tools can be built from source using build.bat:

build.bat

This 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

compile is a small wrapper around g++ for quickly compiling competitive programming code.

compile main.cpp

The .cpp extension can be omitted:

compile main

It 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 -DDEBUG

The resulting executable is written next to the source file.

run

run is used to quickly execute a compiled solution.

run main

It is intended for convenient local testing during competitive programming.

expander

expander expands #include <sponge/...> directives recursively and produces a standalone source file suitable for submission to online judges.

expander main.cpp

Use

expander --help

for all available options.

Typical Workflow

Write a solution using Sponge Library:

#include <sponge/all.hpp>
using namespace sponge;

int main()
{
    // ...
}

Compile it:

compile main

Test it locally:

run main

Before submitting, expand the library headers:

expander main.cpp

License

This project is licensed under the MIT License.

About

A personal C++ library for competitive programming.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages