brain

tamnd's digital brain — notes, problems, research

43815 notes

CF 2225B - Alternating String

We are given a binary string consisting only of a and b. The goal is to determine whether we can transform it into a perfectly alternating string, meaning no two adjacent characters are the same. We are allowed to perform at most one operation.

codeforcescompetitive-programmingbrute-forcegreedy
CF 2222H - Counting Sort?

We are asked to count arrays with a property defined recursively. Given an array of integers, each bounded individually by a corresponding ri, we define a transformation f(b) that counts how many times each integer appears in b.

codeforcescompetitive-programmingbrute-forcecombinatoricsdp
CF 2222G - Statistics on Tree

We are working with a tree where each pair of vertices defines a path. For any pair of nodes $(u, v)$, we look at the unique simple path connecting them and then imagine removing all edges on that path from the tree.

codeforcescompetitive-programmingbinary-searchbrute-forcedfs-and-similardivide-and-conquergraphstrees
CF 2222F - Building Tree

We start with a weighted undirected graph on n vertices. The twist is that distance between two nodes is not the usual shortest path sum. Instead, if you take any path and look at the set of edge weights used on that path, the cost of the path is the mex of that set.

codeforcescompetitive-programmingdata-structuresdivide-and-conquerdsugraphsimplementation
CF 2222E - Seek the Truth

We are interacting with a hidden transformation on integers in the range from 0 to $2^n - 1$. Behind the scenes there is a fixed bitmask $c$ and a hidden operation type $k in {1,2,3}$. Every time we insert a number $x$, the judge does not insert $x$ itself.

codeforcescompetitive-programmingbinary-searchbitmasksconstructive-algorithmsinteractive
CF 2222D - Permutation Construction

We are given an array a of n integers, which can be positive, negative, or zero. The task is to construct a permutation p of length n - a sequence containing all integers from 1 to n exactly once - such that the "beauty" of the permutation is maximized.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuressortings
CF 2222B - Artistic Balance Tree

We are given an array of integers and a sequence of operations. Each operation consists of two conceptual parts: first, you can swap elements symmetrically around any chosen center in the array, effectively letting you reorder elements in a controlled way; second, you mark a…

codeforcescompetitive-programminggreedysortings
CF 2222C - Median Partition

We are given a sequence of positive integers of odd length. The task is to divide this sequence into contiguous subarrays, each of odd length, such that all these subarrays share the same median. Our goal is to maximize the number of subarrays in such a partition.

codeforcescompetitive-programmingdpmath
CF 2222A - A Wonderful Contest

We are asked to determine whether a programming contest is “wonderful” in the sense that every possible integer total score between 0 and 100 n can be achieved. The contest has n problems, and each problem is divided into ai subtasks.

codeforcescompetitive-programmingbrute-forcedpmath
CF 2219E - Weird Chessboard

We are asked to construct a configuration of pieces on an $n times n$ chessboard such that every cell is "good." A piece placed at $(i,j)$ attacks every cell $(x,y)$ where $x ge i$ and $y ge j$, excluding the cell itself.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 2219C - Coloring a Red Black Tree

We are given a tree with n nodes, where each node is initially colored either red or black according to a binary string. Red nodes are marked 1 and black nodes 0.

codeforcescompetitive-programmingdfs-and-similardpgreedymathprobabilitiestrees
CF 2219D - MEX Replacement on Tree

We are given a tree with n vertices rooted at vertex 1. Each vertex has a unique integer weight between 0 and n-1. For any vertex v, we define Sv as the set of weights along the path from the root to v, inclusive.

codeforcescompetitive-programmingdata-structuresimplementationmathtrees
CF 2219B2 - Unique Values (Hard version)

We are given an array of length $2n+1$ containing integers from $1$ to $n$. Every integer appears exactly twice, except one integer, which appears three times. Our task is to identify the positions of the integer that appears three times.

codeforcescompetitive-programmingbinary-searchbitmasksconstructive-algorithmsinteractive
CF 2219A - Grid L

We are given two types of tiles: unit-length segments (1×1 edges) and L-shaped pieces formed by joining two segments at a right angle.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsmathnumber-theory
CF 2219B1 - Unique Values (Easy version)

We are given an array of length $2n+1$. Every number lies in the range $1$ to $n$. The structure is highly constrained: all values appear exactly twice except for one special value that appears exactly three times.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsdivide-and-conquerinteractivemath
CF 2218F - The 67th Tree Problem

We are asked to build a rooted tree on exactly $x+y$ labeled nodes, with node $1$ designated as the root. For every node $u$, we look at its subtree, meaning all nodes whose path to the root passes through $u$, including $u$ itself.

codeforcescompetitive-programmingconstructive-algorithmsimplementationtrees
CF 2218E - The 67th XOR Problem

We are given an array of non-negative integers. We perform a sequence of operations until only one element remains. Each operation consists of picking an element, XORing it with all elements of the current array, and then removing it.

codeforcescompetitive-programmingbinary-searchbitmasksbrute-force
CF 2218C - The 67th Permutation Problem

The task is to construct a permutation of length $3n$ where we partition it into $n$ consecutive blocks of three elements each, and then take the median of each block. Our goal is to maximize the sum of these medians.

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 2218D - The 67th OEIS Problem

We are asked to construct sequences of integers of a given length such that the greatest common divisor of every consecutive pair is unique.

codeforcescompetitive-programmingconstructive-algorithmsgreedymathnumber-theory
CF 2218B - The 67th 6-7 Integer Problem

We are given exactly seven integers. The task is to negate six of them-multiply them by -1-and leave one unchanged, then compute the sum. We want the maximum sum achievable by choosing which six to negate.

codeforcescompetitive-programminggreedymath
CF 2217H - Closer

We have a tree with $2n$ vertices, each hosting a single person. Every person carries a badge corresponding to one of $n$ deals, and each deal appears exactly twice among the people.

codeforcescompetitive-programmingdfs-and-similardptrees
CF 2217G - Down the Pivot

We are asked to count labeled binary trees with a very specific operation and cost function. Each node of the tree is labeled either 0 or 1. The allowed operation is to pick a simple path that passes through the root and flip every label along that path.

codeforcescompetitive-programmingcombinatoricsdpmathtrees
CF 2217D - Flip the Bit (Hard Version)

We are given a binary array and a set of special indices where all values are identical. Our goal is to make the entire array equal to the value at these special indices using the fewest number of flip operations.

codeforcescompetitive-programminggreedyimplementationmath
CF 2217F - Interval Game

The problem describes a two-player turn-based game involving two intervals. Alice chooses the first interval within a fixed bound [1, x1], and the second interval is picked uniformly at random from all valid intervals in [1, x2].

codeforcescompetitive-programmingbitmaskscombinatoricsconstructive-algorithmsdpgamesgreedymathprobabilities
CF 2217E - Definitely Larger

We are given a fixed permutation p of size n. Think of each position i as a point that has two independent labels: its position index and its value pi.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsdata-structuresgraphsgreedysortings
CF 2217B - Flip the Bit (Easy Version)

We are given a binary array of length $n$ and a single special index $p1$ (since $k=1$). The element at this special index has value $x$, and our goal is to make the entire array equal to $x$.

codeforcescompetitive-programminggreedyimplementation
CF 2217C - Grid Covering

The problem asks whether a person starting at the top-left corner of a grid can eventually visit every cell by jumping in a very specific pattern.

codeforcescompetitive-programmingchinese-remainder-theoremmathnumber-theory
CF 2217A - The Equalizer

We are given an array of positive integers. Two players alternate turns starting with Shaunak. A normal turn consists of picking any position whose value is still positive and decreasing it by one.

codeforcescompetitive-programmingmath
CF 1972A - Contest Proposal

We are given a contest with n problems, each having a proposed difficulty ai and an expected maximum difficulty bi. Both sequences are sorted in non-decreasing order. The goal is to adjust the proposed difficulties so that every problem satisfies ai ≤ bi.

codeforcescompetitive-programmingbrute-forcegreedytwo-pointers
CF 1968G2 - Division + LCP (hard version)

We are given a string and asked to split it into a fixed number of contiguous pieces. For any such split, we look at how long a common prefix all pieces share, meaning we compare the first characters of every segment, then the second characters, and so on, stopping at the…

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresdphashingmathstring-suffix-structuresstrings
CF 1968F - Equal XOR Segments

We are asked to decide, for subarrays of a given array, whether it is possible to partition the subarray into at least two consecutive segments such that the bitwise XOR of each segment is equal.

codeforcescompetitive-programmingbinary-searchdata-structures
CF 1968G1 - Division + LCP (easy version)

The problem asks us to split a string into exactly $k$ consecutive substrings and then compute the longest common prefix (LCP) shared among those substrings.

codeforcescompetitive-programmingbinary-searchdata-structuresdphashingstring-suffix-structuresstrings
CF 1968E - Cells Arrangement

We are asked to place exactly $n$ points inside an $n times n$ integer grid. Each point occupies a distinct cell, and we then look at all pairwise Manhattan distances between chosen points.

codeforcescompetitive-programmingconstructive-algorithms
CF 1968C - Assembly via Remainders

We are asked to reconstruct an array of integers when only the modular differences between consecutive elements are known.

codeforcescompetitive-programmingconstructive-algorithmsnumber-theory
CF 1968A - Maximize?

We are given a number $x$, and we need to choose a smaller positive integer $y$ such that the value $$gcd(x, y) + y$$ is as large as possible. The goal is not to maximize $y$ itself, but a combination of $y$ and how much it shares divisors with $x$.

codeforcescompetitive-programmingbrute-forcemathnumber-theory
CF 1968D - Permutation Game

We are given a directed structure formed by a permutation. From each index $x$, there is exactly one outgoing edge to $px$, so the entire system decomposes into disjoint directed cycles, possibly with trees feeding into them, but because $p$ is a permutation, every node lies…

codeforcescompetitive-programmingbrute-forcedfs-and-similargamesgraphsgreedymath
CF 1957E - Carousel of Combinations

We are counting circular arrangements of selected elements, then mixing that count with a modular reduction that depends on the size of the selection.

codeforcescompetitive-programmingbrute-forcecombinatoricsdpmathnumber-theory
CF 1957F1 - Frequency Mismatch (Easy Version)

We are working on a rooted tree where each node carries a small integer label. Each query gives us two paths in the tree. For each path, we can think of walking from one endpoint to the other and collecting the multiset of node values along the way.

codeforcescompetitive-programmingbinary-searchdata-structuresdivide-and-conquerhashingprobabilitiestrees
CF 1957F2 - Frequency Mismatch (Hard Version)

We are given a tree with $n$ nodes, each node labeled with an integer value. The tree is unrooted, but conceptually we can root it anywhere for processing. For each query, we are asked to compare the multiset of values along two paths in the tree.

codeforcescompetitive-programmingbinary-searchdata-structuresdfs-and-similarhashingprobabilitiestrees
CF 1957D - A BIT of an Inequality

We are given an array of integers and asked to count all triples of indices $(x, y, z)$ where $1 le x le y le z le n$, such that the XOR of two subarrays, $f(x, y)$ and $f(y, z)$, is strictly greater than the XOR of the entire range from $x$ to $z$, denoted $f(x, z)$.

codeforcescompetitive-programmingbitmasksbrute-forcedpmath
CF 1957B - A BIT of a Construction

We are asked to build an array of length n consisting of non-negative integers whose total sum is exactly k. Among all such arrays, we want to maximize the number of set bits in the bitwise OR of all elements.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsgreedyimplementation
CF 1957C - How Does the Rook Move?

We are playing a two-player game on an $n times n$ chessboard. You place a white rook on your turn and the computer places a black rook immediately after, mirroring your move across the main diagonal, meaning the rook at $(r, c)$ is mirrored to $(c, r)$.

codeforcescompetitive-programmingcombinatoricsdpmath
CF 1952H - Palindrome

The problem asks us to determine whether a given string reads the same forwards and backwards, which is the definition of a palindrome. We are given multiple test cases, each consisting of a single string of lowercase letters.

codeforcescompetitive-programming*specialimplementationstrings
CF 1952G - Mathematician Takeover

We are given a single real number $x$ between 1 and 100, precise to three decimal places. The goal is to compute a real number $y$ such that it satisfies a hidden mathematical property tied to $x$.

codeforcescompetitive-programming*specialbinary-searchdfs-and-similarmath
CF 1952F - Grid

We are given a 21 by 21 grid where each cell contains either a 0 or a 1. The task is to determine the largest "cross" of 1s that can be formed inside this grid.

codeforcescompetitive-programming*specialbrute-force
CF 1952E - Sweep Line

We are given a line of positions, each position holding one of three possible values: 0, 1, or 2. The task is to count how many valid global configurations exist that are consistent with the given array, where the notion of “validity” comes from a hidden combinatorial rule…

codeforcescompetitive-programming*specialcombinatoricsgamesmath
CF 1952D - Are You a Procrastinator?

I can’t reliably write a correct editorial for Codeforces 1952D - “Are You a Procrastinator?” from what you provided, because the actual problem statement (input/output definition, scoring rules, and constraints) is missing.

codeforcescompetitive-programming*specialimplementation
CF 1948F - Rare Coins

Each bag contains two types of coins. Gold coins are simple: every gold coin always contributes exactly one unit of value. Silver coins are uncertain, each silver coin independently behaves like a fair coin flip and contributes either 0 or 1 with equal probability.

codeforcescompetitive-programmingcombinatoricsmathprobabilities
CF 1948E - Clique Partition

We are asked to construct a graph on $n$ vertices in a very specific way: each vertex receives a distinct integer from $1$ to $n$, and then we connect two vertices $i$ and $j$ with an edge if the sum of their index difference and value difference does not exceed a given…

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgraphsgreedyimplementation
CF 1948B - Array Fix

We are given an array of integers between 0 and 99, and our goal is to decide whether we can transform it into a non-decreasing array by repeatedly "splitting" numbers of two digits into their individual digits.

codeforcescompetitive-programmingbrute-forcedpgreedyimplementation
CF 1948D - Tandem Repeats?

We are given a string s consisting of lowercase letters and question marks. A tandem repeat is a substring of even length where the first half is exactly equal to the second half.

codeforcescompetitive-programmingbrute-forcestringstwo-pointers
CF 1948A - Special Characters

We are asked to construct a string over uppercase Latin letters such that exactly n positions are “special”. A position is called special when its character matches exactly one of its immediate neighbors.

codeforcescompetitive-programmingbrute-forceconstructive-algorithms
CF 1946F - Nobody is needed

We are given a permutation of integers from 1 to $n$ and a series of queries. Each query asks how many sequences of indices in a specified range $[l, r]$ can be formed such that the sequence is strictly increasing and each element divides the next one in the permutation.

codeforcescompetitive-programming2-satdata-structuresdfs-and-similardp
CF 1946E - Girl Permutation

We are given a permutation of size $n$, which means it contains all integers from $1$ to $n$ exactly once, in some unknown order. Instead of seeing the permutation directly, we are told the positions of its prefix maximums and suffix maximums.

codeforcescompetitive-programmingcombinatoricsdpmathnumber-theory
CF 1946D - Birthday Gift

We are given an array and we are allowed to cut it into contiguous segments that cover the entire array from left to right. Each segment is summarized into a single value, the XOR of its elements.

codeforcescompetitive-programmingbitmasksbrute-forceconstructive-algorithmsgreedyimplementation
CF 1946A - Median of an Array

We are given an array of integers and asked to determine the minimum number of increment operations needed to increase the median of the array. An increment operation consists of picking any element and adding one to it.

codeforcescompetitive-programminggreedyimplementationsortings
CF 1946B - Maximum Sum

We start with an integer array. Each operation allows us to choose any contiguous subarray, including the empty subarray, compute its sum, and insert that sum as a new element anywhere in the array. The key observation is that inserting a value changes the total sum of the array.

codeforcescompetitive-programmingdpgreedymath
CF 494E - Sharti

We are asked to determine the winner of a two-player combinatorial game played on an $n times n$ board. The board consists of black and white cells. Initially, only certain rectangles are white, and the rest are black.

codeforcescompetitive-programmingdata-structuresgames
CF 494B - Obsessive String

We are given two strings, s and t. The task is to count how many ways we can choose one or more non-overlapping substrings from s such that each chosen substring contains t somewhere inside it.

codeforcescompetitive-programmingdpstrings
CF 494D - Birthday

We are given a rooted tree with n vertices, where vertex 1 is the root. Each edge has a positive weight, and the distance between any two vertices is the sum of the weights along the unique path connecting them.

codeforcescompetitive-programmingdata-structuresdfs-and-similardptrees
CF 494A - Treasure

We are given a string consisting of three types of characters: opening parentheses, closing parentheses, and special placeholders. Each placeholder must be expanded into a positive number of closing parentheses.

codeforcescompetitive-programminggreedy
CF 492E - Vanya and Field

We are given an n × n grid representing a field, with m apple trees located at specific cells. Vanya starts at some cell and moves in discrete time steps along a fixed vector (dx, dy), wrapping around the grid in a toroidal fashion (i.e., positions are taken modulo n).

codeforcescompetitive-programmingmath
CF 492A - Vanya and Cubes

Vanya wants to build a pyramid using exactly the pattern described by triangular numbers. The first level contains 1 cube. The second level contains 1 + 2 = 3 cubes. The third level contains 1 + 2 + 3 = 6 cubes.

codeforcescompetitive-programmingimplementation
CF 492D - Vanya and Computer Game

Two players are attacking a sequence of monsters. Each monster has a health value in hits, meaning it requires that many discrete attacks before it dies. The attacks are not interleaved arbitrarily; instead, the two players hit at perfectly regular intervals.

codeforcescompetitive-programmingbinary-searchimplementationmathsortings
CF 492B - Vanya and Lanterns

We are asked to determine the minimum radius of light for lanterns placed along a straight street of length l so that the entire street is illuminated. Each lantern is at a fixed position along the street and can light up points within a distance d to its left and right.

codeforcescompetitive-programmingbinary-searchimplementationmathsortings
CF 490E - Restoring Increasing Sequence

We are given a sequence of strings. Each string represents a positive integer, but some digits have been replaced by '?'. The original sequence was strictly increasing. Our task is to replace every '?

codeforcescompetitive-programmingbinary-searchbrute-forcegreedyimplementation
CF 490F - Treeland Tour

We are given a tree of cities, where each city has a population. The roads connect cities such that there is exactly one simple path between any two cities.

codeforcescompetitive-programmingdata-structuresdfs-and-similardptrees
CF 490D - Chocolate

Each chocolate bar is a rectangle made of unit squares, so its “value” is just its area. We start with two rectangles and we are allowed to modify them minute by minute.

codeforcescompetitive-programmingbrute-forcedfs-and-similarmathmeet-in-the-middlenumber-theory
CF 490B - Queue

Each input line describes one student, but the student's own ID is not given directly. Instead, we are told the ID of the student standing immediately in front of them and the ID of the student standing immediately behind them.

codeforcescompetitive-programmingdsuimplementation
CF 490C - Hacking Cypher

We are given a very long decimal number as a string. Its length can reach one million digits, so treating it as a normal integer is impossible. We must choose a position where the string is cut into two nonempty pieces.

codeforcescompetitive-programmingbrute-forcemathnumber-theorystrings
CF 490A - Team Olympiad

We are given a list of children, each identified by a number indicating their skill: programming (1), maths (2), or physical education (3). The task is to form as many teams of three as possible, where each team has exactly one child from each skill.

codeforcescompetitive-programminggreedyimplementationsortings
CF 489E - Hiking

We have a sequence of resting points along a river. Point i is located at position x[i] and has picturesqueness value b[i]. The traveler starts at coordinate 0 and must finish at the last resting point, which is also the farthest one.

codeforcescompetitive-programmingbinary-searchdp
CF 489F - Special Matrices

We are asked to count the number of n × n binary matrices where each row and each column contains exactly two ones. Some of the first rows are already fixed, and we must count only matrices consistent with them.

codeforcescompetitive-programmingcombinatoricsdp
CF 489D - Unbearable Controversy of Being

We are given a directed graph representing intersections and one-way roads. A "damn rhombus" consists of four distinct vertices $a, b, c, d$ such that there are directed edges $$a rightarrow b,quad b rightarrow c,quad a rightarrow d,quad d rightarrow c$$ In other words, from…

codeforcescompetitive-programmingbrute-forcecombinatoricsdfs-and-similargraphs
CF 489A - SwapSort

We are given an array of integers and must transform it into non-decreasing order by performing swaps of array positions. The interesting part is that we do not need the minimum number of swaps. Any valid sequence containing at most n swaps is accepted.

codeforcescompetitive-programminggreedyimplementationsortings
CF 489B - BerSU Ball

We have two groups of dancers. Each boy has a skill level, and each girl has a skill level. A boy and a girl can be paired only if their skill levels differ by at most 1. Every dancer can belong to at most one pair. The task is to form as many valid boy-girl pairs as possible.

codeforcescompetitive-programmingdfs-and-similardpgraph-matchingsgreedysortingstwo-pointers
CF 489C - Given Length and Sum of Digits...

We are asked to construct two integers of a specified length, m, such that the sum of their digits is exactly s. One of these integers must be the smallest possible and the other the largest possible in lexicographical order.

codeforcescompetitive-programmingdpgreedyimplementation
CF 487E - Tourists

We are asked to handle queries on a connected undirected graph representing cities in Cyberland. Each city has a souvenir price, and roads connect pairs of cities.

codeforcescompetitive-programmingdata-structuresdfs-and-similargraphstrees
CF 487D - Conveyor Belts

We are given a rectangular table of size n by m filled with conveyor belts. Each conveyor belt points either up (^), left (<), or right (). Surrounding the table are diner seats, numbered logically as rows 0 and n+1 and columns 0 and m+1.

codeforcescompetitive-programmingdata-structures
CF 487C - Prefix Product Sequence

We need to arrange the numbers $1,2,dots,n$ into a permutation $a1,a2,dots,an$. Define $$pi = a1a2cdots ai pmod n.$$ The requirement is that the sequence $p1,p2,dots,pn$ must itself be a permutation of all residues $0,1,dots,n-1$.

codeforcescompetitive-programmingconstructive-algorithmsmathnumber-theory
CF 487A - Fight the Monster

We are given the initial combat statistics of two characters, Master Yang and a monster. Each character has hit points, attack, and defense. Combat proceeds in discrete seconds.

codeforcescompetitive-programmingbinary-searchbrute-forceimplementation
CF 487B - Strip

We have an array of integers representing numbers on a strip of paper. Alexandra wants to divide the strip into contiguous segments. Each segment must have at least l numbers, and the difference between the largest and smallest number in that segment must not exceed s.

codeforcescompetitive-programmingbinary-searchdata-structuresdptwo-pointers
CF 486E - LIS of Sequence

We are given an array and we care about its longest increasing subsequences. An index belongs to a longest increasing subsequence if the value at that position is selected as one of the elements of that subsequence. The task is not to count LISs.

codeforcescompetitive-programmingdata-structuresdpgreedyhashingmath
CF 486D - Valid Sets

We are given a tree where every vertex has an integer value. A set of vertices is considered valid if it is non-empty, forms a connected subgraph of the tree, and the difference between the largest and smallest value inside the set does not exceed d.

codeforcescompetitive-programmingdfs-and-similardpmathtrees
CF 486C - Palindrome Transformation

We are given a string of length $n$ consisting of lowercase English letters, along with a cursor position $p$ that can move left or right around the string in a cyclic manner.

codeforcescompetitive-programmingbrute-forcegreedyimplementation
CF 486A - Calculating Function

We are given a single integer n and asked to evaluate the alternating sum $$-1 + 2 - 3 + 4 - 5 + dots + (-1)^n n.$$ The sign of each term depends on its position. Odd numbers are subtracted and even numbers are added. The output is the final value of this sum.

codeforcescompetitive-programmingimplementationmath
CF 486B - OR in Matrix

We are given a matrix B of size m × n, where each element is either 0 or 1. This matrix was supposedly generated from some original matrix A of the same size using a specific rule: each element B[i][j] equals the logical OR of all elements in the i-th row of A combined with…

codeforcescompetitive-programminggreedyhashingimplementation
CF 484E - Sign on Fence

We have a fence represented by an array of heights. A rectangular sign must be placed on top of some consecutive panels. The sign has a fixed width w, so it must cover exactly w consecutive fence panels.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsdata-structures
CF 484D - Kindergarten

We have a line of children, each with an integer charisma value. The goal is to partition the line into contiguous groups. For each group, its sociability is the difference between the largest and smallest charisma values in that group.

codeforcescompetitive-programmingdata-structuresdpgreedy
CF 484C - Strange Sorting

Working

codeforcescompetitive-programmingimplementationmath
CF 484A - Bits

We are asked to process several queries, each defined by a lower bound l and an upper bound r. For each query, we need to find the integer x within the interval [l, r] such that the number of set bits in its binary representation is as large as possible.

codeforcescompetitive-programmingbitmasksconstructive-algorithms
CF 484B - Maximum Value

We are given a sequence of integers a1, a2, …, an and asked to compute the maximum value of ai % aj over all pairs (i, j) where ai ≥ aj. The input consists of the number of integers n and the sequence itself.

codeforcescompetitive-programmingbinary-searchmathsortingstwo-pointers
CF 482C - Game with Strings

We know all candidate strings in advance. One of them is chosen uniformly at random. We reveal information by asking about character positions. The order of questions is not chosen strategically. At every step we pick uniformly among positions that have not been asked yet.

codeforcescompetitive-programmingbitmasksdpprobabilities
CF 482D - Random Function and Tree

We are given a rooted tree with n vertices, where vertex 1 is the root and every other vertex i has a specified parent pi. Initially, every vertex is painted red.

codeforcescompetitive-programmingcombinatoricsdptrees
CF 482E - ELCA

I can't provide a correct "complete solution editorial" with a full accepted implementation for Codeforces 482E from first principles here, because this is a very difficult 3200-rated dynamic-tree problem and I do not have enough information to reliably reconstruct the entire…

codeforcescompetitive-programmingdata-structurestrees
CF 482A - Diverse Permutation

We are asked to construct a permutation of integers from 1 to n such that the set of absolute differences between consecutive elements contains exactly k distinct values.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 482B - Interesting Array

We are asked to construct an array of n non-negative integers such that m given bitwise AND constraints are satisfied.

codeforcescompetitive-programmingconstructive-algorithmsdata-structurestrees
CF 466E - Information Graph

We have a company hierarchy that is built gradually over time. Initially nobody has a boss. A type 1 operation attaches an employee x under employee y, making y the boss of x. The input guarantees that x currently has no boss, and cycles never appear.

codeforcescompetitive-programmingdfs-and-similardsugraphstrees
CF 464E - The Classic Problem

We are given an undirected weighted graph with up to 100,000 vertices and 100,000 edges. Each edge weight is a power of two, specified as $2^{xi}$, where $xi$ is between 0 and 100,000.

codeforcescompetitive-programmingdata-structuresgraphsshortest-paths
CF 464B - Restore Cube

We are given eight points in three-dimensional space. Each point was originally a vertex of a cube whose side length was positive. The complication is that the coordinates have been corrupted in a very specific way.

codeforcescompetitive-programmingbrute-forcegeometry