Algorithms for Competitive ProgrammingThe goal of this project is to translate the wonderful resource http://e-maxx.ru/algo which provides descriptions of many algorithms and data structures especially popular in field of competitive programming. Moreover we want to improve the collected knowledge by extending the articles and adding new articles to the collection.https://cp-algorithms.com/https://github.com/cp-algorithms/cp-algorithmsenWed, 19 Jun 2024 16:33:07 -0000Wed, 19 Jun 2024 16:33:07 -00001440MkDocs RSS plugin - v1.12.22-SAT<h1>2-SAT</h1><p>SAT (Boolean satisfiability problem) is the problem of assigning Boolean values to variables to satisfy a given Boolean formula.The Boolean formul...</p>https://cp-algorithms.com/graph/2SAT.html Wed, 19 Jun 2024 16:32:34 +0000Navigation<ul><li>Home<ul><li><a href="index.md">Main Page</a></li><li><a href="navigation.md">Navigation</a></li><li><a href="tags.md">Tag index</a></li><li><a href="contrib.md">How to Contribute</a></li><li>[Code of conduct]...</li></ul></li></ul>https://cp-algorithms.com/navigation.html Wed, 19 Jun 2024 16:24:53 +0000Knapsack Problem<h1>Knapsack Problem</h1><p>Prerequisite knowledge: <a href="https://cp-algorithms.com/dynamic_programming/intro-to-dp.html">Introduction to Dynamic Programming</a></p><h2>Introduc...</h2>https://cp-algorithms.com/dynamic_programming/knapsack.html Wed, 19 Jun 2024 16:24:26 +0000Bit manipulation<h1>Bit manipulation</h1><h2>Binary number</h2><p>A <strong>binary number</strong> is a number expressed in the base-2 numeral system or binary numeral system, it is a method of math...</p>https://cp-algorithms.com/algebra/bit-manipulation.html Tue, 18 Jun 2024 16:10:02 +0000Fenwick Tree<h1>Fenwick Tree</h1><p>Let $f$ be some group operation (a binary associative function over a set with an identity element and inverse elements) and $A$ be an array ...</p>https://cp-algorithms.com/data_structures/fenwick.html Tue, 18 Jun 2024 01:10:33 +0000Operations on polynomials and series<h1>Operations on polynomials and series</h1><p>Problems in competitive programming, especially the ones involving enumeration some kind, are often solved by reducin...</p>https://cp-algorithms.com/algebra/polynomial.html Mon, 17 Jun 2024 22:48:19 +0000Checking a graph for acyclicity and finding a cycle in O(M)<h1>Checking a graph for acyclicity and finding a cycle in $O(M)$</h1><p>Consider a directed or undirected graph without loops and multiple edges. We have to check w...</p>https://cp-algorithms.com/graph/finding-cycle.html Mon, 10 Jun 2024 07:23:09 +0000Introduction to Dynamic Programming<h1>Introduction to Dynamic Programming</h1><p>The essence of dynamic programming is to avoid repeated calculation. Often, dynamic programming problems are naturall...</p>https://cp-algorithms.com/dynamic_programming/intro-to-dp.html Sun, 09 Jun 2024 00:24:41 +0000Finding Connected Components<h1>Search for connected components in a graph</h1><p>Given an undirected graph $G$ with $n$ nodes and $m$ edges. We are required to find in it all the connected com...</p>https://cp-algorithms.com/graph/search-for-connected-components.html Sun, 09 Jun 2024 00:14:23 +0000Depth First Search<h1>Depth First Search</h1><p>Depth First Search is one of the main graph algorithms.</p><p>Depth First Search finds the lexicographical first path in the graph from a so...</p>https://cp-algorithms.com/graph/depth-first-search.html Sat, 08 Jun 2024 21:18:51 +0000Finding Bridges Online<h1>Finding Bridges Online</h1><p>We are given an undirected graph.A bridge is an edge whose removal makes the graph disconnected (or, more precisely, increases the...</p>https://cp-algorithms.com/graph/bridge-searching-online.html Wed, 15 May 2024 23:16:08 +0000Finding Bridges in O(N+M)<h1>Finding bridges in a graph in $O(N+M)$</h1><p>We are given an undirected graph. A bridge is defined as an edge which, when removed, makes the graph disconnected ...</p>https://cp-algorithms.com/graph/bridge-searching.html Sat, 04 May 2024 09:10:05 +0000Main Page<h1>Algorithms for Competitive Programming</h1><p>[<img alt="Contributors" src="https://img.shields.io/github/contributors/cp-algorithms/cp-algorithms.svg">](https://github.com/cp...</p>https://cp-algorithms.com/index.html Wed, 17 Apr 2024 23:38:29 +0000Primality tests<h1>Primality tests</h1><p>This article describes multiple algorithms to determine if a number is prime or not.</p><h2>Trial division</h2><p>By definition a prime number does...</p>https://cp-algorithms.com/algebra/primality_tests.html Tue, 16 Apr 2024 21:24:37 +0000Integer factorization<h1>Integer factorization</h1><p>In this article we list several algorithms for the factorization of integers, each of which can be either fast or varying levels of ...</p>https://cp-algorithms.com/algebra/factorization.html Tue, 16 Apr 2024 21:08:03 +0000Aho-Corasick algorithm<h1>Aho-Corasick algorithm</h1><p>The Aho-Corasick algorithm allows us to quickly search for multiple patterns in a text.The set of pattern strings is also called a...</p>https://cp-algorithms.com/string/aho_corasick.html Mon, 25 Mar 2024 14:27:28 +0000The Inclusion-Exclusion Principle<h1>The Inclusion-Exclusion Principle</h1><p>The inclusion-exclusion principle is an important combinatorial way to compute the size of a set or the probability of c...</p>https://cp-algorithms.com/combinatorics/inclusion-exclusion.html Thu, 21 Mar 2024 13:34:12 +0000MEX task (Minimal Excluded element in an array)<h1>MEX (minimal excluded) of a sequence</h1><p>Given an array $A$ of size $N$. You have to find the minimal non-negative element that is not present in the array. T...</p>https://cp-algorithms.com/sequences/mex.html Fri, 08 Mar 2024 14:59:34 +0000Convex hull construction<h1>Convex Hull construction</h1><p>In this article we will discuss the problem of constructing a convex hull from a set of points.</p><p>Consider $N$ points given on a p...</p>https://cp-algorithms.com/geometry/convex-hull.html Sat, 24 Feb 2024 18:50:04 +0000Minimum-cost flow<h1>Minimum-cost flow - Successive shortest path algorithm</h1><p>Given a network $G$ consisting of $n$ vertices and $m$ edges.For each edge (generally speaking, or...</p>https://cp-algorithms.com/graph/min_cost_flow.html Sat, 24 Feb 2024 18:20:48 +0000