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-algorithmsenMon, 29 Dec 2025 19:18:53 -0000Mon, 29 Dec 2025 19:18:53 -00001440MkDocs RSS plugin - v1.17.7NoneAlgorithms for Competitive Programming https://cp-algorithms.com/ Longest 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/dynamic_programming/longest_increasing_subsequence.html Mon, 25 Aug 2025 06:45:10 +0000Algorithms for Competitive Programminghttps://cp-algorithms.com/dynamic_programming/longest_increasing_subsequence.htmlMinimum Enclosing Circle<h1>Minimum Enclosing Circle</h1> <p>Consider the following problem:</p> <p>!!! example "[Library Checker - Minimum Enclosing Circle](https://judge.yosupo.jp/problem/minimu...</p> https://cp-algorithms.com/geometry/enclosing-circle.html Tue, 19 Aug 2025 15:59:22 +0000Algorithms for Competitive Programminghttps://cp-algorithms.com/geometry/enclosing-circle.htmlSimulated Annealing<h1>Simulated Annealing</h1> <p><strong>Simulated Annealing (SA)</strong> is a randomized algorithm, which approximates the global optimum of a function. It's called a randomized ...</p> https://cp-algorithms.com/num_methods/simulated_annealing.html Fri, 18 Oct 2024 16:18:55 +0000Algorithms for Competitive Programminghttps://cp-algorithms.com/num_methods/simulated_annealing.htmlKnapsack 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 Sat, 18 May 2024 06:20:41 +0000Algorithms for Competitive Programminghttps://cp-algorithms.com/dynamic_programming/knapsack.htmlManhattan Distance<h1>Manhattan Distance</h1> <h2>Definition</h2> <p>For points $p$ and $q$ on a plane, we can define the distance between them as the sum of the differences between their $...</p> https://cp-algorithms.com/geometry/manhattan-distance.html Thu, 16 May 2024 19:20:34 +0000Algorithms for Competitive Programminghttps://cp-algorithms.com/geometry/manhattan-distance.htmlHungarian Algorithm<h1>Hungarian algorithm for solving the assignment problem</h1> <h2>Statement of the assignment problem</h2> <p>There are several standard formulations of the assignment p...</p> https://cp-algorithms.com/graph/hungarian-algorithm.html Thu, 07 Dec 2023 23:50:44 +0000Algorithms for Competitive Programminghttps://cp-algorithms.com/graph/hungarian-algorithm.htmlIntroduction 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 Wed, 29 Nov 2023 10:21:39 +0000Algorithms for Competitive Programminghttps://cp-algorithms.com/dynamic_programming/intro-to-dp.htmlTortoise and Hare Algorithm (Linked List cycle detection)<h1>Floyd's Linked List Cycle Finding Algorithm</h1> <p>Given a linked list where the starting point of that linked list is denoted by <strong>head</strong>, and there may or may ...</p> https://cp-algorithms.com/others/tortoise_and_hare.html Sun, 10 Sep 2023 08:20:59 +0000Algorithms for Competitive Programminghttps://cp-algorithms.com/others/tortoise_and_hare.htmlFinding faces of a planar graph<h1>Finding faces of a planar graph</h1> <p>Consider a graph $G$ with $n$ vertices and $m$ edges, which can be drawn on a plane in such a way that two edges intersect...</p> https://cp-algorithms.com/geometry/planar.html Wed, 12 Jul 2023 15:52:18 +0000Algorithms for Competitive Programminghttps://cp-algorithms.com/geometry/planar.htmlBit 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 Fri, 31 Mar 2023 02:53:20 +0000Algorithms for Competitive Programminghttps://cp-algorithms.com/algebra/bit-manipulation.htmlGarner's Algorithm<h1>Garner's algorithm</h1> <p>A consequence of the <a href="chinese-remainder-theorem.md">Chinese Remainder Theorem</a> is, that we can represent big numbers using an array of ...</p> https://cp-algorithms.com/algebra/garners-algorithm.html Sun, 29 Jan 2023 19:48:33 +0000Algorithms for Competitive Programminghttps://cp-algorithms.com/algebra/garners-algorithm.htmlCode of conduct<h1>Code of conduct</h1> <p>We endorse and follow the code of conduct of the International Olympiad of Informatics, available at the [IOI website](https://ioinformati...</p> https://cp-algorithms.com/code_of_conduct.html Tue, 13 Dec 2022 14:21:50 +0000Algorithms for Competitive Programminghttps://cp-algorithms.com/code_of_conduct.htmlTag index<h1>Tags</h1> <p>This file contains a global index of all tags used on the pages.</p> <h6>tags.md:74-96/name { #tags.md:74-96/slug }</h6> https://cp-algorithms.com/tags.html Sun, 05 Jun 2022 22:11:56 +0000Algorithms for Competitive Programminghttps://cp-algorithms.com/tags.htmlNavigation<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 Sun, 05 Jun 2022 18:52:23 +0000Algorithms for Competitive Programminghttps://cp-algorithms.com/navigation.htmlBinary Search<h1>Binary search</h1> <p><strong>Binary search</strong> is a method that allows for quicker search of something by splitting the search interval into two. Its most common applica...</p> https://cp-algorithms.com/num_methods/binary_search.html Fri, 03 Jun 2022 11:53:41 +0000Algorithms for Competitive Programminghttps://cp-algorithms.com/num_methods/binary_search.htmlKnuth's Optimization<h1>Knuth's Optimization</h1> <p>Knuth's optimization, also known as the Knuth-Yao Speedup, is a special case of dynamic programming on ranges, that can optimize the ...</p> https://cp-algorithms.com/dynamic_programming/knuth-optimization.html Fri, 29 Apr 2022 09:57:35 +0000Algorithms for Competitive Programminghttps://cp-algorithms.com/dynamic_programming/knuth-optimization.htmlFactoring Exponentiation<h1>Binary Exponentiation by Factoring</h1> <p>Consider a problem of computing $ax^y \pmod{2^d}$, given integers $a$, $x$, $y$ and $d \geq 3$, where $x$ is odd.</p> <p>The ...</p> https://cp-algorithms.com/algebra/factoring-exp.html Sat, 16 Apr 2022 22:54:14 +0000Algorithms for Competitive Programminghttps://cp-algorithms.com/algebra/factoring-exp.htmlContinued fractions<!--?title Continued fractions --> <h1>Continued fractions</h1> <p><strong>Continued fraction</strong> is a representation of a real number as a specific convergent sequence of ra...</p> https://cp-algorithms.com/algebra/continued-fractions.html Thu, 31 Mar 2022 16:21:16 +0000Algorithms for Competitive Programminghttps://cp-algorithms.com/algebra/continued-fractions.htmlMEX 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, 25 Feb 2022 06:55:18 +0000Algorithms for Competitive Programminghttps://cp-algorithms.com/sequences/mex.htmlConvex 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 Mon, 11 Oct 2021 17:25:19 +0000Algorithms for Competitive Programminghttps://cp-algorithms.com/geometry/convex-hull.html