brain

tamnd's digital brain — notes, problems, research

43815 notes

CF 2104B - Move to the End

We are given an array of integers, and for every possible length $k$ from 1 to $n$, we want to maximize the sum of the last $k$ elements after moving one element of our choice to the end of the array. After we choose and move that element, we restore the array for the next query.

codeforcescompetitive-programmingbrute-forcedata-structuresdpgreedyimplementation
CF 2104C - Card Game

We are given a small card game where each card is uniquely labeled from 1 to n, and each card initially belongs to either Alice or Bob. The ownership is fixed at the start, but during the game cards can move between players depending on outcomes.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgamesgreedymath
CF 2106G2 - Baudelaire (hard version)

We are given a tree with up to 1000 nodes, and each node hides a value of either 1 or −1. The tree is rooted somewhere, but the root is unknown to us.

codeforcescompetitive-programmingbinary-searchdfs-and-similardivide-and-conquerimplementationinteractivetrees
CF 2106G1 - Baudelaire (easy version)

We are given a tree of size $n$, where each node carries a value of either $1$ or $-1$. The tree is connected in such a way that every node is adjacent to node $1$.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsdivide-and-conquergreedyinteractivetrees
CF 2106F - Goblin

We are asked to find the largest connected set of zeros in an $n times n$ grid that is built from a single binary string $s$. Each row of the grid is generated by flipping one character of $s$ at the row's index.

codeforcescompetitive-programmingdfs-and-similardpdsugreedymath
CF 2106E - Wolf

We are given a permutation of numbers from 1 to n, and we need to answer many independent queries. Each query picks a subarray range $[l, r]$ and a target value $k$. We imagine performing the standard binary search process on that fixed range, even though the array is not sorted.

codeforcescompetitive-programmingbinary-searchgreedymath
CF 2106D - Flower Boy

We are given a sequence of flowers in a row, each with a numeric beauty value. Igor wants to collect a fixed number of flowers, exactly $m$, moving strictly left to right.

codeforcescompetitive-programmingbinary-searchdpgreedytwo-pointers
CF 2106B - St. Chroma

We are given a list that must be a permutation of numbers from 0 to n−1. As we reveal this permutation from left to right, we compute a running value: after each prefix, we take the smallest non-negative integer that is missing from that prefix.

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 2106A - Dr. TC

We are given a binary string s of length n, and we imagine creating n new strings by flipping exactly one bit of s in each position. The resulting strings are arranged as rows of an n × n board. Our goal is to count the total number of 1s on this board.

codeforcescompetitive-programmingbrute-forcemath
CF 2106C - Cherry Bomb

We are given two arrays of length $n$, $a$ and $b$. Array $a$ is fully known, and $b$ has some missing elements marked as $-1$. The goal is to fill in the missing elements in $b$ such that the sum $ai + bi$ is constant for all $i$. Each element in $b$ must remain within $[0, k]$.

codeforcescompetitive-programminggreedymathsortings
CF 2107F2 - Cycling (Hard Version)

The problem presents a sequence of cyclists, each with an agility value. Leo is positioned at the back and wants to overtake all cyclists to reach the front.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresdpgreedy
Kvant Math Problem 865

For consecutive pairs $a_{i-1}<a_i$, the expression

kvantmathematicsolympiad
CF 2107F1 - Cycling (Easy Version)

We are given a line of cyclists with different “agility costs” associated to each position. Leo starts behind the last cyclist and wants to move all the way to the front, passing every cyclist one by one until he is ahead of the first.

codeforcescompetitive-programmingbinary-searchbrute-forcedpgreedy
CF 2107E - Ain and Apple Tree

We are asked to construct a rooted tree on nodes labeled from 1 to n, where node 1 is fixed as the root. The contribution of a pair of nodes i and j is determined by how deep their lowest common ancestor is in this rooted tree.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsgreedymathtrees
CF 2107D - Apple Tree Traversing

We are given a tree with n nodes, each node initially containing one apple. Our goal is to traverse this tree and repeatedly select paths consisting only of nodes that still have apples, remove the apples along that path, and write down three numbers: the length of the path…

codeforcescompetitive-programmingbrute-forcedfs-and-similargreedyimplementationtrees
CF 2107C - Maximum Subarray Sum

We are given an array where some positions are already fixed and some positions are “unknown”. Unknown positions are initially set to zero, but we are allowed to overwrite them with arbitrary integers up to $10^{18}$.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsdpimplementationmath
CF 2107B - Apples in Boxes

We are given several independent games. In each game, there are multiple boxes of apples. On every move, a player removes exactly one apple from a single non-empty box.

codeforcescompetitive-programminggamesgreedymath
CF 2107A - LRC and VIP

We are given several independent arrays, and for each one we need to split its elements into two non-empty groups. Each number must go into exactly one group, so we are really choosing a binary labeling of indices.

codeforcescompetitive-programminggreedynumber-theory
CF 2108F - Fallen Towers

We are given an array of towers, each tower starting with some non-negative height. We must process every tower exactly once, in any order we choose.

codeforcescompetitive-programmingbinary-searchgreedy
CF 2108E - Spruce Dispute

We are given a tree with an odd number of vertices. Almost all vertices carry ornaments, and every ornament belongs to exactly one color, with each color appearing on exactly two vertices. One vertex is special and initially uncolored, acting as a “topper”.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similargraphsgreedyimplementationshortest-pathstrees
CF 2108D - Needle in a Numstack

We are given a hidden array C formed by concatenating two unknown arrays A and B. The split point is unknown. Both arrays are over the alphabet {1, 2, ...

codeforcescompetitive-programmingbinary-searchbrute-forceimplementationinteractive
CF 2108B - SUMdamental Decomposition

We are asked to construct an array of n positive integers whose bitwise XOR is exactly x and to minimize the sum of the array. Instead of outputting the array itself, we are asked to return the sum of the elements.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsgreedyimplementationmath
CF 2108C - Neo's Escape

Neo is faced with a row of buttons, each labeled with a positive integer weight. He wants to press all the buttons such that the sequence of weights of the pressed buttons never increases.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresdpdsugraphsgreedyimplementation
CF 2108A - Permutation Warm-Up

We are given a permutation of the numbers from 1 to n, and we measure how far each element moves away from its original position. For each position i, we take the absolute difference between the value sitting there and i itself, and sum this over the entire array.

codeforcescompetitive-programmingcombinatoricsgreedymath
CF 2109F - Penguin Steps

We are working on an $n times n$ grid where each cell has two attributes: a weight $a{i,j}$ and a color that is either black or white. Two players start from different positions on the left side of the grid and both aim to reach the same exit cell on the rightmost column.

codeforcescompetitive-programmingbinary-searchdfs-and-similarflowsgraphsshortest-paths
CF 2109E - Binary String Wowee

We are given a binary string s of length n and an integer k. Our task is to perform exactly k operations, each of which selects a zero in the current string and flips all bits from the beginning up to that zero.

codeforcescompetitive-programmingcombinatoricsdpstrings
CF 2109C2 - Hacking Numbers (Medium Version)

In this problem, we are asked to manipulate an unknown integer $x$ to become equal to a given target $n$ using a very limited number of operations.

codeforcescompetitive-programmingconstructive-algorithmsinteractivemathnumber-theory
CF 2109D - D/D/D

We are given a connected, undirected graph with n vertices and m edges. There are no self-loops or multiple edges, so each edge connects two distinct vertices exactly once. Along with the graph, we are given a multiset A of positive integers, each representing a "move length.

codeforcescompetitive-programmingdfs-and-similargraphsgreedyshortest-paths
CF 2109C3 - Hacking Numbers (Hard Version)

We start with an unknown integer x, hidden from us, guaranteed to lie in the range from 1 to 10^9. Our goal is to transform this hidden value into a given target value n.

codeforcescompetitive-programmingconstructive-algorithmsinteractivemathnumber-theory
CF 2109C1 - Hacking Numbers (Easy Version)

In this problem, we face an unknown integer x that is initially hidden from us, and our goal is to transform it into a target integer n by issuing at most seven interactive commands.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsinteractivemathnumber-theory
CF 2109B - Slice to Survive

We are given a rectangular grid of size $n times m$, and a single token (a monster) initially placed at cell $(a, b)$.

codeforcescompetitive-programmingbitmasksgreedymath
CF 2109A - It's Time To Duel

We are given a line of players, each participating in duels with their immediate neighbor, so player 1 duels player 2, player 2 duels player 3, and so on until player $n-1$ duels player $n$. After all $n-1$ duels, each player reports whether they won at least one duel.

codeforcescompetitive-programmingimplementation
Kvant Math Problem 830

Let the first quadratic be $x^2 + p_1 x + q_1 = 0$ with two distinct real roots $r_1 \le s_1$.

kvantmathematicsolympiad
CF 2110F - Faculty

We are given an array of positive integers, and for each prefix of the array we are asked to compute its "beauty." The beauty of an array is defined as the maximum value of the function $f(x, y) = (x bmod y) + (y bmod x)$ over all pairs of elements $x, y$ in the prefix.

codeforcescompetitive-programmingbrute-forcegreedymathnumber-theory
CF 2110D - Fewer Batteries

We are asked to guide a robot through a series of checkpoints. Each checkpoint has a certain number of batteries that the robot can collect, and there are one-way passages connecting some checkpoints.

codeforcescompetitive-programmingbinary-searchdfs-and-similardpgraphsgreedyhashing
CF 2110E - Melody

We are asked to arrange a set of sounds, each defined by a volume and pitch, into a sequence that is simultaneously beautiful and non-boring.

codeforcescompetitive-programmingdfs-and-similargraphsimplementation
CF 2110C - Racing

We are asked to plan a drone flight through a sequence of obstacles, where each obstacle defines an allowable height range.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 2110A - Fashionable Array

We are given an array of integers, and we define it as fashionable if the sum of its minimum and maximum elements is even. Our task is to determine the minimum number of elements that must be removed so that the array becomes fashionable.

codeforcescompetitive-programmingimplementationsortings
CF 2110B - Down with Brackets

We are given a string representing a balanced sequence of parentheses, and we need to decide whether it is possible to remove exactly one opening bracket and exactly one closing bracket such that the resulting string is no longer balanced.

codeforcescompetitive-programmingstrings
CF 2111G - Divisible Subarrays

We are given a permutation of the numbers from 1 to n. For every query, we take a contiguous segment of this permutation and must decide whether that segment has a very specific structural property: whether there exists a way to split the segment into two parts using a…

codeforcescompetitive-programmingbinary-searchbitmasksbrute-forcedata-structuresinteractive
CF 2111F - Puzzle

We are asked to construct a shape made from unit square tiles placed on the integer grid. Each tile occupies one cell, and all chosen cells must form a single 4-connected component, meaning you can walk between any two tiles by stepping across shared edges.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedymath
CF 2111E - Changing the String

We are given a string consisting only of the characters a, b, and c. Alongside it is a sequence of operations. Each operation suggests a possible replacement: choose any occurrence of a letter x and turn it into another letter y, or skip the operation entirely.

codeforcescompetitive-programmingbinary-searchdata-structuresgreedyimplementationsortingsstrings
CF 2111D - Creating a Schedule

We are tasked with creating a class schedule for a faculty where each group has exactly six classes on the first day. There are $n$ student groups and $m$ classrooms.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresgreedyimplementationsortings
CF 2111B - Fibonacci Cubes

We have a collection of cubes, where the side length of the $i$-th cube corresponds to the $i$-th Fibonacci number under a modified definition: $f1 = 1$, $f2 = 2$, and $fi = f{i-1} + f{i-2}$ for $i 2$.

codeforcescompetitive-programmingbrute-forcedpimplementationmath
CF 2111A - Energy Crystals

We are working with three identical storage units that start at zero energy. The goal is to bring all three to exactly the same target level $x$. The only operation allowed is to pick one unit and increase its value by any positive integer.

codeforcescompetitive-programminggreedyimplementationmath
CF 2111C - Equal Values

We are given an array of integers and allowed to repeatedly “broadcast” a chosen element’s value either to everything on its left or everything on its right.

codeforcescompetitive-programmingbrute-forcegreedytwo-pointers
CF 2112F - Variables and Operations

We are given a directed system of value propagation rules over $n$ variables. Each rule says that one variable $x$ can potentially be reduced using the value of another variable $y$, shifted by a constant $z$, through an operation of the form $ax leftarrow min(ax, ay + z)$.

codeforcescompetitive-programminggraphsgreedyshortest-paths
CF 2112E - Tree Colorings

We are given a rooted tree, and every vertex must be assigned one of three colors: green, blue, or yellow. The root is fixed to be green. A coloring is considered valid when two connectivity constraints hold.

codeforcescompetitive-programmingcombinatoricsdfs-and-similardpgraphsmathnumber-theorytrees
CF 2112D - Reachability and Tree

We are asked to take an undirected tree and assign a direction to each edge so that the number of ordered vertex pairs $(u, v)$ where there is a directed path from $u$ to $v$ equals exactly $n$, the number of vertices.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similargraphstrees
Kvant Math Problem 734

Let $AB=c$, $AC=b$, and let $\angle A = \alpha$.

kvantmathematicsolympiad
CF 2112C - Coloring Game

We are given a sorted array of integers, and we need to count how many ways Alice can pick exactly three distinct indices such that no matter what Bob does afterward, Alice’s chosen triple is “safe”. The sequence of events matters. Alice first selects three elements.

codeforcescompetitive-programmingbinary-searchbrute-forcegreedytwo-pointers
CF 2112A - Race

In this problem, Alice and Bob are racing to a prize that will appear at one of two distinct points on a one-dimensional line. Alice has already chosen her starting point a.

codeforcescompetitive-programmingimplementationmath
CF 2112B - Shrinking Array

We are given an array of integers, and we want to make it "beautiful." A beautiful array has at least two elements and contains at least one pair of adjacent elements whose difference is at most one.

codeforcescompetitive-programmingbrute-forcegreedy
CF 2113E - From Kazan with Love

We are given a tree representing a city. Marat starts at vertex x at time 1 and wants to reach vertex y. Each day progresses in discrete time steps, and at each step he can either stay in place or move along one edge of the tree. At the same time, there are up to 200 enemies.

codeforcescompetitive-programmingdfs-and-similargraphsimplementationtrees
CF 2113F - Two Arrays

We are given two arrays, a and b, each containing n integers. We can swap elements between the arrays at the same index as many times as we like. The goal is to maximize the sum of the number of distinct elements in each array.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similargraphsmath
CF 2113D - Cheater

We are given two ordered stacks of cards, one belonging to the player and one belonging to the dealer. Both stacks contain distinct values, and each stack is played from top to bottom. In every round, both sides reveal their current top card.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsgreedyimplementation
CF 2113C - Smilo and Minecraft

We are given a grid where each cell is either empty, stone, or gold. Smilo can only place dynamite in empty cells. When he detonates at an empty cell, it affects a square region centered there with fixed radius k, so the square has side length 2k + 1.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedy
CF 2113B - Good Start

We are given a rectangular roof aligned with the coordinate axes, with width $w$ and height $h$. The roof lies in the plane starting from $(0,0)$. We also have identical rectangular tiles of fixed size $a times b$.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 2113A - Shashliks

We are given a grill that starts at some temperature and two types of shashlik that can be cooked repeatedly without limit. Each time we cook a portion, we must first check whether the current temperature is high enough, and then the grill’s temperature drops afterward.

codeforcescompetitive-programminggreedymath
CF 2114G - Build an Array

We start from an empty array and repeatedly append integers either to its left end or right end. After each insertion, the array may simplify itself: whenever two identical neighbors appear, they merge into a single element equal to their sum.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdpgreedymathnumber-theory
CF 2114F - Small Operations

We are given two integers, x and y, and an upper bound k. Our goal is to transform x into y using the fewest possible operations.

codeforcescompetitive-programmingbinary-searchbrute-forcedfs-and-similardpmathnumber-theorysortings
CF 2114E - Kirei Attacks the Estate

We are given a rooted tree where vertex 1 is the root, and each vertex has a numeric value. For every vertex $v$, we consider the path going upward from $v$ to the root.

codeforcescompetitive-programmingdfs-and-similardpgreedytrees
CF 2114D - Come a Little Closer

We are asked to destroy all monsters on a very large $10^9 times 10^9$ grid. Each monster occupies a distinct cell, and we are allowed to move exactly one monster to any empty cell before selecting a rectangle that covers some contiguous region of the grid.

codeforcescompetitive-programmingbrute-forcegreedyimplementationmath
CF 2114C - Need More Arrays

We are given a non-decreasing array of integers. The task is to remove zero or more elements to maximize the number of arrays formed according to a sequential rule.

codeforcescompetitive-programmingdpgreedy
CF 2114B - Not Quite a Palindromic String

We are given a binary string of even length and a target number of good pairs. A good pair consists of two characters symmetrically positioned around the center that are equal.

codeforcescompetitive-programminggreedymath
CF 2114A - Square Year

We are given a four-digit year as a string, potentially including leading zeros, and we are asked to determine if this number can be expressed as the square of the sum of two non-negative integers.

codeforcescompetitive-programmingbinary-searchbrute-forcemath
Kvant Math Problem 672

Let $f(n)=2^n-1$.

kvantmathematicsolympiad
CF 2115F1 - Gellyfish and Lycoris Radiata (Easy Version)

We are asked to maintain an array of n sets under a sequence of q online operations, where each operation modifies some prefix of sets or deletes a specific element from all sets, and then asks for the smallest element in a particular set.

codeforcescompetitive-programmingdata-structures
CF 2115E - Gellyfish and Mayflower

We are asked to navigate a directed acyclic graph (DAG) with vertices numbered from 1 to n. Each vertex contains a trader who sells cards with a given power for a given cost.

codeforcescompetitive-programmingdpgraphs
CF 2115A - Gellyfish and Flaming Peony

We start with a sequence of positive integers. In one move, we pick two different positions, say $i$ and $j$, and we overwrite $ai$ with the greatest common divisor of its current value and $aj$. The second element $aj$ stays unchanged.

codeforcescompetitive-programmingconstructive-algorithmsdpmathnumber-theory
Kvant Math Problem 575

Let $A_0A_1,\dots,A_{n-1}A_n$ be consecutive segments on a line with each length at most $1$.

kvantmathematicsolympiad
CF 2117D - Retaliation

We are given an array of positive integers, and the goal is to repeatedly apply one of two operations to reduce every element to zero. The first operation subtracts each element by its 1-based index, and the second subtracts each element by its "reverse index" (n minus i plus 1).

codeforcescompetitive-programmingbinary-searchmathnumber-theory
CF 2117A - False Alarm

We are given a sequence of doors arranged in a line. Each door is either open or closed. Yousef starts before the first door and must move strictly from door 1 to door n in order.

codeforcescompetitive-programminggreedyimplementation
CF 2118F - Shifts and Swaps

We are asked whether one array of integers, a, can be transformed into another array, b, using two types of operations. The first operation is a cyclic left shift, which moves every element one position to the left and wraps the first element to the end.

codeforcescompetitive-programmingdata-structuresgraphshashingtrees
CF 2118E - Grid Coloring

We have an odd-sized rectangular grid. Cells are colored one at a time. Whenever a new cell is colored, we look only at the cells that were already colored before this step. Among those cells, every cell that is farthest from the newly colored one receives one penalty.

codeforcescompetitive-programmingconstructive-algorithmsgeometrygreedymath
CF 2118D1 - Red Light, Green Light (Easy version)

We have a one-dimensional strip of length up to $10^{15}$, along which certain cells contain traffic lights. Each light has a fixed period $k$ and a delay $di < k$, and it turns red at times $l cdot k + di$ for integer $l ge 0$. All other times, the light is green.

codeforcescompetitive-programmingbrute-forcedfs-and-similardpgraphsimplementationnumber-theory
CF 2118D2 - Red Light, Green Light (Hard version)

We are asked to simulate motion along a one-dimensional strip of length up to $10^{15}$, where certain cells contain traffic lights with periodic red signals. Each traffic light has a fixed period $k$ and a delay $di$, meaning it shows red at times $t$ where $t mod k = di$.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresdfs-and-similardpgraphsimplementationmathnumber-theory
CF 2118C - Make It Beautiful

We are given an array of integers. Each integer has a "beauty" defined as the number of 1s in its binary representation. For example, 5 in binary is 101, which has two 1s, so its beauty is 2. The total beauty of the array is the sum of the beauties of all its elements.

codeforcescompetitive-programmingbitmasksdata-structuresgreedymath
CF 2118B - Make It Permutation

We start with an $n times n$ matrix where every row is identical and equal to the sequence $1,2,3,dots,n$. So initially every column is constant, and no column is a permutation at all.

codeforcescompetitive-programmingconstructive-algorithms
CF 2118A - Equal Subsequences

We are asked to construct a binary string of length $n$, containing exactly $k$ ones, with an additional structural constraint involving subsequences of length three.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 2119F - Volcanic Eruptions

We are given a rooted tree where every node carries a value of either +1 or −1. A lava wave starts from the root and expands outward one edge per time unit, so at time t every node at distance at most t from the root is already unsafe.

codeforcescompetitive-programmingdfs-and-similardpgreedyshortest-pathstrees
Kvant Math Problem 500

Label the people $1,2,\dots,N$ from left to right.

kvantmathematicsolympiad
CF 2119E - And Constraint

We are given two sequences, a of length n-1 and b of length n. The goal is to increase elements in b using the fewest increments so that for every adjacent pair (bi, b{i+1}), their bitwise AND equals ai.

codeforcescompetitive-programmingbitmasksdpgreedy
CF 2119D - Token Removing

We are given sequences where each position i can store a value a[i] between 0 and i inclusive. Think of the index i as a time step and also as the right endpoint of a segment. Now interpret the process that defines the weight.

codeforcescompetitive-programmingcombinatoricsdpmath
CF 2119C - A Good Problem

We are asked to construct an array of length n using integers within a given range [l, r], such that the bitwise AND of all elements equals the bitwise XOR of all elements. We do not need to output the full array; only the k-th element in lexicographical order.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsmath
CF 2119A - Add or XOR

We are given two non-negative integers a and b and two operations that can transform a. The first operation increments a by one at a cost x. The second operation flips the least significant bit of a (using a XOR 1) at a cost y.

codeforcescompetitive-programmingbitmasksgreedymath
CF 2119B - Line Segments

We are given two fixed points on a plane: a starting location and a destination. We also receive a sequence of movement lengths. At step i, we must move from our current position to any point whose Euclidean distance from the current position is exactly ai.

codeforcescompetitive-programminggeometrygreedymath
CF 2120G - Eulerian Line Graph

We are given a simple, connected graph $G$ with $n$ vertices and $m$ edges, and we are asked to examine the properties of its iterated line graph $L^k(G)$.

codeforcescompetitive-programminggraphsgreedymath
CF 2120E - Lanes of Cars

Each lane initially contains ai cars. If nobody moves, the cars in a lane leave one per second, so a lane of size x contributes $$1+2+dots+x=frac{x(x+1)}2$$ to the total angriness. Cars may switch lanes.

codeforcescompetitive-programmingbinary-searchdpternary-search
CF 2120F - Superb Graphs

We are given several graphs on the same vertex set. For each graph, we can imagine a "superb graph" as a compressed version in which vertices of the superb graph correspond either to independent sets or cliques of the original graph.

codeforcescompetitive-programming2-satgraphs
CF 2120D - Matrix game

We are asked to determine the smallest size of a matrix Aryan should request from Harshith to guarantee that Aryan can always find a submatrix of size $a times b$ filled with identical numbers.

codeforcescompetitive-programmingcombinatoricsmath
CF 2120C - Divine Tree

We are asked to construct a rooted tree of n nodes with a special property: each node has a divineness, which is the smallest node label on the path from the root to that node.

codeforcescompetitive-programmingconstructive-algorithmsgreedymathsortingstrees
CF 2120A - Square of Rectangles

We are given three axis-aligned rectangles. Their dimensions are already ordered so that $$l3 le l2 le l1$$ and $$b3 le b2 le b1.$$ The rectangles cannot be rotated.

codeforcescompetitive-programminggeometrymath
CF 2120B - Square Pool

We are given a square pool table of side length $s$ with pockets at the four corners. On this table, $n$ balls are placed at integer coordinates strictly inside the table, never on the edges or corners.

codeforcescompetitive-programminggeometry
CF 2121F - Yamakasi

We are given an integer array and, for each test case, two target values: a required subarray sum s and a required maximum value x. The task is to count how many contiguous subarrays have total sum exactly equal to s and whose largest element is exactly x.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresgreedytwo-pointers
CF 2121G - Gangsta

We are asked to process a binary string and compute, for every contiguous substring, the maximum frequency of either 0 or 1 in that substring, then sum these values across all substrings.

codeforcescompetitive-programmingdata-structuresdivide-and-conquermathsortings
Kvant Math Problem 456

At each vertex of the polyhedron, exactly three edges meet, so the vertex figure is a trihedral angle.

kvantmathematicsolympiad
CF 2121D - 1709

We are given two arrays, a and b, each of length n, containing all integers from 1 to 2n exactly once between them. The task is to rearrange the arrays using three types of swaps so that a is strictly increasing, b is strictly increasing, and at each position i, a[i] < b[i].

codeforcescompetitive-programmingimplementationsortings
CF 2121E - Sponsor of Your Problems

We are given two integers of equal length in decimal form, and we are allowed to pick any integer x that lies within the inclusive range between them.

codeforcescompetitive-programmingdpgreedyimplementationstrings
CF 2121C - Those Who Are With Us

We are given a rectangular grid of integers. In one move, we pick a single row and a single column. Every cell that lies in that chosen row or that chosen column gets decreased by one, with the intersection cell counted only once.

codeforcescompetitive-programminggreedyimplementation