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-algorithmsenSat, 24 Feb 2024 18:53:09 -0000Sat, 24 Feb 2024 18:53:09 -00001440MkDocs RSS plugin - v1.12.1Convex 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 +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 Sat, 24 Feb 2024 18:24:11 +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 +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 Fri, 23 Feb 2024 21:31:31 +0000Linear Diophantine Equations<h1>Linear Diophantine Equation</h1><p>A Linear Diophantine Equation (in two variables) is an equation of the general form:</p><p>$$ax + by = c$$</p><p>where $a$, $b$, $c$ are...</p>https://cp-algorithms.com/algebra/linear-diophantine-equation.html Fri, 23 Feb 2024 20:57:36 +0000Search for a pair of intersecting segments<h1>Search for a pair of intersecting segments</h1><p>Given $n$ line segments on the plane. It is required to check whether at least two of them intersect with each ...</p>https://cp-algorithms.com/geometry/intersecting_segments.html Thu, 22 Feb 2024 17:55:40 +0000Stars and bars<h1>Stars and bars</h1><p>Stars and bars is a mathematical technique for solving certain combinatorial problems.It occurs whenever you want to count the number of w...</p>https://cp-algorithms.com/combinatorics/stars_and_bars.html Tue, 20 Feb 2024 18:23:49 +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 Sat, 17 Feb 2024 19:06:14 +0000Fast Fourier transform<h1>Fast Fourier transform</h1><p>In this article we will discuss an algorithm that allows us to multiply two polynomials of length $n$ in $O(n \log n)$ time, which ...</p>https://cp-algorithms.com/algebra/fft.html Sat, 17 Feb 2024 19:04:10 +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, 12 Feb 2024 20:53:53 +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 Sun, 11 Feb 2024 16:00:08 +0000Longest increasing subsequence<h1>Longest increasing subsequence</h1><p>We are given an array with $n$ numbers: $a[0 \dots n-1]$.The task is to find the longest, strictly increasing, subsequence...</p>https://cp-algorithms.com/sequences/longest_increasing_subsequence.html Sat, 10 Feb 2024 08:13:33 +0000Maximum flow - Push-relabel algorithm<h1>Maximum flow - Push-relabel algorithm</h1><p>The push-relabel algorithm (or also known as preflow-push algorithm) is an algorithm for computing the maximum flow ...</p>https://cp-algorithms.com/graph/push-relabel.html Mon, 29 Jan 2024 14:47:56 +0000Introducton 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, 28 Jan 2024 19:51:12 +0000Euler's totient function<h1>Euler's totient function</h1><p>Euler's totient function, also known as <strong>phi-function</strong> $\phi (n)$, counts the number of integers between 1 and $n$ inclusive, w...</p>https://cp-algorithms.com/algebra/phi-function.html Sat, 27 Jan 2024 07:15:28 +0000Minkowski sum of convex polygons<h1>Minkowski sum of convex polygons</h1><h2>Definition</h2><p>Consider two sets $A$ and $B$ of points on a plane. Minkowski sum $A + B$ is defined as ${a + b| a \in A, ...</p>https://cp-algorithms.com/geometry/minkowski.html Fri, 26 Jan 2024 03:52:43 +0000Fenwick Tree<h1>Fenwick Tree</h1><p>Let, $f$ be some group operation (binary associative function over a set with identity element and inverse elements) and $A$ be an array of i...</p>https://cp-algorithms.com/data_structures/fenwick.html Wed, 24 Jan 2024 19:02:09 +0000Sqrt Decomposition<h1>Sqrt Decomposition</h1><p>Sqrt Decomposition is a method (or a data structure) that allows you to perform some common operations (finding sum of the elements of ...</p>https://cp-algorithms.com/data_structures/sqrt_decomposition.html Wed, 24 Jan 2024 08:54:20 +0000Euclidean algorithm for computing the greatest common divisor<h1>Euclidean algorithm for computing the greatest common divisor</h1><p>Given two non-negative integers $a$ and $b$, we have to find their <strong>GCD</strong> (greatest common ...</p>https://cp-algorithms.com/algebra/euclid-algorithm.html Thu, 18 Jan 2024 18:04:20 +0000Maximum flow - Push-relabel algorithm improved<h1>Maximum flow - Push-relabel method improved</h1><p>We will modify the <a href="push-relabel.md">push-relabel method</a> to achieve a better runtime.</p><h2>Description</h2><p>The mo...</p>https://cp-algorithms.com/graph/push-relabel-faster.html Sat, 06 Jan 2024 04:53:25 +0000