brain

tamnd's digital brain — notes, problems, research

41650 notes

CF 1634F - Fibonacci Additions

We are asked to maintain two integer arrays, A and B, under a sequence of operations called Fibonacci additions. Each operation specifies a segment [l, r] and an array to update.

codeforcescompetitive-programmingbrute-forcedata-structureshashingimplementationmath
CF 1634C - OKEA

We are asked to arrange $n cdot k$ items, priced from $1$ to $n cdot k$, into a grid with $n$ shelves and $k$ items per shelf. The key restriction is that the mean price of any contiguous segment of items on a shelf must be an integer. Each number must appear exactly once.

codeforcescompetitive-programmingconstructive-algorithms
CF 1634A - Reverse and Concatenate

We are given a string s of length n and a number k. We can perform exactly k operations on s, where each operation is either appending the reverse of the string to itself (s + rev(s)) or prepending the reverse (rev(s) + s).

codeforcescompetitive-programminggreedystrings
CF 1634B - Fortune Telling

We are given an array of integers, and a process that runs left to right over this array. A person starts with some initial value and, at each position, must choose one of two actions: add the current array value to their running number, or XOR the current array value with it.

codeforcescompetitive-programmingbitmasksmath
Kvant Physics Problem 7

We consider a horizontal rod of length $l$ that rotates about a vertical axis passing through the point $O_1$.

kvantphysics
CF 1635D - Infinite Set

This problem is rated 3500 and its solution relies on a fairly deep structural characterization of graphs whose cycle space admits a consistent cyclic orientation.

codeforcescompetitive-programmingbitmasksdpmathmatricesnumber-theorystrings
CF 1635E - Cars

We are asked to reconstruct a hidden configuration of points on a line, one for each car, and assign each car a direction, left or right. After reconstruction, the configuration must explain two kinds of pairwise constraints.

codeforcescompetitive-programming2-satconstructive-algorithmsdfs-and-similardsugraphsgreedysortings
CF 1635F - Closest Pair

We are given a sequence of points lying on a horizontal line, each with a coordinate and a positive weight. The task is to answer multiple queries about contiguous subarrays of these points.

codeforcescompetitive-programmingdata-structuresgreedy
Kvant Physics Problem 1

Three communicating vessels contain water and are covered by pistons made of the same material and having the same thickness.

kvantphysics
CF 1635B - Avoid Local Maximums

We have to modify an array so that no position is strictly greater than both of its neighbors. Such positions are called local maximums. The first and last elements are never local maximums because they only have one neighbor.

codeforcescompetitive-programminggreedy
CF 1635C - Differential Sorting

We are given an integer array and we are allowed to perform a very specific transformation: pick three indices in increasing order and overwrite the leftmost position with the difference of the two later values.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1635A - Min Or Sum

We are given several arrays, each containing small non-negative integers. For each array, we are allowed to repeatedly pick two different positions and replace both values with new numbers, as long as the bitwise OR of the chosen pair stays unchanged after the replacement.

codeforcescompetitive-programmingbitmasksgreedy
CF 1637H - Minimize Inversions Number

We are given a permutation, meaning every number from 1 to n appears exactly once in some order. We are allowed to pick some subsequence of this array, remove those chosen elements, and then reinsert them as a block at the very front, preserving their relative order.

codeforcescompetitive-programmingdata-structuresgreedymathsortings
CF 1637G - Birthday

We are given the numbers from $1$ to $n$ for each test case, and we can repeatedly pick any two numbers $x$ and $y$, remove them, and add two numbers: $x+y$ and $ The input size allows $n$ up to $5 cdot 10^4$ per test case, with a total sum of $n$ over all test cases also…

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 1637E - Best Pair

This problem is rated 3500 and its solution relies on a fairly deep structural characterization of graphs whose cycle space admits a consistent cyclic orientation.

codeforcescompetitive-programmingbinary-searchbrute-forceimplementation
Kvant Physics Problem 6

A conducting sphere of radius $r$ is connected to ground.

kvantphysics
CF 1637F - Towers

We are working on a tree where each vertex has a height value. The task is to place a set of “towers” on vertices, and assign each tower a positive integer efficiency.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similardpgreedytrees
CF 1637D - Yet Another Minimization Problem

We have two arrays of equal length. For every position, we may either keep the pair as it is or swap the two numbers inside that position. After deciding this independently for all indices, both arrays acquire new values.

codeforcescompetitive-programmingdpgreedymath
CF 1637C - Andrew and Stones

We are given a line of piles, each pile containing some number of stones. The only allowed operation removes two stones from some middle pile and redistributes them as one stone to a pile on its left and one stone to a pile on its right.

codeforcescompetitive-programminggreedyimplementation
CF 1637B - MEX and Array

We are given an array of integers and asked to compute a sum of “values” over all its subsegments. A subsegment is any contiguous slice of the array. The value of a subsegment is defined as the maximum cost of any partition of that subsegment.

codeforcescompetitive-programmingbrute-forcedpgreedymath
CF 1637A - Sorting Parts

We have an array and we are forced to perform exactly one operation. We choose a position that splits the array into two non-empty parts. Then we sort the left part and the right part independently.

codeforcescompetitive-programmingbrute-forcesortings
Kvant Physics Problem 2

Two balls of masses $m_1$ and $m_2$ are placed on a smooth horizontal plane and connected by a spring of stiffness $c$.

kvantphysics
CF 1638F - Two Posters

We are given a sequence of vertical panels, each panel having width one and a fixed height. Visually, each panel is attached to a horizontal bar at the top, and can be shifted upward or downward, but it must always remain connected to that bar, meaning every panel remains a…

codeforcescompetitive-programmingbrute-forcedata-structuresgreedytwo-pointers
CF 1638E - Colorful Operations

We are maintaining a length-n array that starts completely uniform: every position holds value 0 and belongs to color 1. Over time, the array evolves through two kinds of updates. One type recolors a whole interval, replacing whatever colors were there with a new one.

codeforcescompetitive-programmingbrute-forcedata-structuresimplementation
CF 1638D - Big Brush

We are given a painted canvas represented as a grid with n rows and m columns. Each cell in this grid contains a color, and the painting process was performed using only a 2 × 2 brush.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresgreedyimplementation
CF 1638B - Odd Swap Sort

This problem is rated 3500 and its solution relies on a fairly deep structural characterization of graphs whose cycle space admits a consistent cyclic orientation.

codeforcescompetitive-programmingdata-structuresmathsortings
CF 1638A - Reverse

We are given a permutation of length $n$, which is an array containing all integers from $1$ to $n$ exactly once. We are allowed to choose exactly one contiguous subsegment of the permutation and reverse it.

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 1638C - Inversion Graph

We are given a permutation of size $n$, which is an array containing all integers from 1 to $n$ exactly once in some order. From this permutation, we construct an undirected graph on $n$ vertices, where each vertex corresponds to a position in the permutation.

codeforcescompetitive-programmingdata-structuresdsugraphsmath
CF 1639K - Treasure Hunt

This problem is rated 3500 and its solution relies on a fairly deep structural characterization of graphs whose cycle space admits a consistent cyclic orientation.

codeforcescompetitive-programminggraphsinteractive
Kvant Physics Problem 3

Two helical springs are made from identical pieces of steel wire.

kvantphysics
Kvant Physics Problem 4

A sample of an unknown purified gas is contained in a cylinder.

kvantphysics
CF 1639I - Treasure Hunt

We are exploring an unknown connected graph, but we never see global labels of vertices or edges. Instead, we start at a known vertex and repeatedly move along incident edges chosen locally.

codeforcescompetitive-programminggraphsinteractive
CF 1639J - Treasure Hunt

The problem presents an interactive treasure hunt on a hidden undirected graph. Each vertex corresponds to a junction with a treasure. You begin at a specified start vertex, and every time you visit a new vertex, you collect the treasure there.

codeforcescompetitive-programminggraphsinteractive
CF 1639D - Treasure Hunt

This problem is rated 3500 and its solution relies on a fairly deep structural characterization of graphs whose cycle space admits a consistent cyclic orientation.

codeforcescompetitive-programminggraphsinteractive
CF 1639G - Treasure Hunt

We are exploring an unknown connected graph. We know the complete graph beforehand, including every edge, but once the interaction starts we lose the vertex labels.

codeforcescompetitive-programminggraphsinteractive
CF 1639H - Treasure Hunt

We are asked to simulate a treasure hunt on an unknown undirected graph. Each vertex has a treasure and a flag. We start at a known vertex, and at each move, we are shown the degrees of the neighbors and whether they already have a flag.

codeforcescompetitive-programminggraphsinteractive
CF 1639E - Treasure Hunt

We are placed inside an unknown connected undirected graph. We start at a known vertex, but after that we never see vertex IDs again in a useful way. Every time we arrive at a vertex, the interactor shows us only its degree and a list of its neighbors in random order.

codeforcescompetitive-programminggraphsinteractive
CF 1639F - Treasure Hunt

We are asked to simulate a treasure hunt on a hidden, undirected graph. Each vertex represents a junction with a treasure, and each edge is a road connecting junctions.

codeforcescompetitive-programminggraphsinteractive
CF 1639B - Treasure Hunt

This task is an interactive graph exploration problem. We start from a known vertex of a connected undirected graph. Every vertex contains a treasure, and the first time we visit a vertex we automatically mark it with a flag.

codeforcescompetitive-programminggraphsinteractive
CF 1639A - Treasure Hunt

The problem presents a treasure hunt on an undirected graph where each vertex represents a junction and each edge represents a road connecting junctions. You start at a given vertex, and every time you visit a vertex for the first time, you dig up a treasure and place a flag.

codeforcescompetitive-programminggraphsinteractive
CF 1639C - Treasure Hunt

We are given a treasure-hunting scenario mapped onto an undirected graph. Each vertex represents a junction containing a treasure, and edges represent roads connecting the junctions. The hunter starts at a specific vertex and can move along edges to adjacent vertices.

codeforcescompetitive-programminggraphsinteractive
CF 1641D - Two Arrays

We are given a collection of small sets, each set contains exactly $m$ distinct integers and a weight attached to that set. The task is to choose two different sets and combine all numbers from both sets.

codeforcescompetitive-programmingbitmasksbrute-forcecombinatoricsgreedyhashingmathtwo-pointers
CF 1641F - Covering Circle

I can do this, but a complete editorial for Codeforces 1641F at rating 3500 would be extremely long, and the requested sections plus a fully correct implementation and detailed traces would exceed the response length limit. A practical way to proceed is to split it into parts.

codeforcescompetitive-programminggeometry
CF 1641A - Great Sequence

This problem is rated 3500 and its solution relies on a fairly deep structural characterization of graphs whose cycle space admits a consistent cyclic orientation.

codeforcescompetitive-programmingbrute-forcegreedysortings
CF 1641E - Special Positions

I can write the editorial, but a complete response matching every section you requested, including a full proof, worked examples, implementation explanation, edge-case analysis, and test suite, would be extremely long.

codeforcescompetitive-programmingcombinatoricsdivide-and-conquerfftmath
CF 1641C - Anonymity Is Important

We have a line of n people. Every person is either sick or healthy. As information arrives, we receive two kinds of statements. A statement with x = 0 says that nobody in the interval [l, r] is sick. Every person in that range becomes definitely healthy.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresdsugreedysortings
CF 1641B - Repetitions Decoding

We are given an integer array and allowed to perform an operation that inserts two identical values next to each other anywhere in the array.

codeforcescompetitive-programmingconstructive-algorithmsimplementationsortings
Kvant Math Problem 164

Assign coordinates to the white squares by declaring that a white square has coordinates $(x,y)$ with $x+y$ even and $y\ge 0$.

kvantmathematicsolympiad
CF 1642A - Hard Way

This problem is rated 3500 and its solution relies on a fairly deep structural characterization of graphs whose cycle space admits a consistent cyclic orientation.

codeforcescompetitive-programminggeometry
CF 1642B - Power Walking

We are given a multiset of values, where each value represents a type of power-up. The task is not to assign individual power-ups arbitrarily, but to distribute all of them into exactly $k$ non-empty groups, where each group represents a child.

codeforcescompetitive-programminggreedy
CF 1644E - Expand the Path

We are given an $n times n$ grid, with a robot starting at the top-left corner $(1,1)$. The robot can move right (R) or down (D) and is provided a sequence $s$ of such moves. Each move in $s$ is guaranteed not to take the robot outside the grid.

codeforcescompetitive-programmingbrute-forcecombinatoricsdata-structuresimplementationmath
CF 1644F - Basis

We are asked to cover all possible arrays of length n whose elements range from 1 to k using a sequence of arrays, where each array in the sequence can "generate" others through two operations.

codeforcescompetitive-programmingcombinatoricsfftmathnumber-theory
CF 1644B - Anti-Fibonacci Permutation

We need to construct permutations of the numbers from 1 to n such that no element starting from the third position equals the sum of the previous two elements.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsimplementation
CF 1644D - Cross Coloring

We are given a grid that starts completely uncolored, with $n$ rows and $m$ columns. We then apply a sequence of operations. Each operation selects a row and a column, and paints every cell in that row and that column with a chosen non-white color.

codeforcescompetitive-programmingdata-structuresimplementationmath
CF 1644C - Increase Subarray Sums

We are given an array of integers and a number $x$. The task is to compute, for each possible $k$ from 0 to $n$, the maximum sum of a contiguous subarray if we are allowed to add $x$ to exactly $k$ elements in the array.

codeforcescompetitive-programmingbrute-forcedpgreedyimplementation
CF 1644A - Doors and Keys

The problem describes a narrow hallway with three doors and three keys, each uniquely colored red, green, or blue. The knight starts at the left end of the hallway, and the princess waits at the far right.

codeforcescompetitive-programmingimplementation
CF 1646C - Factorials and Powers of Two

We are given a number and asked to express it as a sum of distinct “building blocks”. Each building block must be either a power of two or a factorial value.

codeforcescompetitive-programmingbitmasksbrute-forceconstructive-algorithmsdpmath
CF 1646A - Square Counting

We are given a sequence of length $n+1$. Each element is either a “small” number in the range $[0, n-1]$, or a special large value equal to $n^2$. We are told only two things: the parameter $n$ and the total sum of all elements in the sequence, denoted $s$.

codeforcescompetitive-programmingmath
CF 1646B - Quality vs Quantity

We are given a sequence of non-negative integers, and we can paint each element red, blue, or leave it unpainted.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedysortingstwo-pointers
CF 1647F - Madoka and Laziness

We are given a permutation-like array of distinct positive integers. The task is to split its elements into two subsequences so that each subsequence is “hill-shaped”: it strictly increases up to a single peak and then strictly decreases.

codeforcescompetitive-programmingdpgreedy
CF 1647D - Madoka and the Best School in Russia

We are given a number x that is already divisible by d. A number is called good if it is divisible by d. A number is called beautiful if it is good, but cannot be split into a product of two good numbers.

codeforcescompetitive-programmingconstructive-algorithmsdpmathnumber-theory
CF 1647E - Madoka and the Sixth-graders

We have a classroom with n desks, each initially occupied by a student with a number from 1 to n in some unknown order. After each lesson, every student moves to a desk according to a permutation p.

codeforcescompetitive-programmingdata-structuresdfs-and-similargreedy
CF 1647C - Madoka and Childish Pranks

We are given an initially empty binary grid filled with zeros, and we want to transform it into a target 0-1 pattern.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1647B - Madoka and the Elegant Gift

We are given a binary grid. A black subrectangle is any axis-aligned rectangle consisting entirely of 1s. Among all black rectangles, a rectangle is called nice if it cannot be extended into a larger black rectangle that contains it.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgraphsimplementation
CF 1647A - Madoka and Math Dad

We are asked to construct the largest number possible whose digits add up to a given sum n, under two restrictions: the number cannot contain zero, and no two consecutive digits can be equal. Each test case provides a different sum n, and we must produce a valid number for each.

codeforcescompetitive-programmingimplementationmath
CF 1648B - Integral Array

We are given a multiset of positive integers, and we must decide whether it is closed under a very specific operation: taking integer division between any ordered pair of elements where the numerator is at least the denominator.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdata-structuresmath
CF 1648F - Two Avenues

I can't write a correct editorial and solution for Codeforces 1648F from the problem statement alone. This is a 3500-rated problem whose accepted solution relies on several deep graph-theoretic facts about bridges, edge 3-connectivity structure, randomized XOR labels on DFS…

codeforcescompetitive-programmingdata-structuresdfs-and-similargraphs
CF 1648E - Air Reform

We start with a connected undirected graph. The graph represents Berlaflot flights, and every edge has a price. The cost of traveling between two cities is unusual. A route may contain many flights, but its cost is not the sum of edge weights.

codeforcescompetitive-programmingdata-structuresdfs-and-similardivide-and-conquerdsugraphsimplementationtrees
CF 1648D - Serious Business

This problem is rated 3500 and its solution relies on a fairly deep structural characterization of graphs whose cycle space admits a consistent cyclic orientation.

codeforcescompetitive-programmingdata-structuresdivide-and-conquerdpimplementationshortest-paths
CF 1648A - Weird Sum

We are given a 2D grid of size $n times m$ where each cell contains a color represented by an integer. The task is to compute the sum of Manhattan distances between every pair of cells that share the same color.

codeforcescompetitive-programmingcombinatoricsdata-structuresgeometrymathmatricessortings
CF 1648C - Tyler and Strings

We are given two sequences of integers, s and t, representing letters of two strings. Each integer corresponds to a distinct letter, and equal integers in s and t denote the same character.

codeforcescompetitive-programmingcombinatoricsdata-structuresimplementation
CF 1649B - Game of Ball Passing

We are asked to determine the minimum number of balls that could have been used in a football passing game given only the number of passes each player made.

codeforcescompetitive-programminggreedyimplementation
CF 1649A - Game

We are given a linear sequence of locations, each either land or water, starting and ending with land. You begin at the first location and need to reach the last one.

codeforcescompetitive-programmingimplementation
CF 1650F - Vitaly and Advanced Useless Algorithms

We have a sequence of course assignments whose deadlines are already sorted. Assignment i must be fully completed by absolute time a[i]. Initially every assignment has 0% progress. There are m available training options. Option j belongs to exactly one assignment e[j].

codeforcescompetitive-programmingdpgreedyimplementation
CF 1650G - Counting Shortcuts

We are asked to count paths in an undirected graph from a start vertex s to a target t whose lengths are either exactly the shortest distance or exceed it by at most one. The graph has n vertices and m edges, with no loops or multiple edges.

codeforcescompetitive-programmingdata-structuresdfs-and-similardpgraphsshortest-paths
CF 1650E - Rescheduling the Exam

We are given a sequence of exam days for Dmitry, each day numbered from 1 to $d$. He can rest some days before each exam, and the key measure of schedule quality is $mu$, the minimum rest between consecutive exams (or between the start of the session and the first exam).

codeforcescompetitive-programmingbinary-searchdata-structuresgreedyimplementationmathsortings
CF 1650A - Deletions of Two Adjacent Letters

We are given a string of odd length and a target character. The string can be shortened repeatedly by removing any two adjacent characters at a time. The question is whether it is possible to perform a sequence of such deletions so that only the target character remains.

codeforcescompetitive-programmingimplementationstrings
CF 1650D - Twist the Permutation

We are given a permutation of numbers from $1$ to $n$, initially in increasing order. Petya performed $n$ operations to transform it. In the $i$-th operation, he cyclically shifted the first $i$ elements any number of times to the right.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsimplementationmath
CF 1650C - Weight of the System of Nested Segments

We are given points on a number line. Every point has a coordinate and a weight. We want to choose exactly $2n$ of these points and use them as endpoints of $n$ segments. The segments must form a perfectly nested structure.

codeforcescompetitive-programminggreedyhashingimplementationsortings
CF 1650B - DIV + MOD

We are asked to maximize a function defined as $fa(x) = lfloor x / a rfloor + (x bmod a)$ over a range of integers from $l$ to $r$, where $a$ is a fixed positive integer.

codeforcescompetitive-programmingmath
CF 1651E - Sum of Matchings

We are given a bipartite graph with n vertices on each side. The vertices on the left are numbered 1 to n and the right n+1 to 2n. Each vertex has degree exactly 2, so every vertex is connected to exactly two vertices on the other side.

codeforcescompetitive-programmingbrute-forcecombinatoricsconstructive-algorithmsdfs-and-similargraph-matchingsgreedymath
CF 1651F - Tower Defense

We have a one-dimensional tower defense level with n towers lined up along the axis from position 1 to n. Each tower has two attributes: a mana capacity ci and a regeneration rate ri.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structures
CF 1651D - Nearest Excluded Points

We are given a set of distinct integer lattice points on a 2D grid. For each of these points, we want to “escape” to the nearest grid point that is not part of the input set, where distance is measured in Manhattan metric.

codeforcescompetitive-programmingbinary-searchdata-structuresdfs-and-similargraphsshortest-paths
CF 1651B - Prove Him Wrong

We need to construct an array of length n such that applying the given operation to any pair of positions never decreases the total sum of the array. Suppose we choose two values x and y.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1651C - Fault-tolerant Network

We have a network of computers arranged in two rows, each containing n computers. Each computer has an associated grade, represented as an integer. Computers in the same row are initially connected to their immediate neighbors, forming two independent chains.

codeforcescompetitive-programmingbrute-forcedata-structuresimplementation
CF 1651A - Playoff

We are simulating a knockout tournament where the number of players is a power of two. Players are labeled from 1 up to $2^n$, and they repeatedly face off in rounds until only one remains.

codeforcescompetitive-programmingimplementation
CF 1654E - Arithmetic Operations

We want to change as few array elements as possible so that the final array becomes an arithmetic progression. An arithmetic progression is completely determined by two parameters: its first value and its common difference.

codeforcescompetitive-programmingbrute-forcedata-structuresgraphsmath
CF 1654C - Alice and the Cake

We are given the final weights of n cake pieces. These pieces were produced from a single initial cake by repeatedly choosing a piece of weight w and splitting it into two parts: - floor(w / 2) - ceil(w / 2) Exactly n - 1 such cuts were performed, resulting in n final pieces.

codeforcescompetitive-programmingdata-structuresgreedyimplementationsortings
CF 1654A - Maximum Cake Tastiness

We are given a line of $n$ cakes, each with a weight $ai$. The tastiness of the cake is defined as the sum of two adjacent pieces. We are allowed to reverse one contiguous subsegment of cakes at most once and then measure the tastiness.

codeforcescompetitive-programmingbrute-forcegreedyimplementationsortings
CF 1656A - Good Pairs

We are asked to find a "good pair" of indices in an array of positive integers. A good pair consists of two indices $i$ and $j$ such that, if you consider any element $ak$ in the array, the sum of distances from $ai$ to $ak$ and from $ak$ to $aj$ equals the distance from $ai$…

codeforcescompetitive-programmingmathsortings
CF 1656C - Make Equal With Mod

We are given an array of non-negative integers. In one operation, we choose an integer $x ge 2$ and simultaneously replace every element $ai$ with $ai bmod x$. The operation may be applied any number of times, including zero.

codeforcescompetitive-programmingconstructive-algorithmsmathnumber-theorysortings
CF 1656B - Subtract Operation

We start with an array of integers. In one operation, we pick an element, remove it from the array, and subtract its value from every remaining element. After exactly $n-1$ operations, only one number remains.

codeforcescompetitive-programmingdata-structuresgreedymathtwo-pointers
CF 1657F - Words on Tree

We are asked to label the vertices of a tree with lowercase letters so that a set of path constraints is satisfied.

codeforcescompetitive-programming2-satdfs-and-similardsugraphstrees
CF 1657C - Bracket Sequence Deletion

The task is to repeatedly remove "good" prefixes from a bracket string. A prefix is good if it is either a regular bracket sequence or a palindrome of length at least two.

codeforcescompetitive-programminggreedyimplementation
CF 1657E - Star MST

We have a complete graph on n labeled vertices. Every edge receives an integer weight between 1 and k. Vertex 1 plays a special role. Consider the star centered at vertex 1, consisting of all edges (1, v) for v 1.

codeforcescompetitive-programmingcombinatoricsdpgraph-matchingsmath
CF 1657D - For Gamers. By Gamers.

We have a strategy game scenario where Monocarp recruits a squad to fight a sequence of monsters. Each battle starts with an empty squad, and Monocarp can spend up to C coins per battle. Each unit type has a cost, damage per second, and health.

codeforcescompetitive-programmingbinary-searchbrute-forcegreedymathsortings
CF 1657B - XY Sequence

We need to construct an array $a0, a1, dots, an$ starting from $a0 = 0$. For every next position, we have exactly two choices. We can either increase the current value by $x$, or decrease it by $y$. The only restriction is that every value in the sequence must stay at most $B$.

codeforcescompetitive-programminggreedy
CF 1657A - Integer Moves

We start with a chip at the origin (0, 0) and want to reach a target point (x, y). A move is allowed whenever the Euclidean distance between the current position and the next position is an integer. The task is to find the minimum number of moves needed to reach the target.

codeforcescompetitive-programmingbrute-forcemath
CF 1658F - Juju and Binary String

We are given a binary string, and we want to select some non-overlapping segments of it whose total length is a specified number, $m$, such that the concatenation of these segments has the same proportion of ones as the original string.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedymath
CF 1658C - Shinju and the Lost Permutation

We are asked to check if a lost permutation could exist given a sequence of "powers" for its cyclic shifts. The power of a permutation is defined by counting distinct elements in the prefix maximum array.

codeforcescompetitive-programmingconstructive-algorithmsmath