Giter VIP home page Giter VIP logo

ccptl's Introduction

CCPTL

CodeISM Competitve Programming Template Library

Aim

The aim of this repository is to provide copy-pastable code snippets. Focus is more on efficiency/performance as opposed to readability.

Usage

Code snippets in a file are meant to be self sufficient.

Note: A modern C++ compiler with support of c++14 or later is required although most the files might work with lower versions too. Code is gauranteed to work with GCC/LLVM (Clang) toolchain but most of the code is portable across compilers and architectures.

Directory

Data Structures

  • BIT/Fenwick Tree: Supports prefix queries and point update in O(log N) after taking O(N) time to build with O(N) space.
  • Min Deque: Finding minimum element out of current element in the deque. Overhead of one integer per element, but is quite space efficient in practice.
  • Ordered set: Dyanmic Order statistics in O(log N). Uses GNU's policy based data structure (pbds).
  • Sparse Table: Static data structure that can answer queries in O(1) after O(NlogN) preprocessing (for some functions).
  • DSU/Union-Find: Works in O(alpha(N)) and uses union by size heuristics.

Graph

  • 2-SAT: solves 2-SAT problem in O(#boolean variables + #clauses) with CNF based formulation.
  • DSU on tree: In O(NlogN) answer all queries of type: How many vertices in the subtree of vertex v has some property?.

LCA

Math

Number Theory

Linear Algebra

  • Matrix: highly optimized: multiplication, exponentiation, transpose including versions with modular arithmetic.

Dynamic Programming

String Algorithms

Misc

  • Modular Arithmetic: A convenient and efficient wrapper of plain int for modular arithmetic. Functionality provided: add, subtract, multiply, divide, exponentiation, inverse and IO.
  • Ska Sort: A much faster (2x w.r.t. std::sort) sorting algorithm.
  • All Permutations: Generate all permutations of a sequence (iterative) in some order (not lexicographic).
  • N-D vector: A less cumbersome declarator of next N-Dimensional std::vector.

TODO

  • Update this readme with new (updated) content
  • Test the implementation for bugs

Authorship

Many of the implementations are common in folklore of competitive programming and the authour is unknown. Whenever possible author of the code is added. Kindly contact us in case of any issues.

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.