brain

tamnd's digital brain — notes, problems, research

41650 notes

CF 2132D - From 1 to Infinity

We are asked to consider an infinite string formed by writing all positive integers consecutively: 123456789101112... and so on. For each test case, we are given a number k representing the number of digits to take from the start of this infinite string.

codeforcescompetitive-programmingbinary-searchdpimplementationmath
CF 2132A - Homework

We start with a string a. Another string b contains characters that must be inserted one by one, in the order they appear. For every position i in b, the corresponding character c[i] tells us who inserts that character.

codeforcescompetitive-programmingbrute-forceimplementationstrings
CF 2132B - The Secret Number

We are given a number $n$ that was constructed in a very specific way. Someone secretly chose an integer $x$, then created another number $y$ by appending one or more zeros to the right of $x$. That means $y = x cdot 10^k$ for some $k ge 1$.

codeforcescompetitive-programmingmath
CF 2132C1 - The Cunning Seller (easy version)

The problem gives us a seller who offers watermelons in bundles of sizes that are powers of three. Each bundle of size $3^x$ costs $3^{x+1} + x cdot 3^{x-1}$ coins.

codeforcescompetitive-programminggreedymath
CF 2133D - Chicken Jockey

Working

codeforcescompetitive-programmingdpgreedy
CF 2133E - I Yearned For The Mines

We are working on a tree where an adversary occupies exactly one node, but we never know which one. The adversary is also reactive: after each of our actions, they are allowed to move along one edge or stay in place, except in the special case where we directly queried their…

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similardpgreedytrees
CF 2133F - Flint and Steel

We are given a line of creepers, each with an explosive power. Detonating a creeper at position $i$ kills all creepers within distance less than its explosive power, specifically positions $j$ such that $ The input consists of multiple test cases, each with $n$ creepers and an…

codeforcescompetitive-programmingdata-structuresdpgraphs
CF 2133C - The Nether

We are given a network of nether portals represented as a directed acyclic graph. Each portal may have directed connections to other portals, but there are no cycles. The task is to find a longest path in this hidden DAG.

codeforcescompetitive-programminggraphsinteractive
CF 2133B - Villagers

We are given several independent scenarios. In each scenario, there are $n$ villagers, and each villager starts with a non-negative integer value called grumpiness.

codeforcescompetitive-programminggreedy
CF 2133A - Redstone?

We are asked to decide whether a sequence of gears can be arranged in a line such that spinning the leftmost gear at one revolution per second results in the rightmost gear spinning exactly at one revolution per second.

codeforcescompetitive-programmingbrute-forcedata-structuresimplementationmath
CF 2134D - Sliding Tree

We are given a tree and a very specific local rewiring operation. The operation picks a vertex $b$ with two distinguished neighbors $a$ and $c$. After that, every other neighbor of $b$ is detached from $b$ and reattached to $c$.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similargreedyimplementationtrees
CF 2134E - Power Boxes

We are given a sequence of boxes, each with a hidden power of either 1 or 2. The boxes are placed on a number line at positions 1 through n. We need to discover the power of each box using two interactive queries: swapping adjacent boxes and throwing a ball at a box.

codeforcescompetitive-programmingconstructive-algorithmsdpimplementationinteractive
CF 2134F - Permutation Oddness

We are given counts for four integers, 0 through 3. Specifically, $c0$ copies of 0, $c1$ copies of 1, $c2$ copies of 2, and $c3$ copies of 3. From this, we can form an array of length $n = c0 + c1 + c2 + c3$.

codeforcescompetitive-programmingcombinatoricsdpmath
CF 2134C - Even Larger

We are given an array of non-negative integers and we need to make it good by performing the minimum number of operations.

codeforcescompetitive-programmingbrute-forcegreedyimplementation
CF 2134A - Painting With Two Colors

We are given a row of n cells, all initially white. We have two painting operations. The first operation paints a consecutive cells red, starting at any position x such that the red block fits entirely within the row.

codeforcescompetitive-programmingconstructive-algorithmsimplementationmath
CF 2134B - Add 0 or K

We are given an array of positive integers and a positive integer $k$. For each element of the array, we are allowed to either leave it as-is or add $k$ to it in one operation.

codeforcescompetitive-programmingconstructive-algorithmsmathnumber-theory
CF 2135F - To the Infinity

We are given a rooted full binary tree where every node represents a function built recursively from its children. Leaves behave simply: their function is just the identity map $fu(x) = x$.

codeforcescompetitive-programmingdata-structureshashingmathtrees
CF 2135E2 - Beyond the Palindrome (Hard Version)

We are asked to count binary strings of a given length that are almost-palindromes under a specific transformation. For a binary string, repeatedly deleting all occurrences of the substring 10 yields a "reduced" string.

codeforcescompetitive-programmingcombinatoricsdpmathnumber-theory
CF 2135D2 - From the Unknown (Hard Version)

The task is to determine the unknown width parameter $W$ of a text editor. The editor displays a sequence of words, each represented by its length, on lines of width $W$.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsinteractivemath
CF 2135E1 - Beyond the Palindrome (Easy Version)

We are asked to count a specific subset of binary strings of length $n$, which are called almost-palindromes. The key to understanding this problem is the function $f(r)$, which repeatedly deletes all occurrences of the substring 10 from a binary string $r$ until no 10 remains.

codeforcescompetitive-programmingcombinatoricsdpmath
CF 2135D1 - From the Unknown (Easy Version)

We are trying to determine an unknown integer parameter $W$, the width of lines in a text editor. Each article we submit is a sequence of positive integers representing word lengths.

codeforcescompetitive-programmingconstructive-algorithmsinteractivemath
CF 2135A - Against the Difference

We are given an array of integers, and we want to find the length of the longest subsequence that can be split into "blocks". A block is defined as a contiguous sequence where every element equals the length of that sequence.

codeforcescompetitive-programmingdata-structuresdp
CF 2135C - By the Assignment

We are given a connected undirected graph where each vertex may have a weight, but some weights are missing and represented by -1. The goal is to fill in the missing weights such that the graph becomes balanced.

codeforcescompetitive-programmingbinary-searchbitmaskscombinatoricsdfs-and-similardsugraphsmath
CF 2135B - For the Champion

The original problem is interactive. We know a set of anchor points, and there is a hidden robot position. By moving the robot and observing the minimum Manhattan distance to any anchor, we must recover the initial coordinates.

codeforcescompetitive-programmingconstructive-algorithmsinteractivemath
CF 2136A - In the Dream

We know the score at halftime and the score at full time. If the halftime score is a:b, then during the first half the RiOI team scored exactly a goals and the KDOI team scored exactly b goals.

codeforcescompetitive-programminggreedymath
CF 2137G - Cry Me a River

We are given a directed acyclic graph with n nodes and m edges. Each node starts colored blue, and players Cry and River play a two-player token game. The token starts at a node s. Cry moves first, then River, and they alternate.

codeforcescompetitive-programmingdfs-and-similardpgamesgraphs
CF 2137D - Replace with Occurrences

We are given a sequence of numbers, and we want to interpret each number in that sequence as a frequency requirement for some unknown array we must construct.

codeforcescompetitive-programmingconstructive-algorithms
CF 2137F - Prefix Maximum Invariance

For any array $x$, its sequence of prefix maxima is completely determined. At position $i$, the prefix maximum is $$max(x1,x2,dots,xi).$$ We are allowed to build another array $z$ whose prefix maxima are identical to those of $x$.

codeforcescompetitive-programmingbinary-searchcombinatoricsdata-structuressortings
CF 2137E - Mexification

We are given an array of integers and asked to perform a special transformation multiple times. For each element in the array, we replace it with the minimum non-negative integer that does not appear anywhere else in the array.

codeforcescompetitive-programmingbrute-forceimplementationmath
CF 2137A - Collatz Conjecture

We are given the result of running the Collatz operation exactly k times and the final value x. The task is not to find the original value uniquely, because many different starting values may lead to the same result.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 2137C - Maximum Even Sum

We are given two integers, $a$ and $b$, and we can pick a positive integer $k$ such that $b$ is divisible by $k$. Then we replace $a$ with $a cdot k$ and $b$ with $b / k$. The goal is to make the sum $a + b$ as large as possible while ensuring it is even.

codeforcescompetitive-programmingbrute-forcegreedyimplementationmath
CF 2137B - Fun Permutation

We are given a permutation $p$ of size $n$, meaning it contains each integer from $1$ to $n$ exactly once. We must construct another permutation $q$ of the same size, also a rearrangement of $1$ to $n$, with a structural constraint linking adjacent positions.

codeforcescompetitive-programmingconstructive-algorithmsmathnumber-theory
CF 2138F - Ode to the Bridge Builder

We start with two fixed points in the plane, one at the origin and one at $(1,0)$, connected by a segment. The only allowed way to create new points is by repeatedly selecting an existing segment, treating its endpoints as two vertices of a triangle, and then placing a third…

codeforcescompetitive-programmingconstructive-algorithmsgeometry
CF 2138E2 - Determinant Construction (Hard Version)

We are asked to construct a square matrix with small integer entries, limited non-zero elements per row and column, and a determinant equal to a given target number.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsmathmatricesnumber-theory
CF 2138E1 - Determinant Construction (Easy Version)

The determinant can be written using the Leibniz formula: $$det(M)=sum{sigma} operatorname{sgn}(sigma)prodi M{i,sigma(i)}.$$ A brute force viewpoint is to think of each permutation as choosing one outgoing edge from every row and one incoming edge into every column.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsmathmatricesnumber-theory
CF 2138D - Antiamuny and Slider Movement

We are given a sorted line of unit-sized sliders placed on integer positions along a very long track. Each slider keeps a fixed identity, and the initial configuration is strictly increasing, meaning no two sliders start at the same position.

codeforcescompetitive-programmingbrute-forcecombinatoricsimplementationmathsortings
CF 2138C2 - Maple and Tree Beauty (Hard Version)

We are given a rooted tree with n vertices. Each vertex must be labeled either 0 or 1, with exactly k zeros and n - k ones. The "name" of a vertex is the string formed by concatenating the labels along the path from the root to that vertex.

codeforcescompetitive-programmingbitmasksbrute-forcedfs-and-similardpffttrees
CF 2138B - Antiamuny Wants to Learn Swap

We are given a permutation of integers from 1 to $n$, and we must answer multiple queries about whether certain subarrays are "perfect" according to a special sorting rule.

codeforcescompetitive-programmingdata-structuresgreedytwo-pointers
CF 2138A - Cake Assignment

We have two people, Chocola and Vanilla, who start with exactly the same number of cakes, which is $2^k$ each. The total number of cakes is $2^{k+1}$. The goal is to redistribute the cakes so that Chocola ends up with exactly $x$ cakes and Vanilla gets the rest.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsgreedy
CF 2138C1 - Maple and Tree Beauty (Easy Version)

We are given a rooted tree with n vertices, where the root is vertex 1. Each vertex is labeled either 0 or 1, but we do not know the exact labeling. All we know is that exactly k vertices have label 0, and the remaining n - k have label 1.

codeforcescompetitive-programmingbrute-forcedfs-and-similardpgraphstrees
CF 2139A - Maple and Multiplication

We are asked to make two positive integers equal using a series of multiplication operations. Maple can choose either number and multiply it by any positive integer of her choice. The goal is to do this in the minimum number of operations.

codeforcescompetitive-programminggreedymath
CF 2140F - Sum Minimisation

We are given an array of integers and a special operation that can decrease some of its elements. For any chosen set of $k$ distinct indices, we sum the selected elements, take the remainder of this sum modulo $k$, and then decrease the smallest $y$ elements by 1, where $y$ is…

codeforcescompetitive-programmingnumber-theory
CF 2140E2 - Prime Gaming (Hard Version)

We have a sequence of n piles. The number of stones in each pile can be any integer from 1 to m. The game itself does not depend on the stone values while moves are being made. Players only choose positions to delete.

codeforcescompetitive-programmingbitmaskscombinatoricsdpprobabilities
CF 2140E1 - Prime Gaming (Easy Version)

We have a row of n piles. Each pile contains either 1 or 2 stones because this is the easy version and m ≤ 2. The game does not modify pile values. Players only remove piles.

codeforcescompetitive-programmingbitmaskscombinatoricsdp
CF 2140D - A Cruel Segment's Thesis

We are given several intervals on a number line. Each interval represents a “resource” with a left and right boundary. Initially none of these intervals are used. We repeatedly pick two unused intervals, and from each chosen interval we pick one point inside it.

codeforcescompetitive-programmingdata-structuresgreedysortings
CF 2140C - Ultimate Value

We are given a game played on an array of integers where two players take turns performing a single action: either end the game immediately or swap two elements at positions $l$ and $r$, which adds $r-l$ to a running cost.

codeforcescompetitive-programmingdata-structuresgamesgreedy
CF 2140A - Shift Sort

We are given a binary string, which is a sequence of 0s and 1s, and the goal is to sort it into non-decreasing order using a specific operation.

codeforcescompetitive-programminggreedysortings
CF 2140B - Another Divisibility Problem

We are given a number $x$, and we must construct another positive integer $y$ such that a specific divisibility condition holds. The construction depends on forming a new number by concatenating the decimal representation of $x$ followed immediately by $y$.

codeforcescompetitive-programmingconstructive-algorithmsmathnumber-theory
CF 2141I - Color the Tree

We are working with a tree where every vertex starts uncolored. In one move, we pick any two vertices, possibly the same vertex twice, and we “recolor” every vertex on the unique path between them.

codeforcescompetitive-programming*special
CF 2141H - Merging Vertices in a Graph

We start with an undirected simple graph on $n$ vertices. The graph evolves through an operation that removes two existing vertices and replaces them with a new vertex whose neighborhood is exactly the intersection of the neighborhoods of the removed vertices.

codeforcescompetitive-programming*specialdfs-and-similardsugraphs
CF 2141C - Minimum on Subarrays

The problem asks us to simulate a special structure that supports adding and removing elements from both ends, along with a min operation that accumulates the minimum of all current elements into a running sum.

codeforcescompetitive-programming*specialbrute-force
CF 2141A - Furniture Store

We are given a list of sofa models, each positioned on a website in a fixed order. Every model has a price, and every customer scans the list from left to right, picking the first sofa whose price does not exceed their budget.

codeforcescompetitive-programming*specialimplementation
CF 2143F - Increasing Xor

We are given an array of small integers, and we are allowed to repeatedly pick two positions inside a chosen segment and XOR the value at the later index with the value at the earlier index.

codeforcescompetitive-programmingbitmasksdata-structuresmath
CF 2143D2 - Inversion Graph Coloring (Hard Version)

We are given a sequence of integers and asked to count how many of its subsequences can be colored in red and blue such that, for every inversion (a pair of indices $i < j$ with $ai aj$), the two elements have different colors.

codeforcescompetitive-programmingbinary-searchcombinatoricsdata-structuresdptwo-pointers
CF 2143E - Make Good

We start with a string made only of opening and closing brackets. The string is not fixed: we are allowed to repeatedly pick two adjacent identical brackets and flip them as a pair.

codeforcescompetitive-programmingconstructive-algorithmsgreedymathstrings
CF 2143D1 - Inversion Graph Coloring (Easy Version)

We are given a sequence of integers, each between 1 and n, and we want to count subsequences that can be “colored” red or blue in such a way that every inversion in the subsequence has endpoints of different colors.

codeforcescompetitive-programmingcombinatoricsdata-structuresdpgreedytwo-pointers
CF 2143A - All Lengths Subtraction

We are given a permutation of length $n$, which is an array containing all integers from 1 to $n$ in some order, with no duplicates. We must perform a series of exactly $n$ operations, one for each $k$ from 1 to $n$.

codeforcescompetitive-programmingbrute-forcetwo-pointers
CF 2143B - Discounts

We are asked to buy a set of products with individual prices while minimizing the total cost using discount vouchers. Each voucher allows you to pick a fixed number of products and get the cheapest among them for free.

codeforcescompetitive-programminggreedysortingstwo-pointers
CF 2143C - Max Tree

We are given a tree with n vertices and n-1 edges, each edge carrying two non-negative integers x and y. The problem asks us to assign distinct integers from 1 to n to the vertices so that the sum of edge contributions is maximized.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similargraphsgreedy
CF 2144E1 - Looking at Towers (easy version)

We are given an array of tower heights, and we consider subsequences formed by deleting some elements while preserving order. For any chosen subsequence, we “scan” it from the left and record every element that is strictly larger than all previously seen elements.

codeforcescompetitive-programmingcombinatoricsdp
CF 2144F - Bracket Groups

We are given several bracket strings, each of length at most $k$, and we must assign every string to exactly one group. For each group we also construct a single “reference” regular bracket sequence of length exactly $k$.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdpstring-suffix-structuresstrings
CF 2144E2 - Looking at Towers (difficult version)

We are given a sequence of tower heights and need to count subsequences that preserve the "visibility from left" and "visibility from right" sets.

codeforcescompetitive-programmingcombinatoricsdata-structuresdp
CF 2144D - Price Tags

We are running a clearance sale for a store with multiple items, each with a fixed original price. The store allows a uniform discount via division by an integer factor $x 1$, where the new price of an item is the ceiling of its original price divided by $x$.

codeforcescompetitive-programmingbrute-forcedpmath
CF 2144B - Maximum Cost Permutation

We are given an array p of length n where some positions contain integers from 1 to n and others are zeros. No positive integer appears more than once.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 2144A - Cut the Array

We are given an array of non-negative integers and are asked to split it into three contiguous non-empty subarrays: a prefix, a middle part, and a suffix. For each subarray, we calculate the sum modulo 3.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsmathnumber-theory
CF 2144C - Non-Descending Arrays

We are given two integer arrays of the same length, a and b. At each index, we can either leave the elements as they are or swap a[i] with b[i]. After performing any subset of these swaps, both arrays must be non-descending for the subset to be considered "good.

codeforcescompetitive-programmingcombinatoricsdpmath
CF 2145E - Predicting Popularity

We are tasked with predicting how many users on a streaming platform will watch a movie, given each user's preference for action and drama, and the movie's action and drama levels. Each user has thresholds for action and drama.

codeforcescompetitive-programmingbinary-searchdata-structuresgreedysortings
CF 2145G - Cost of Coloring

We are given a rectangular sheet with $n$ rows and $m$ columns, initially uncolored. Our task is to determine how many ways we can color it “beautifully” with exactly $k$ colors, using the fewest operations possible for each number of operations from $min(n, m)$ to $n+m-1$.

codeforcescompetitive-programmingcombinatoricsdivide-and-conquerdpfftmath
CF 2145F - Long Journey

We are given a very long one-dimensional strip of cells, numbered from 0 up to m. A chip starts at cell 0 and wants to reach cell m in as few turns as possible. Each turn, the chip either stays where it is or moves one step to the right.

codeforcescompetitive-programmingdfs-and-similardivide-and-conquerdpgraphsgreedymathmatricesnumber-theory
CF 2145D - Inversion Value of a Permutation

We are asked to construct a permutation of length $n$, meaning we must arrange the numbers from $1$ to $n$ exactly once in some order. For any fixed permutation, we can look at its inversions, which are pairs of positions where a larger number appears before a smaller one.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similardp
CF 2145C - Monocarp's String

We are given a binary string consisting only of a and b. From this string, we are allowed to remove exactly one contiguous block of characters, possibly empty. After this deletion, we look at the remaining characters and count how many a and b are left.

codeforcescompetitive-programmingbinary-searchgreedystrings
CF 2145B - Deck of Cards

We are given a deck of cards numbered from 1 to n, initially sorted with 1 on top and n on the bottom. Monocarp performs a sequence of k operations that remove cards from either the top, the bottom, or ambiguously from either end.

codeforcescompetitive-programminggreedyimplementation
CF 2145A - Candies for Nephews

Monocarp wants to divide a certain number of candies evenly among his three nephews. He starts with n candies and needs to figure out how many more, if any, he must buy to make the total divisible by three.

codeforcescompetitive-programmingmath
CF 2146F - Bubble Sort

The task is to count permutations of length $n$ that satisfy a specific condition derived from bubble sort. For a permutation $p$, define $bi$ as the number of bubble sort rounds required to sort the prefix $[p1, dots, pi]$.

codeforcescompetitive-programmingbrute-forcecombinatoricsdp
CF 2146E - Yet Another MEX Problem

We are given an array that grows one element at a time from left to right. After each new element is appended, we look at all subarrays that end exactly at this new position. Among those subarrays, we want the one that maximizes a particular score.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdata-structuresdivide-and-conquergreedyhashing
CF 2146D2 - Max Sum OR (Hard Version)

We are given an integer interval $[l, r]$. From this interval we form a list containing every integer exactly once. One copy of this list is fixed as array $b$. The other copy, array $a$, is initially identical but we are allowed to permute it arbitrarily.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsdivide-and-conquergreedy
CF 2146D1 - Max Sum OR (Easy Version)

We are given two integers, l and r, where l is always zero in this easy version and r is less than 200,000. From these, we define an array b that contains every integer from l to r, inclusive. We are allowed to permute a copy of this array, which we call a.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsdivide-and-conquergreedytrees
CF 2146B - Merging the Sets

We are given several collections of integers, where each collection can be thought of as a “bundle of labels” from the range $1$ to $m$.

codeforcescompetitive-programminggreedyimplementation
CF 2146C - Wrong Binary Search

We are asked to construct a permutation of integers from 1 to n based on a binary string that marks which numbers are “stable” under a randomized variant of binary search.

codeforcescompetitive-programmingbinary-searchconstructive-algorithms
CF 2146A - Equal Occurrences

We are given a non-decreasing array of integers, and we want to find a subsequence whose elements all appear the same number of times. A subsequence can skip elements but cannot change their order.

codeforcescompetitive-programmingbrute-forcegreedyimplementation
CF 2147I2 - Longest Increasing Path (Hard Version)

We are asked to construct a long sequence of integers, where the sequence behaves like a walk on the number line. Each consecutive pair defines a jump distance, and these jump distances must strictly increase as we move along the sequence.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 2147G - Modular Tetration

We are asked to analyze sequences generated by repeated exponentiation modulo a given number. Specifically, for a positive integer $a$, we define a sequence $bn$ by $b0 = 1$ and $bn = a^{b{n-1}}$ for $n ge 1$.

codeforcescompetitive-programmingcombinatoricsmathnumber-theory
CF 2147I1 - Longest Increasing Path (Easy Version)

We are asked to construct a sequence of integers of length $n$ placed on the number line. The only structural constraint is about consecutive jumps: if we define the jump sizes as $ So the sequence of distances is strictly increasing, while the actual points $ai$ can move left…

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 2147H - Maxflow GCD Coloring

The graph defines a family of pairwise connectivity strengths. For every ordered pair of distinct vertices, we look at the maximum flow value between them when treating edges as undirected capacitated connections.

codeforcescompetitive-programmingconstructive-algorithmsflowsgraphs
CF 2147F - Exchange Queries

We are given a set of items, and each item is ranked in two independent ways. One ranking comes from permutation p, the other from permutation s.

codeforcescompetitive-programmingcombinatoricsdata-structuresgreedy
CF 2147D - Game on Array

We are given a sequence of positive integers, representing a set of “tiles” with values. Two players, Alice and Bob, take turns picking a number that currently exists in the array.

codeforcescompetitive-programminggamesgreedy
CF 2147E - Maximum OR Popcount

We are given an array of non-negative integers, and for each query we are allowed to increment any elements of the array a certain number of times.

codeforcescompetitive-programmingbinary-searchbitmasksbrute-forcedata-structuresgreedy
CF 2147A - Shortest Increasing Path

We are on a two-dimensional grid starting at the origin $(0, 0)$ and want to reach a target $(x, y)$. Movement is constrained in two ways. First, we alternate axes: the first step moves right along $x$, the second up along $y$, the third along $x$ again, and so on.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 2147C - Rabbits

We are given a row of flower pots, some with flowers and some empty. Each empty pot must host a rabbit, and we have to decide which way each rabbit will face: left or right. Rabbits are fidgety and may jump to the adjacent pot in the direction they face.

codeforcescompetitive-programmingconstructive-algorithmsdpgreedyimplementation
CF 2147B - Multiple Construction

We are asked to construct a permutation-like array of length $2n$, but with repetition allowed: every number from $1$ to $n$ must appear exactly twice. The real constraint is not placement, but spacing.

codeforcescompetitive-programmingconstructive-algorithms
CF 2148F - Gravity Falls

We are given several arrays of integers, each of potentially different lengths. We can think of these arrays as rows in a grid that we are allowed to stack in any order, left-aligned.

codeforcescompetitive-programminggreedyimplementationsortings
CF 2148G - Farmer John's Last Wish

We are given an array of integers representing objects lying on the floor. Farmer John is concerned with the greatest common divisor (GCD) of prefixes of this array.

codeforcescompetitive-programmingbinary-searchdata-structuresmathnumber-theory
CF 2148E - Split

We are given an array of positive integers and a parameter $k$. For any chosen segment $[l, r]$, we imagine splitting the array into two parts: inside the segment and outside the segment. Every element inside the segment is forced into a distinguished multiset, call it bucket 1.

codeforcescompetitive-programmingbinary-searchdata-structurestwo-pointers
CF 2148D - Destruction of the Dandelion Fields

We are given a sequence of fields, each containing some number of dandelions. We are allowed to choose the order in which we visit these fields, and each field is visited exactly once.

codeforcescompetitive-programmingconstructive-algorithmsgreedysortings
CF 2148C - Pacer

We are simulating a very simple movement process along a line of time, where each minute Farmer John either stays on his current side of a gym or runs to the opposite side. Each time he chooses to run, he earns one point.

codeforcescompetitive-programminggreedymath
CF 2148B - Lasers

We are working on a grid-like plane from the origin to a target point, but instead of being blocked by walls, the plane contains infinitely thin obstacles.

codeforcescompetitive-programminggeometry
CF 2148A - Sublime Sequence

The problem gives us a number x and a length n and asks us to construct a sequence by alternating x and -x, starting with x. We are then asked to compute the sum of all elements in that sequence.

codeforcescompetitive-programmingbrute-forcehashingmath
CF 2149G - Buratsuta 3

We are given an array of integers and many independent range queries. For each query segment, we must identify all values whose frequency inside that segment is strictly greater than one third of the segment length.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresdivide-and-conquerprobabilities
CF 2149F - Nezuko in the Clearing

Nezuko starts at position 0 on a number line with a certain number of health points, and she wants to reach position d. In each turn, she can either rest to gain one health point or move forward by one.

codeforcescompetitive-programmingbinary-searchmathternary-search
CF 2149D - A and B

We are given a binary string made only of two symbols, a and b. We are allowed to swap adjacent characters, so any operation is essentially a single step of bubble-sorting two neighbors.

codeforcescompetitive-programmingstrings