Giter VIP home page Giter VIP logo

ojlibs's Introduction

OJLIBS

C++ Utility library for competitive programming. Fully C++17 compatible.

Permit to use under MIT License.

Additionally, anybody can submit code that contains any part of this library to online judging platforms, if the usage can be restricted in online judging only.

(e.g. If someone can get submitted code on an OJ, and then use it outside the OJ legally according to the OJ's term of service, the usage of this library is forbidden.)

Scope

  • Submit a single C++ file to online judging platform. Target environments are Codeforces, Atcoder and Google Code Jam (stack size >= 64M, source code size limit >= 64KB, support most c++17 features, at least O2 optimization level). ojlibs_cpp script can be used to combine headers, remove comments, put library code to global namespace, and produce a single file.
  • as a header-only library, all components are in ojlibs namespace, and only depends on standard library.

Design Considerations

Readability first, Performance second, Source Code Size third.

Header Only.

Modern C++. Use standard library whenever possible. Depend on template heavily.

Trust compiler instead of hand-tuning.

About moving to C++17

This library adopts c++17 futures to reduce template boilerplate.

When c++20 is widely available, we will switch to c++20.

Old c++11 version of this library can be found at c++11 branch.

Components

Intrusive Data structures

list : doubly-linked list

slist: singly-linked list

rbtree: red-black tree

splay: a splay tree with subtree size to support fast n-th query

treap, sbtree, link-cut tree. (TODO)

Special Data structures

Disjoint Set

Bit Index Tree (a.k.a Fenwick Tree)

Segment Tree (flavour I/II, and lazy)

Arithmatic

Division with fixed rounding direction

GCD / LCM

Extended Euclid Algorithm

Modular Arithmatic

Chinese Remainder Theorem

Bignum

PELL equation (python source)

Mathematics Objects

Permutaion, Combination, Subset (and generators)

Mobius Inversion

Subset Inversion

Multiprecision (bignum)

FFT, FWT.

NTT (TODO)

Linear Algebra

Matrix over a ring / field, Arithmatics, Inversion, Determinant

(P)LU decomposition

Computational Geometry

2D geometry (point, line, circle, convex hull, half-planes intersection, closest point pair)

Geometry Transform (TODO)

String Processing

KMP

Z-Function

Suffix Array (TODO: SA-IS algorithm, linear time construction)

AC-Automaton

Lexicographically least string of all rotations of a given string

Graph Theory

Generic graph algorithms (inspired by boost graph library. all vertex or edge attributes are stored externally, and algorithms depends on graph concept, not graph implementation)

DFS / BFS

Shortest Path (Dijkstra, Bellman-Ford, Floyd-Warshall)

Strongly Connected Component

Topological Sort (on DAG)

Offline Tarjan LCA (on rooted/rootless tree)

Cut-vertex in undirected graph (Tarjan)

Network Flow (Dinic)

Maximum Bipartitie Matching (Hungarian / Kuhn-Munkres)

Eular Walk (TODO : support removing edge in graph)

reusable Centroid Decomposition (TODO)

MISC

Generic memorization function without virtual function overhead (Useful for top-down dynamic programming.)

High-dimension pre-order problem (CDQ algorithm)

2SAT

FAST IO

// A + B problem
int main() {
    int a, b; fin, a, b;
    fout, a + b, endl;
}

TOOLS

  • Codeforces sample test cases crawler, and automatic validation script. (tools/cf_test_crawler)

  • A tool that can combine source code with included header files of this library to produce a single source file to submit. (tools/ojlibs_cpp)

  • Solution Template : main.cpp, check.sh, interactive.sh and Makefile (src/)

# Download test cases
$ cf_test_crawler -p 123 A
# Check program
$ make check

ojlibs's People

Contributors

georeth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

strikew

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.