About • Getting Started • Milestones
This is my personal C++ library designed specifically for competitive programming. It contains a variety of data structures, algorithms, and other utilities commonly used in competitive programming. Each component of this library is designed to be drop-in usable—no setup or external dependencies required. The entire library is designed to have sections that are copy-pasteable into a single file for contest submission.
Since the core idea of this library is to copy-paste sections from it into your own code I recommend keeping a local copy of the library in an easy to access location:
git clone https://github.com/BrandonPacewic/CompetitiveProgramming
From there you can:
- Directly copy code from
cpl/inc
andcpl/src
into your own code. - Include them locally in your own code for local practice.
- Test against the provided test cases in
test/
for your own algorithm development.
Note
Additional instructions and support for importing the library and using the test cases is planned to be added in the future.
As with every single one of my projects, this is still very much a work in progress. The following is a list of goals I have for this project before I consider it to be complete, in no particular order:
# | Goal | Status |
---|---|---|
1 | Refactor old code to match current standards | |
2 | Full test coverage | |
3 | Performance with supporting benchmarks | |
4 | Codebase Atomizer | ❌ |
5 | Full implementation of the CPH | ❌️ |
A more detailed description of each goal can be found below:
This is my longest standing project in terms of the initial creation date. As such, the earlier code does not reflect my current standards. One of the current goals is to revise such code to improve quality.
Note
I find the structure of the code in this repository to be quite volatile. I have probably re-written some of the algorithms 10+ times as this library tends to evolve as I become a better programmer. If something doesn't look quite right, it probably isn't.
While this library is meant for competitive programming (where tests don’t carry over), it should still have full test coverage — including tests derived from problems where I used components of this library to solve them.
In the spirit of competitive programming, while solving the problem is the main goal, performance is also a key component. Benchmarks should back up various design decisions when it comes to how I have chosen to structure and implement various key algorithms and data structures.
Note
While I do want 100% test coverage, I'm less concerned about benchmarks. Benchmarks will be added as I find them necessary to support design decisions.
The Atomizer is a tool used to break down the codebase into smaller, more manageable pieces, that can be
retrieved quickly. For example, if you want to use a specific function, say output_container
to keep things
simple. You can use the Atomizer output to retrieve that specific function via a file lookup, output_container.cpp
.
You can also use any supporting tool you want to paste that file buffer directly inline into your code. Rather than
opening the container header file and copying the specific lines from the file that you need. This will also work
with more complex algorithms that may require an additional data structure to function. For example, if you want to
use Kruskal's algorithm, you can use the Atomizer to retrieve the kruskal.cpp
file which will include the
supporting DisjointSet
class used within the algorithm. Again saving you from finding the specific lines of code
within the header file that you need.
The Competitive Programming Handbook by Antti Laaksonen is an awesome, all in one, resource for everything competitive programming. It contains everything from compiling and reading input to sweep line algorithms including convex hulls. Its an eventual goal of mine to fully implement all the algorithms outlined in the book. This has the added benefit of an complete documentation source of all the algorithms in this library. This is a long term goal and will likely take a while to complete.
Note
This is my endgame for this project. When its completed I will consider this project done as so far as it will no longer be a major work in progress for me personally. I will still add things here and there and work on it when I'm compelled to do so but the core goals of this project will be officially complete.
Copyright (c) Brandon Pacewic
SPDX-License-Identifier: MIT