brain

tamnd's digital brain — notes, problems, research

41650 notes

CF 1389A - LCM Problem

We are given many independent ranges of integers. For each range $[l, r]$, we need to pick two different integers $x$ and $y$ inside this interval such that their least common multiple is also inside the same interval.

codeforcescompetitive-programmingconstructive-algorithmsgreedymathnumber-theory
CF 1389C - Good String

We are given a string of digits and allowed to delete characters anywhere we like, preserving order of the remaining ones. The goal is to transform the string into a special form called “good”.

codeforcescompetitive-programmingbrute-forcedpgreedytwo-pointers
CF 1388A - Captain Flint and Crew Recruitment

We are given multiple independent queries, each asking whether a target number can be broken into four distinct positive integers.

codeforcescompetitive-programmingbrute-forcegreedymathnumber-theory
CF 1388D - Captain Flint and Treasure

We are given a directed structure over indices from 1 to n, where each index i has a value a[i] and a pointer b[i]. The pointer either leads to another index or is absent (represented by -1).

codeforcescompetitive-programmingdata-structuresdfs-and-similargraphsgreedyimplementationtrees
CF 1387B2 - Village (Maximum)

The village is a tree where each house is a node and each road is an edge of length one. Initially, every house has exactly one villager. We must reassign villagers so that every person moves to a different house, forming a permutation of nodes with no fixed points.

codeforcescompetitive-programming*specialdfs-and-similartrees
CF 1387A - Graph

We are given an undirected graph where every edge enforces a linear constraint between its endpoints. Each vertex must be assigned a real value, and every edge says exactly what the sum of its two endpoint values must be. Black edges force a sum of 1, red edges force a sum of 2.

codeforcescompetitive-programming*specialbinary-searchdfs-and-similardpmathternary-search
CF 1386A - Colors

We are interacting with a hidden system that has chosen an integer threshold $C$ between 1 and $N$. We can think of the numbers from 1 to $N$ as positions on a line, and every time we pick a position, we are effectively “dyeing” hair with that color.

codeforcescompetitive-programming*specialbinary-searchconstructive-algorithmsinteractive
CF 1386B - Mixture

We are maintaining a dynamic multiset of 3D vectors, each vector representing the amounts of salt, pepper, and garlic powder in a bottle.

codeforcescompetitive-programming*specialdata-structuresgeometrymathsortings
CF 1385F - Removing Leaves

We are working with a tree where vertices are gradually removed in rounds. In one round, we are allowed to pick a single internal vertex $v$ and remove exactly $k$ of its current leaf neighbors. A vertex counts as a leaf if it has degree one in the current remaining graph.

codeforcescompetitive-programmingdata-structuresgreedyimplementationtrees
CF 1385D - a-Good String

The task is to transform a given string into a very specific recursively defined structure centered around the letter 'a'.

codeforcescompetitive-programmingbitmasksbrute-forcedivide-and-conquerdpimplementation
CF 1385C - Make It Good

We are given an array and we are only allowed to delete a prefix, meaning we remove some number of elements from the front and keep the rest unchanged.

codeforcescompetitive-programminggreedy
CF 1384B2 - Koa and the Beach (Hard Version)

We are given a one-dimensional path from a shore to an island, where the sea between them is split into $n$ positions. Each position has a base depth $di$. Time progresses in discrete steps, and at each time the water level is uniformly shifted by a periodic tide function.

codeforcescompetitive-programmingconstructive-algorithmsdpgreedyimplementation
CF 1384A - Common Prefixes

Stopped thinkingDo you like this personality?

codeforcescompetitive-programmingconstructive-algorithmsgreedystrings
CF 1383D - Rearrange

We are given a complete permutation of numbers from 1 to $n cdot m$ arranged in an $n times m$ grid. From this grid we extract two small summaries: the set of row maxima and the set of column maxima.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgraphsgreedysortings
CF 1383C - String Transformation 2

We are given two strings of equal length, built from a small alphabet of 20 letters. We start with string A and want to transform it into string B using a specific operation. One operation works like this: pick a letter x.

codeforcescompetitive-programmingbitmasksdpgraphstrees
CF 1382A - Common Subsequence

We are given two integer arrays, and we want to construct a third array that can be obtained by deleting elements from both of them. In other words, we are looking for a sequence of values that appears in both arrays while preserving order in each.

codeforcescompetitive-programmingbrute-force
CF 1381A1 - Prefix Flip (Easy Version)

We are given two binary strings of equal length. The goal is to transform the first string into the second using a very specific operation: pick a prefix, reverse it, and flip every bit inside it. Flipping means turning 0 into 1 and 1 into 0.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresstrings
CF 1381B - Unmerge

We are given a permutation of size $2n$. The task is to decide whether we can split the numbers into two disjoint sequences $a$ and $b$, each of length $n$, such that if we repeatedly simulate a specific “two-pointer merge” process starting from the heads of $a$ and $b$…

codeforcescompetitive-programmingdp
CF 1380G - Circular Dungeon

We are placing a multiset of values into a circular array of rooms. Each room contains exactly one item, and each item is either a regular chest with a reward value or a mimic that immediately stops the run when entered.

codeforcescompetitive-programminggreedymathprobabilities
CF 1380E - Merging Towers

We are given a set of numbered discs from 1 to n, where larger numbers represent larger discs. These discs are initially split across m towers, and each tower already has its discs stacked in decreasing order of size from bottom to top.

codeforcescompetitive-programmingdata-structuresdsuimplementationtrees
CF 1380B - Universal Solution

We are given a string describing a cyclic opponent strategy in a rock-paper-scissors game. The opponent does not adapt; instead, they choose moves according to a fixed circular string. If they start at some position, they follow the string in order and wrap around forever.

codeforcescompetitive-programminggreedy
CF 1379F2 - Chess Strikes Back (hard version)

We are working on a very large grid of size $2n times 2m$, but we only care about the white cells, those where the sum of coordinates is even. Among these white cells, some are dynamically toggled between available and unavailable across a sequence of updates.

codeforcescompetitive-programmingdata-structuresdivide-and-conquer
CF 1379A - Acacius and String

We are given a short string consisting of lowercase letters and question marks. Each question mark can later be replaced by any lowercase letter. After replacements, we want to end up with a string that contains the fixed pattern "abacaba" as a substring exactly once.

codeforcescompetitive-programmingbrute-forceimplementationstrings
CF 1379C - Choosing flowers

We are choosing exactly $n$ flowers from $m$ available types, where each type can be used an unlimited number of times. The value of picking flowers is not linear per flower, instead each type behaves like a diminishing reward stream.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresdfs-and-similardpgreedysortingstwo-pointers
CF 1375H - Set Merging

We are given a permutation of numbers from 1 to n, but the real object we care about is not the values themselves, it is their positions. Initially each position i forms a singleton set containing the value a[i].

codeforcescompetitive-programmingconstructive-algorithmsdivide-and-conquer
CF 1375F - Integer Game

Three numbers represent the sizes of three piles of stones. The interaction alternates between us and the opponent.

codeforcescompetitive-programmingconstructive-algorithmsgamesinteractivemath
CF 1375E - Inversion SwapSort

We are given a sequence of numbers, and we are allowed to swap any two positions, but only if those two positions currently form an inversion in the original array. An inversion is simply a pair of indices where the left value is strictly larger than the right value.

codeforcescompetitive-programmingconstructive-algorithmsgreedysortings
CF 1375A - Sign Flipping

Stopped thinking

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1375B - Neighbor Grid

We are given a grid of integers, but the final goal is not to preserve these values exactly. Instead, we are allowed to only increase values, and we want to transform the grid into a configuration where every positive cell behaves like a “node” whose value equals how many of…

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1374F - Cyclic Shifts Sorting

We are given an array and a very specific primitive operation: we can pick any position and rotate a block of three consecutive elements to the right. That means a local triple [x, y, z] becomes [z, x, y].

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsimplementationsortings
CF 1374E1 - Reading Books (easy version)

We are given a collection of books, each with a reading time and two independent preference flags, one for Alice and one for Bob.

codeforcescompetitive-programmingdata-structuresgreedysortings
CF 1373E - Sum of Digits

We are trying to construct the smallest non-negative integer $x$ such that if we take a short consecutive block of numbers starting at $x$, specifically $x, x+1, dots, x+k$, and sum the digit sums of all of them, the total equals a given target $n$.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdpgreedy
CF 1373A - Donut Shops

We are comparing two different ways of buying the same number of donuts, and for each way we want to know when it becomes strictly cheaper than the other. In the first shop, the price is linear: buying $x$ donuts costs exactly $a cdot x$.

codeforcescompetitive-programminggreedyimplementationmath
CF 1373B - 01 Game

We are given a binary string and two players who alternately remove exactly two adjacent characters from it. Each move deletes a contiguous pair, so the string shrinks by 2 characters each turn.

codeforcescompetitive-programminggames
CF 1372A - Omkar and Completion

We are asked to construct an integer array of length n where every element is positive, does not exceed 1000, and satisfies a global restriction on sums: if we pick any three positions (they may coincide), the sum of two chosen elements is never equal to any element of the array.

codeforcescompetitive-programmingconstructive-algorithmsimplementation
CF 1372F - Omkar and Modes

We are given a hidden array of length $n$, already sorted in nondecreasing order, and containing at most $k le 25000$ distinct values. Our only way to inspect it is by querying a segment $[l,r]$.

codeforcescompetitive-programmingbinary-searchdivide-and-conquerinteractive
CF 1371F - Raging Thunder

We are given a line of positions, each containing a direction symbol that behaves like a deterministic local rule. From every starting position, a ball moves left or right according to its own symbol and the symbol of the neighbor it is interacting with.

codeforcescompetitive-programmingdata-structuresdivide-and-conquerimplementation
CF 1371C - A Cookie for You

We are given two types of cookies and two types of guests. The cookies are split into vanilla and chocolate counts, and guests also come in two behavioral types.

codeforcescompetitive-programminggreedyimplementationmath
CF 1370F2 - The Hidden Pair (Hard Version)

We are given a tree and two hidden distinct nodes inside it. We do not know which nodes they are, but we can interactively probe the tree by choosing any subset of nodes.

codeforcescompetitive-programmingbinary-searchdfs-and-similargraphsinteractiveshortest-pathstrees
CF 1370B - GCD Compression

We are given an array of length $2n$. We are allowed to remove exactly two elements permanently. After that, the remaining $2n-2$ elements must be partitioned into pairs. Each pair is replaced by the sum of its two elements, producing an array $b$ of length $n-1$.

codeforcescompetitive-programmingconstructive-algorithmsmathnumber-theory
CF 1370D - Odd-Even Subsequence

We are given a sequence of numbers and asked to choose a subsequence of fixed length $k$. Once we pick this subsequence, we alternate its elements into odd and even positions based on their order inside the subsequence, not their original positions in the array.

codeforcescompetitive-programmingbinary-searchdpdsugreedyimplementation
CF 1369F - BareLee

Each round is a two-player deterministic game played on a single integer. A round starts with a value $si$ on a board and a limit $ei$. Players alternate turns, and on each turn the current value $a$ must be replaced by either $a+1$ or $2a$.

codeforcescompetitive-programmingdfs-and-similardpgames
CF 1369D - TediousLee

The structure in this problem is a very specific rooted tree that grows level by level. Starting from a single node, each level expands every vertex depending on how many children it already has.

codeforcescompetitive-programmingdpgraphsgreedymathtrees
CF 1368H2 - Breadboard Capacity (hard version)

The structure we are working with is a rectangular grid where every cell is a junction and every boundary cell has a port attached to one of the two external systems. Each port is either red or blue.

codeforcescompetitive-programming
CF 1368C - Even Picture

We are asked to construct a set of grid cells on an infinite checkerboard, where each chosen cell is considered “gray”. The shape we build must behave like a graph: cells are vertices, and edges connect cells that share a side. The construction must satisfy three conditions.

codeforcescompetitive-programmingconstructive-algorithms
CF 1368F - Lamps on a Circle

We are playing an interactive game on a circular array of n positions. All positions start empty. On each turn, the player is allowed to pick a number k and activate any k positions.

codeforcescompetitive-programminggamesimplementationinteractivemath
CF 1367F2 - Flying Sort (Hard Version)

We are given a sequence of numbers and a very specific way to reorder it. In one operation, we pick any element and either push it all the way to the front or all the way to the back of the array.

codeforcescompetitive-programmingbinary-searchdata-structuresdpgreedysortingstwo-pointers
CF 1367D - Task On The Board

We are given a multiset of lowercase letters, initially written as a string $s$. From this multiset, some letters are discarded and the remaining letters are rearranged arbitrarily to form a new string $t$.

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementationsortings
CF 1367B - Even Array

We are given an array where each position has a fixed “required parity”: even indices must contain even numbers, and odd indices must contain odd numbers.

codeforcescompetitive-programminggreedymath
CF 1366D - Two Divisors

Each input value can be viewed as a box labeled with an integer, and for every box we must choose two non-trivial divisors of that number.

codeforcescompetitive-programmingconstructive-algorithmsmathnumber-theory
CF 1365F - Swaps Again

We are given two arrays of equal length and a very specific transformation rule. Starting from the first array, we are allowed to repeatedly pick a split size and swap two equal-length blocks: the prefix of that size and the suffix of the same size.

codeforcescompetitive-programmingconstructive-algorithmsimplementationsortings
CF 1365G - Secure Password

We are given an unknown array of non-negative integers, each up to 64-bit range. We cannot see the array directly. Instead, we can query any subset of indices, and the judge returns the bitwise OR of the elements at those positions.

codeforcescompetitive-programmingbitmaskscombinatoricsconstructive-algorithmsinteractivemath
CF 1364B - Most socially-distanced subsequence

We are given a permutation, which means every number from 1 to n appears exactly once, just in some order. From this array we are allowed to delete elements and keep the remaining ones in the same relative order, forming a subsequence.

codeforcescompetitive-programminggreedytwo-pointers
CF 1364E - X-OR

We are given a hidden arrangement of the numbers from 0 to n−1 placed at indices 1 through n. The only way to gain information is to choose two different positions and receive the bitwise OR of the values stored at those positions.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsdivide-and-conquerinteractiveprobabilities
CF 1363D - Guess The Maximums

We are given an array $A$ of length $n$, but we cannot see it directly. Instead, we can ask queries: pick any subset of indices and the judge returns the maximum value of $A$ over those indices. Along with this hidden array, we are given $k$ special index sets $S1, S2, dots, Sk$.

codeforcescompetitive-programmingbinary-searchimplementationinteractivemath
CF 1363E - Tree Shuffling

We are given a rooted tree where each node carries two bits of information: an initial binary digit and a desired final binary digit.

codeforcescompetitive-programmingdfs-and-similardpgreedytrees
CF 1362C - Johnny and Another Rating Drop

We are given a sequence that always contains consecutive integers starting from 0 up to some number n. Each number is viewed in binary, and all numbers are conceptually padded with leading zeros so they share the same bit length.

codeforcescompetitive-programmingbitmasksgreedymath
CF 1362A - Johnny and Ancient Computer

We are given a starting number and a target number, and we are allowed to transform the starting value using a very specific set of operations.

codeforcescompetitive-programmingimplementation
CF 1361C - Johnny and Megan's Necklace

Each input item is a small “edge gadget” consisting of two pearls, and each pearl has an integer color in the range $[0, 2^{20})$. The goal is to take all these $n$ gadgets and connect their endpoints into one single cycle that uses every pearl exactly once.

codeforcescompetitive-programmingbinary-searchbitmasksconstructive-algorithmsdfs-and-similardsugraphs
CF 1361D - Johnny and James

We are given a set of points on the plane, one of which is guaranteed to be the origin. From these points, we must keep exactly k points and delete the rest.

codeforcescompetitive-programminggreedyimplementationmathtrees
CF 1360G - A/B Matrix

We are asked to construct a binary grid of size $n times m$, where each cell is either 0 or 1, under two simultaneous constraints that tightly couple rows and columns. Every row must contain exactly $a$ ones, and every column must contain exactly $b$ ones.

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 1360C - Similar Pairs

We are given several independent arrays, each with an even number of elements. For each array, we must decide whether it is possible to split all elements into disjoint pairs such that every number belongs to exactly one pair and each pair satisfies a compatibility rule.

codeforcescompetitive-programmingconstructive-algorithmsgraph-matchingsgreedysortings
CF 1359E - Modular Stability

We are asked to count how many strictly increasing sequences of length $k$, chosen from the integers $1$ to $n$, have a very strong invariance property under repeated modulo operations.

codeforcescompetitive-programmingcombinatoricsmathnumber-theory
CF 1359F - RC Kaboom Show

We are given a collection of moving objects on an infinite plane. Each object starts from a fixed point, has a fixed direction, and moves in a straight line with a fixed speed.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresgeometrymath
CF 1358D - The Best Vacation

We are given a sequence of months laid out in order, where each month has a fixed length in days. If we flatten the calendar, each day becomes a single linear timeline, but each position still knows its position inside its month, from day 1 up to day $di$.

codeforcescompetitive-programmingbinary-searchbrute-forcegreedyimplementationtwo-pointers
CF 1358E - Are You Fired?

We are effectively given a partially known array of length $n$. The first half (rounded up) is explicitly provided, while the second half is completely uniform and equal to a constant value $x$. So after reading the input, the entire sequence is actually determined.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresgreedyimplementation
CF 1355F - Guess Divisors Count

We are given a hidden integer $X$ in each game, but we are never allowed to see it directly. Instead, we can query any integer $Q$, and the judge returns $gcd(X, Q)$.

codeforcescompetitive-programmingconstructive-algorithmsinteractivenumber-theory
CF 1355D - Game With Array

We are asked to construct a positive integer array of length $N$ whose total sum is exactly $S$. After building this array, we also choose an integer $K$ between $0$ and $S$.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1354G - Find a Gift

We are given a row of boxes, each box hiding either a valuable gift or a stone. Exactly k boxes contain gifts, and every other box contains stones. The key structural property is about weights.

codeforcescompetitive-programmingbinary-searchinteractiveprobabilities
CF 1354C2 - Not So Simple Polygon Embedding

We are given a regular polygon with $2n$ vertices, all edges equal to 1. The polygon is convex, and we are allowed to rotate it freely. We must place it inside a square, also freely rotatable, such that every point of the polygon lies inside or on the square boundary.

codeforcescompetitive-programmingbinary-searchbrute-forcegeometrymath
CF 1354C1 - Simple Polygon Embedding

We are working with a fixed geometric object: a regular polygon with $2n$ sides, each side having length 1. This polygon is convex and highly symmetric, so its shape is completely determined once we fix how it is oriented and scaled in the plane.

codeforcescompetitive-programmingbinary-searchgeometrymathternary-search
CF 1352B - Same Parity Summands

We are asked to split a given integer $n$ into exactly $k$ positive parts such that all parts share the same parity. This means we must choose either all odd numbers or all even numbers, and these $k$ numbers must sum exactly to $n$.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1352A - Sum of Round Numbers

The task is about breaking a given integer into simpler building blocks, where each building block is a number that looks like a single non-zero digit followed only by zeros. These are numbers such as 7, 40, 900, or 3000.

codeforcescompetitive-programmingimplementationmath
CF 1350A - Orac and Factors

We start with a number and repeatedly apply a very specific transformation: find its smallest divisor greater than 1, and add that value to the number. This operation changes the number itself, so the divisor we use may change at every step.

codeforcescompetitive-programmingmath
CF 1348E - Phoenix and Berries

We are given several shrubs, each containing two independent piles of berries: red and blue. From these sources we want to form as many baskets as possible, where every basket must contain exactly $k$ berries.

codeforcescompetitive-programmingbrute-forcedpgreedymath
CF 1348B - Phoenix and Beauty

We are given an array and allowed to insert additional values anywhere inside it, where every inserted value must stay within the same value range as the original array elements.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresgreedysortings
CF 1348C - Phoenix and Distribution

We are given a string made of lowercase letters and we are allowed to split all of its characters into exactly k non-empty groups. Inside each group, we can reorder characters arbitrarily, so each group is effectively just a multiset of letters that we later sort into a string.

codeforcescompetitive-programmingconstructive-algorithmsgreedysortingsstrings
CF 1346I - Pac-Man 2.0

The game world is a directed graph with up to 15 locations, each location containing a fixed number of pellets. From any location you can reach any other, so the graph is strongly connected.

codeforcescompetitive-programming*specialdp
CF 1346C - Spring Cleaning

We are given a row of shelves, each holding some number of books. The goal is to reach a state where every shelf has at most k books. We are allowed to modify the configuration using two operations.

codeforcescompetitive-programming*specialgreedysortings
CF 1346D - Constructing the Dungeon

We are given an undirected connected graph where vertices represent rooms and edges represent tunnels. Each tunnel already has a fixed value, and we must assign a value to every room.

codeforcescompetitive-programming*specialgraphsgreedy
CF 1345B - Card Constructions

We are given a supply of identical cards and we repeatedly build structures called pyramids. A pyramid of height 1 is the smallest possible structure, and every higher pyramid is built in layers: a taller pyramid consists of a smaller pyramid placed on top of a wider base made…

codeforcescompetitive-programmingbinary-searchbrute-forcedpmath
CF 1344E - Train Tracks

The system is a rooted tree of stations, where every node with children behaves like a router that forwards all incoming trains to exactly one of its children.

codeforcescompetitive-programmingdata-structurestrees
CF 1344F - Piet's Palette

We are given a hidden initial configuration of a length-n array. Each position contains either one of three primary colors or is empty. We never observe this initial array directly. Instead, we observe a sequence of operations applied to it over time.

codeforcescompetitive-programmingmatrices
CF 1344D - Résumé Review

We are given several categories of projects, and for each category we know how many projects exist. From each category we choose some number of projects to place on a résumé, with the constraint that the total number of chosen projects is exactly $k$, and we cannot pick more…

codeforcescompetitive-programmingbinary-searchgreedymath
CF 1344C - Quantifier Question

We are given a directed graph on variables $x1, x2, dots, xn$. Each constraint $xj < xk$ behaves like an edge $j to k$, and a full assignment of real values satisfies the formula only if every edge points from a smaller value to a larger value.

codeforcescompetitive-programmingdfs-and-similardpgraphsmath
CF 1343F - Restore the Permutation by Sorted Segments

We are given an unknown permutation of numbers from 1 to n. Instead of seeing it directly, we receive n−1 pieces of information, each piece being a multiset segment taken from the permutation.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdata-structuresgreedyimplementation
CF 1343E - Weights Distributing

We are given a connected undirected graph where each edge represents a road, but the roads do not yet have fixed costs. Instead, we are also given a list of prices, and we must assign exactly one price to each edge.

codeforcescompetitive-programmingbrute-forcegraphsgreedyshortest-pathssortings
CF 1342C - Yet Another Counting Problem

We are working with integers and modular arithmetic, but the structure becomes clearer if we think of the infinite number line as being colored by a periodic rule. For any integer $x$, we compute two values: first we take $x bmod a$, then reduce that result modulo $b$.

codeforcescompetitive-programmingmathnumber-theory
CF 1342B - Binary Period

We are given a binary string and asked to embed it into a larger binary string while preserving order as a subsequence.

codeforcescompetitive-programmingconstructive-algorithmsstrings
CF 1340A - Nastya and Strange Generator

The process builds a permutation from left to right, but the choice at each step is not based on already placed numbers.

codeforcescompetitive-programmingbrute-forcedata-structuresgreedyimplementation
CF 1340C - Nastya and Unexpected Guest

We are given a straight road modeled as integer points from 0 to n. Some of these points are special positions called safety islands, including both endpoints. Denis starts at 0 at time zero and wants to reach n as fast as possible.

codeforcescompetitive-programmingdfs-and-similardpgraphsshortest-paths
CF 1339B - Sorted Adjacent Differences

We are given several independent arrays, and for each one we must reorder its elements into a sequence where the absolute differences between neighboring elements never decrease as we move from left to right.

codeforcescompetitive-programmingconstructive-algorithmssortings
CF 1338C - Perfect Triples

We are building an infinite sequence by repeatedly selecting groups of three unused positive integers. Each group must satisfy a strict bitwise condition: the XOR of the three numbers is zero.

codeforcescompetitive-programmingbitmasksbrute-forceconstructive-algorithmsdivide-and-conquermath
CF 1338D - Nested Rubber Bands

We are given a tree, and the problem asks us to think about a geometric construction that can be performed on it. Each vertex becomes a closed non-self-intersecting curve on a plane.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similardpmathtrees
CF 1337A - Ichihime and Triangle

We are given four integers in non-decreasing order, and we need to choose three lengths from three separate intervals. The first length must come from the first interval, the second from the second interval, and the third from the third interval.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1336D - Yui and Mahjong Set

We are dealing with a hidden multiset of tiles where each tile carries a value from 1 to n. The hidden configuration can be thought of as an array of frequencies a₁, a₂, …, aₙ, where aᵢ is the number of tiles with value i.

codeforcescompetitive-programmingconstructive-algorithmsinteractive
CF 1336C - Kaavi and Magic Spell

We are given two strings. The first string represents a queue of characters that we will consume from the left. The second string is a target pattern.

codeforcescompetitive-programmingdpstrings
CF 1335E2 - Three Blocks Palindrome (hard version)

Codeforces 1335E2: Three Blocks Palindrome (hard version)

codeforcescompetitive-programmingbrute-forcedata-structuresdptwo-pointers
CF 1335F - Robots on a Grid

Each cell in the grid behaves like a deterministic state in a directed graph. From every cell, there is exactly one outgoing edge pointing to one of its four neighbors, as dictated by the arrow in that cell.

codeforcescompetitive-programmingdata-structuresdfs-and-similardsugraphsgreedymatrices
CF 1335C - Two Teams Composing

We are given a multiset of student skills for each test case. From this pool we must form two disjoint groups of students, both of the same size, say $x$.

codeforcescompetitive-programmingbinary-searchgreedyimplementationsortings