/cl-competitive

Common Lisp implementation of algorithms

Primary LanguageCommon Lisp

Common Lisp code collection for competitive programming

Build Status

This code collection is maintained mainly for competitive programming, and partly for just understanding algorithms.

License

The greater part of this library is distributed as public domain, or licensed under either CC0 or the MIT license, whichever gives you the most rights in your legislation. Some code, however, has its specific license (usually because it is a dead copy of other library). For the details, please see the header of each file.

Style

Currently I don't introduce any name spaces (packages) in each file. This is due to the circumstance unique to the competitive programming: one-file-per-submission. It is somewhat troublesome to manage many packages on a single file (especially when modifying inserted code). This style may change in the future, however.

On portability: I try not to abuse non-portable code though I sometimes resort to SBCL's extension and behaviour: e.g. declaration as assertion, bivalent stream, extensible sequence, sb-kernel:%vector-raw-bits and sb-c:define-source-transform. To my knowledge, every competition site adopts SBCL.

Every data structure and algorithm handles a 0-based index and a half-open interval unless otherwise noted.

Test environment

  • SBCL 1.5.5 (x64, linux) — yukicoder's version
  • SBCL 1.3.13 (x64, linux) — CodeChef's version
  • SBCL 1.3.3 (x64, linux) — CS Academy's version
  • SBCL 1.2.4 (x64, linux) — the oldest intallable SBCL

Note that the version of SBCL is 1.1.14 on AtCoder.

Contents

General data structures

General algorithms

Arithmetic and algebra

Real and complex

Bit operations

Graph

Geometry

Pattern matching

I/O

Other utilities

Weird things

  • integer-pack.lisp defstruct-like macro to deal with an integer as a bundle of some slots
  • increase-stack-size.lisp This header runs another SBCL as external process and leaves the entire processing to it. (This ugly hack was invented to increase the stack size of SBCL on contest sites.)
  • self-compile.lisp self-rewriting compilation