brain

tamnd's digital brain — notes, problems, research

41650 notes

CF 1230A - Dawid and Bags of Candies

We are given four separate bags, each containing some number of candies. Each bag is indivisible and must be given entirely to exactly one of two friends.

codeforcescompetitive-programmingbrute-forceimplementation
CF 1231C - Increasing Matrix

We are given a rectangular grid of integers. Some cells already contain fixed positive values, while some cells contain zeros that we are allowed to replace with positive integers of our choice.

codeforcescompetitive-programminggreedy
CF 1231E - Middle-Out

We are given two strings of equal length. The only operation allowed is to pick a character from the current string and move it either to the very front or the very back. Every move removes that character from its position and reinserts it at one of the two extremes.

codeforcescompetitive-programmingconstructive-algorithmsgreedystrings
CF 1240F - Football

We are given a set of teams and a list of potential matches between pairs of teams. Each match can either be played in one of several stadiums or be skipped entirely.

codeforcescompetitive-programminggraphs
CF 1246F - Cursor Distance

We are given a string of lowercase letters, where each position acts like a “tile” labeled by a character. A cursor sits on one of these positions, and we are allowed to move it using a special jump operation: pick a character and a direction, and the cursor teleports to…

codeforcescompetitive-programming
CF 1261F - Xor-Set

We are given two very large sets of integers, but they are not listed explicitly. Instead, each set is described as a union of intervals.

codeforcescompetitive-programmingbitmasksdivide-and-conquermath
CF 1341B - Nastya and Door

We are given an array of mountain heights. A “peak” is an index strictly inside a segment where the height is larger than both immediate neighbors, meaning it forms a local maximum. We are also given a fixed window length $k$, and we slide this window across the array.

codeforcescompetitive-programminggreedyimplementation
CF 1341A - Nastya and Rice

We are given several independent scenarios about a bag of rice grains. In each scenario, there are two layers of uncertainty: the weight of each individual grain and the total weight of all grains together.

codeforcescompetitive-programmingmath
CF 1600F - Party Organization

We are given a simple undirected graph where people are vertices and friendships are edges. A valid party is a selection of exactly five distinct vertices such that the induced subgraph on these five vertices is either completely empty of edges or completely full, meaning it…

codeforcescompetitive-programmingbrute-forcemathprobabilities
CF 1600J - Robot Factory

The grid describes a rectangular factory floor where each cell is a tile that may have walls on some of its four sides. Each tile contains a number from 0 to 15, and this number encodes its walls using four bits.

codeforcescompetitive-programmingbitmasksdfs-and-similar
CF 1600E - Array Game

We are given an array of numbers laid out in a line. Two players alternate turns, starting with Alice. On each move, a player removes either the leftmost or rightmost remaining element and appends it to a sequence that is being constructed.

codeforcescompetitive-programminggamesgreedytwo-pointers
CF 2013E - Prefix GCD

We are given a list of positive integers, and we are allowed to permute them in any order before processing. After choosing an order, we build prefix GCDs: the first value is just the first element, the second is the gcd of the first two elements, and so on until the full array.

codeforcescompetitive-programmingbrute-forcedpgreedymathnumber-theory
CF 2013D - Minimize the Difference

We are given a sequence of numbers arranged in a line. In one move, we are allowed to take one unit from some position and push it to the next position on the right. This means mass can only flow to the right, never backwards, and every move preserves the total sum of the array.

codeforcescompetitive-programmingbinary-searchgreedy
CF 1830F - The Third Grace

We are given a line of positions from 1 to m. At each position i there is a value pi, and we may choose to activate some subset of these positions. We are also given n intervals on the same line. For each interval [l, r], we look at the activated positions inside it.

codeforcescompetitive-programmingdata-structuresdp
CF 1830E - Bully Sort

We are given a permutation of size $n$, and we repeatedly apply a very specific “bullying” operation to measure how far the permutation is from being sorted. At any moment, we look at all indices where the value is not already correct.

codeforcescompetitive-programmingdata-structuresmath
CF 1830D - Mex Tree

Each test case gives a tree, and we must assign every vertex a label of either 0 or 1. Once the labels are fixed, every pair of vertices defines a unique simple path in the tree, and we look at the sequence of labels along that path.

codeforcescompetitive-programmingbrute-forcedptrees
CF 1830B - The BOSS Can Count Pairs

We are given two arrays of equal length, and we need to count how many index pairs behave in a very specific “cross condition”.

codeforcescompetitive-programmingbrute-forcemath
CF 1830A - Copil Copac Draws Trees

We are given a tree described by an ordered list of edges. The edges are not just connectivity information, their order matters because the drawing process scans them sequentially again and again. The process starts with only vertex 1 being considered “drawn”.

codeforcescompetitive-programmingdfs-and-similardpgraphstrees
CF 1830C - Hyperregular Bracket Strings

Working

codeforcescompetitive-programmingcombinatoricsgreedyhashingmathnumber-theorysortings
CF 1817F - Entangled Substrings

We are given a single string and we are asked to count how many ordered pairs of non-empty substrings $(a, b)$ satisfy a very rigid structural property: every occurrence of $a$ inside the string must always be followed by the same fixed middle string $c$ and then $b$, and…

codeforcescompetitive-programmingstring-suffix-structuresstrings
CF 1817B - Fish Graph

We are given an undirected simple graph and asked whether we can select a subset of its edges that forms a very specific structure called a Fish Graph. The target structure consists of two parts. First, there must be a simple cycle.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdfs-and-similargraphs
CF 1817A - Almost Increasing Subsequence

We are working with an array where we need to answer many independent range queries. Each query gives a segment of the array, and for that segment we want the maximum possible length of a subsequence that avoids a very specific forbidden pattern: three chosen elements that…

codeforcescompetitive-programmingbinary-searchdata-structuresgreedy
CF 1817E - Half-sum

We start with a multiset of real values, initially all integers. One operation takes any two values, removes them, and replaces them with their average. This operation reduces the size of the multiset by one, and repeats until exactly two numbers remain.

codeforcescompetitive-programmingbrute-forcedivide-and-conquergreedy
CF 1808E2 - Minibuses on Venus (medium version)

We are counting sequences of length n, where each position holds a digit in base k. So each ticket is just an array of length n with values from 0 to k-1.

codeforcescompetitive-programmingcombinatoricsdivide-and-conquerdpmatrices
CF 1808E1 - Minibuses on Venus (easy version)

We are counting digit sequences of fixed length in base $k$. Each ticket is just an array of $n$ numbers, each between $0$ and $k-1$. A ticket is considered valid if we can pick one position $i$ such that the digit at $i$ is equal to the sum of all other digits, taken modulo $k$.

codeforcescompetitive-programmingcombinatoricsdivide-and-conquerdp
CF 1808C - Unlucky Numbers

We are given multiple independent queries. Each query describes a contiguous range of integers from $l$ to $r$, and each integer in that range represents a starship identifier.

codeforcescompetitive-programmingbrute-forcedpgreedyimplementation
CF 1808A - Lucky Numbers

We are given multiple queries. Each query describes a range of integers from $l$ to $r$, and each integer represents a candidate “starship number”.

codeforcescompetitive-programmingbrute-forceimplementation
CF 1804H - Code Lock

We are given a circular dial with $k$ positions. Each position is labeled with a distinct letter from the first $k$ letters of the alphabet. We are allowed to permute which letter sits at which position before starting.

codeforcescompetitive-programmingbitmasksdp
CF 1804F - Approximate Diameter

We are given a connected, undirected graph with unit-length edges. The key quantity of interest is the graph diameter, which is the largest shortest-path distance between any pair of vertices.

codeforcescompetitive-programmingbinary-searchdivide-and-conquergraphsshortest-paths
CF 1804E - Routing

We are given an undirected, connected graph with up to 20 vertices. Each vertex represents a server, and edges represent direct bidirectional communication links. For every server $u$, we must choose exactly one adjacent vertex $a(u)$.

codeforcescompetitive-programmingbitmasksbrute-forcedfs-and-similardpgraphs
CF 1773L - Lisa's Sequences

We are given a sequence of integers and a fixed length $k$. The task is to modify the sequence as little as possible so that it no longer contains any contiguous block of length exactly $k$ that is monotone.

codeforcescompetitive-programmingdp
CF 1773J - Jumbled Trees

Each edge in a connected undirected graph carries a value that starts at zero. We are allowed to perform operations, and each operation picks a spanning tree of the graph and adds a single chosen value $v$ to every edge in that tree.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1773F - Football

We are given aggregated statistics for a football team over a sequence of matches. Instead of knowing individual match results, we only know three numbers: how many matches were played, how many total goals the team scored across all matches, and how many total goals it conceded.

codeforcescompetitive-programmingconstructive-algorithms
CF 1773I - Interactive Factorial Guessing

We are interacting with a hidden integer $n$, but we are not allowed to see it directly. Instead, we can ask up to 10 questions of the form: “what is the $k$-th digit from the right of $n!$ in decimal representation?”.

codeforcescompetitive-programmingbrute-forcegamesimplementationinteractive
CF 1773H - Hot and Cold

We are playing a coordinate guessing game on a large integer grid. There is a hidden target point somewhere in the square from $(0,0)$ to $(10^6,10^6)$.

codeforcescompetitive-programmingbinary-searchinteractive
CF 1773B - BinCoin

We are given a rooted binary tree with $n$ employees. Each employee has either zero or two direct subordinates, and there is a unique root (the CEO).

codeforcescompetitive-programmingbinary-searchdivide-and-conquerhashingimplementationprobabilitiestrees
CF 1773A - Amazing Trick

We are given a permutation $a$ of size $n$, meaning every number from $1$ to $n$ appears exactly once. We are allowed to apply two permutations $q$ first and then $p$, so that the final position $i$ receives the value originally at position $p[q[i]]$.

codeforcescompetitive-programmingconstructive-algorithmsgraph-matchingsmathprobabilities
CF 1773E - Easy Assembly

We are given several vertical stacks of uniquely numbered blocks. Each stack is ordered from top to bottom, and we are allowed to physically reorganize these blocks using two operations: we can cut a stack into two by taking a prefix or suffix segment and turning it into a new…

codeforcescompetitive-programminggreedysortings
CF 1740I - Arranging Crystal Balls

We are given a circular arrangement of $n$ positions, each holding a value modulo $m$. The goal is to transform every value into zero.

codeforcescompetitive-programmingdata-structuresdivide-and-conquerdpgeometrygraphsnumber-theory
CF 1740G - Dangerous Laser Power

We are given an (n times m) grid where each cell behaves like a directional device that routes a “laser” entering from one side to another side, while possibly increasing its speed.

codeforcescompetitive-programmingconstructive-algorithmsdsusortings
CF 1740H - MEX Tree Manipulation

I can’t produce a correct editorial for “Codeforces 1740H - MEX Tree Manipulation” from the title alone. That problem number corresponds to a very specific and fairly technical tree + data structure task, and without the exact statement (operations, constraints, and what…

codeforcescompetitive-programmingdata-structurestrees
CF 1740F - Conditional Mix

We start with a collection of $n$ single-element sets, one for each value in the array. Each position contributes a separate set, even if values repeat. The only operation allowed is merging two currently existing sets, but only if they are disjoint as sets of values.

codeforcescompetitive-programmingcombinatoricsdpmath
CF 1740E - Hanging Hearts

We are given a rooted tree where each node represents a card. Card 1 is fixed as the root, and every other card hangs from exactly one earlier card, forming a structure where every node has a single parent and edges always point toward smaller indices.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresdfs-and-similardpgreedytrees
CF 1740D - Knowledge Cards

We are given a grid, but only two cells actually behave like “real endpoints”: the top-left cell acts as a source holding a stack of cards, and the bottom-right cell acts as a sink where we must rebuild a stack in sorted order from 1 to k, increasing from top to bottom.

codeforcescompetitive-programmingconstructive-algorithmsdata-structures
CF 1740A - Factorise N+M

We are given several test cases, and each test case starts with a prime number $n$. For every such $n$, we must choose another prime number $m$ such that the sum $n + m$ is not prime.

codeforcescompetitive-programmingconstructive-algorithmsnumber-theory
CF 1740C - Bricks and Bags

We are given a multiset of integer weights representing bricks, and we must distribute every brick into one of three non-empty groups.

codeforcescompetitive-programmingconstructive-algorithmsgamesgreedysortings
CF 1740B - Jumbo Extra Cheese 2

We are given several test cases. In each test case, we receive a collection of rectangles, each representing a cheese slice. Each slice can be rotated, so a rectangle $a times b$ can be treated as either width $a$, height $b$ or width $b$, height $a$.

codeforcescompetitive-programminggeometrygreedysortings
CF 1734F - Zeros and Ones

The construction defines an infinite binary string where each stage doubles the previous string and flips the bits in the second half.

codeforcescompetitive-programmingbitmasksdivide-and-conquerdpmath
CF 1734E - Rectangular Congruence

We are asked to construct an $n times n$ matrix over the field of residues modulo a prime $n$. Every entry must be an integer in the range $0$ to $n-1$, and the diagonal is already fixed: the $i$-th diagonal entry must equal $bi$.

codeforcescompetitive-programmingconstructive-algorithmsnumber-theory
CF 1734D - Slime Escape

We start at position k on a line of n slimes. Each position contains a slime with some health value, and when we step onto a position that still has a slime, we absorb it and add its health to ours. Negative values reduce our health, positive values increase it.

codeforcescompetitive-programmingdata-structuresdpgreedytwo-pointers
CF 1734B - Bright, Nice, Brilliant

The structure is a triangular grid where row i contains i cells, and each cell can send influence downward to two children: directly below-left and below-right.

codeforcescompetitive-programmingconstructive-algorithms
CF 1733E - Conveyor

The system describes a 120 by 120 grid where every cell initially contains a conveyor belt pointing to the right. A single slime starts at the top-left cell, and every second the system evolves in a synchronized way.

codeforcescompetitive-programmingconstructive-algorithmsdpmath
CF 1733D1 - Zero-One (Easy Version)

We are given two binary strings of equal length. We are allowed to repeatedly apply an operation that flips two positions at once: pick indices l and r with l < r, and invert both bits. The cost depends only on whether the chosen positions are adjacent or not.

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 1733D2 - Zero-One (Hard Version)

We are given two binary strings of equal length. We are allowed to fix mismatches between them by flipping pairs of positions in the first string. Each operation picks two different indices and toggles both bits at those positions.

codeforcescompetitive-programmingdpgreedy
CF 1733A - Consecutive Sum

We are given an array of integers, and we are allowed to rearrange elements using a restricted swap operation. The restriction is that we can only swap positions whose indices share the same remainder when divided by a fixed number $k$.

codeforcescompetitive-programminggreedysortings
CF 1733B - Rule of League

We are given a very specific elimination-style tournament. Players arrive in a fixed order from 1 to n. The first match is between player 1 and player 2, then the winner of that match plays player 3, then that winner plays player 4, and so on until player n.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1733C - Parity Shuffle Sorting

We are given an array of integers and a peculiar operation that allows us to “transfer” values between two positions, but the direction of the transfer depends entirely on the parity relationship between the chosen pair. Each operation picks two indices l < r.

codeforcescompetitive-programmingconstructive-algorithmssortings
CF 1732E - Location

Each position in the array behaves like a pair of values, a dynamic value $ai$ and a fixed value $bi$. Over time, we repeatedly overwrite entire segments of the $a$-array with a single number, and occasionally we are asked to inspect a segment and find the smallest value of a…

codeforcescompetitive-programmingdata-structuresdpmathnumber-theory
CF 1732D2 - Balance (Hard version)

We maintain a dynamic set of non-negative integers. It starts with a single element, zero, and evolves through three types of operations: insert a new number, delete an existing number, and answer a query that depends on a parameter $k$.

codeforcescompetitive-programmingbrute-forcedata-structuresnumber-theory
CF 1732D1 - Balance (Easy version)

We start with a set that initially contains only the number zero. Over time, two kinds of operations are applied. One operation inserts a new integer into the set, and the other asks a query about a special value called the k-mex.

codeforcescompetitive-programmingbrute-forcedata-structuresimplementationnumber-theory
CF 1732B - Ugu

We are given a binary string, and we want to transform it into a non-decreasing sequence, meaning that once the string starts containing 1, it should never go back to 0. The final form must look like some number of 0s followed by some number of 1s.

codeforcescompetitive-programmingbrute-forcedpgreedyimplementation
CF 1732C2 - Sheikh (Hard Version)

We are given an array and multiple range queries. For each query interval, we must choose a contiguous subarray fully inside that interval and maximize a score defined on that subarray.

codeforcescompetitive-programmingbinary-searchbitmasksbrute-forcegreedyimplementationtwo-pointers
CF 1732C1 - Sheikh (Easy version)

We are given an array and we are allowed to choose any contiguous segment inside it. For each segment, we compute a score defined as the difference between its sum and its bitwise XOR.

codeforcescompetitive-programmingbinary-searchbitmasksgreedytwo-pointers
CF 1731B - Kill Demodogs

We are working on an $n times n$ grid where each cell $(i, j)$ contains a value equal to the product $i cdot j$. A character starts at the top-left corner $(1, 1)$ and must reach the bottom-right corner $(n, n)$, moving only right or down at each step.

codeforcescompetitive-programminggreedymath
CF 1731E - Graph Cost

We start with a graph of $n$ labeled vertices and no edges. The goal is to end with exactly $m$ undirected edges. Each edge between vertices $u$ and $v$ is not freely chosen: its weight is fixed and equals $gcd(u, v)$.

codeforcescompetitive-programmingdpgreedymathnumber-theory
CF 1731D - Valiant's New Map

We are given several independent grids, each grid representing a city map where every cell contains a building height. From each grid, we must choose a square subgrid of size $l times l$ such that every cell inside that square has height at least $l$.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresdptwo-pointers
CF 1731C - Even Subarrays

We are given an array of integers, and we look at every contiguous segment of it. For each segment we compute the bitwise XOR of its elements, producing a single number.

codeforcescompetitive-programmingbitmasksbrute-forcehashingmathnumber-theory
CF 1730F - Almost Sorted

We are given a permutation p of size n, and we must construct another permutation q of indices 1..n. The constraint on q is unusual: if we look at the values of p along q, they cannot drop by more than k as we move forward.

codeforcescompetitive-programmingbitmasksdata-structuresdp
CF 1730E - Maximums and Minimums

The task is to count how many contiguous subarrays of a given array have a very specific structural property: if you look inside the subarray, take its smallest element and its largest element, the larger one must be an exact multiple of the smaller one.

codeforcescompetitive-programmingcombinatoricsdata-structuresdivide-and-conquernumber-theory
CF 1730D - Prefixes and Suffixes

We are given two strings of equal length. Think of them as two rows of characters, each row having $n$ positions.

codeforcescompetitive-programmingconstructive-algorithmsstringstwo-pointers
CF 1730B - Meeting on the Line

We are given a line with people standing at different coordinates. Each person has a fixed position and also a personal preparation time before they can start moving.

codeforcescompetitive-programmingbinary-searchgeometrygreedyimplementationmathternary-search
CF 1730A - Planets

We are given several independent test cases. In each test case there is a multiset of integers, where each integer represents an orbit label of a planet. Planets sharing the same value belong to the same orbit. We have two ways to destroy planets.

codeforcescompetitive-programmingdata-structuresgreedysortings
CF 1729E - Guess the Cycle Size

We are interacting with a hidden structure that is guaranteed to be a simple cycle on $n$ vertices, where $n$ can be as large as $10^{18}$. The vertices are labeled by distinct integers, but the actual cycle order is unknown.

codeforcescompetitive-programminginteractiveprobabilities
CF 1729G - Cut Substrings

We are given a text string and a pattern string. The operation allowed is to pick any occurrence of the pattern inside the text and replace that entire occurrence with dots. Those dots still occupy positions but no longer participate in further pattern matches.

codeforcescompetitive-programmingcombinatoricsdphashingstringstwo-pointers
CF 1729D - Friends and the Restaurant

We are given a collection of friends where each friend has two numbers: how much they intend to spend at a restaurant and how much money they actually have. The goal is to partition some of these friends into disjoint groups, where each group has at least two people.

codeforcescompetitive-programminggreedysortingstwo-pointers
CF 1729C - Jumping on Tiles

We are given a string of lowercase letters representing a line of tiles. Each position is a node in a path from the first character to the last, but we are not required to move only to adjacent positions.

codeforcescompetitive-programmingconstructive-algorithmsstrings
CF 1729B - Decode String

We are given a string that was produced by encoding a lowercase English string character by character. Each letter was replaced by its position in the alphabet, with the extra twist that two-digit positions are marked by appending an extra 0 after the number.

codeforcescompetitive-programminggreedystrings
CF 1729A - Two Elevators

The situation describes a decision between two elevators that can potentially reach Vlad on the 1st floor. Each elevator has a different movement rule, and the goal is to determine which one arrives back to floor 1 the fastest after Vlad presses a call button.

codeforcescompetitive-programmingmath
CF 1728G - Illumination

We are working on a one-dimensional segment from 0 to d. Some positions on this line are special points that must be “covered”. We also have a collection of lantern positions, and each lantern can be assigned a nonnegative power up to d.

codeforcescompetitive-programmingbinary-searchbitmasksbrute-forcecombinatoricsdpmathtwo-pointers
CF 1728E - Red-Black Pepper

Each dish must receive exactly one seasoning choice: either red pepper or black pepper. If a dish uses red pepper, it contributes $ai$ to the total tastiness, otherwise it contributes $bi$. So the final score is fully determined once we decide a binary assignment for all dishes.

codeforcescompetitive-programmingbrute-forcedata-structuresgreedymathnumber-theory
CF 1728C - Digital Logarithm

We are given two arrays of equal length. Each position contains a positive integer, and we are allowed to repeatedly replace a number by the number of digits it has in base 10.

codeforcescompetitive-programmingdata-structuresgreedysortings
CF 1728A - Colored Balls: Revisited

We are given several test cases. In each test case, there are several colors of balls, and each color has a certain number of balls. The total number of balls across all colors is guaranteed to be odd.

codeforcescompetitive-programmingbrute-forcegreedyimplementationsortings
CF 1728D - Letter Picking

We are playing a two-player game on a string that behaves like a deque. The string initially contains lowercase letters and has even length. Alice moves first, and players alternate.

codeforcescompetitive-programmingconstructive-algorithmsdpgamestwo-pointers
CF 1726H - Mainak and the Bleeding Polygon

We are given a convex polygon described by its vertices in counter-clockwise order. The shape is not arbitrary: every corner is either a right angle or slightly wider than a right angle, but never sharp.

codeforcescompetitive-programmingbinary-searchgeometryimplementationmath
CF 1726G - A Certain Magical Party

We are given a group of $n$ people, each starting with a happiness value $ai$ and a binary personality flag $bi$. We choose a permutation, which represents the order in which they speak.

codeforcescompetitive-programmingcombinatoricsdata-structuresgreedysortings
CF 1726E - Almost Perfect

We are asked to count how many permutations of size $n$ satisfy a very specific structural constraint involving both the permutation and its inverse.

codeforcescompetitive-programmingcombinatoricsfftmath
CF 1726D - Edge Split

We are given a connected undirected graph with a small number of extra edges beyond a tree. For each edge, we must decide whether it is colored red or blue.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdfs-and-similardsugraphsprobabilitiestrees
CF 1726C - Jatayu's Balanced Bracket Sequence

We are given a balanced bracket string of length $2n$. Each position in this string is treated as a vertex in a graph. Two vertices $i$ and $j$ are connected by an undirected edge exactly when the substring from $i$ to $j$ forms a balanced bracket sequence on its own.

codeforcescompetitive-programmingdata-structuresdsugraphsgreedy
CF 1726B - Mainak and Interesting Sequence

We are asked to construct a sequence of positive integers of length $n$ whose sum is fixed to $m$, but with an additional constraint that comes from a peculiar XOR condition applied to value ordering rather than positions.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsmath
CF 1726A - Mainak and Array

We are given an array of positive integers. Exactly once, we are allowed to choose a contiguous segment and rotate it cyclically by any amount, which effectively means we can pick any element inside the segment and move it to either end of that segment, while preserving the…

codeforcescompetitive-programminggreedymath
CF 1725L - Lemper Cooking Competition

We are given a line of stoves, each carrying an integer temperature that may start negative or positive. The goal is to perform a sequence of local operations so that every stove ends up with a non-negative value.

codeforcescompetitive-programmingdata-structures
CF 1725M - Moving Both Hands

We are given a directed weighted graph where every edge allows movement in only one direction and has a cost in time. Two tokens, or “hands”, start on different vertices: one is fixed at vertex 1, and the other starts at some vertex p.

codeforcescompetitive-programmingdpgraphsshortest-paths
CF 1725H - Hot Black Hot White

We are given an array of integers, each representing the strength of a magical stone. We must split these stones into two equal groups and assign each stone one of two colors.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1725D - Deducing Sortability

We are asked to construct a very large hidden array indexed from 1 to N, where N can be up to one billion, without explicitly building it.

codeforcescompetitive-programmingbinary-searchbitmasksmath
CF 1725A - Accumulation of Dominoes

The grid in this problem is not arbitrary, it is completely determined by its dimensions. Every cell contains a unique integer, and the numbers increase row by row from left to right.

codeforcescompetitive-programmingmath
CF 1722G - Even-Odd XOR

We are asked to construct, for each test case, a sequence of distinct nonnegative integers, all strictly below $2^{31}$, with a very specific balancing condition.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsgreedy
CF 1722E - Counting Rectangles

We are given a collection of axis-aligned rectangles, each defined by its height and width. For every query, we are also given two bounding rectangles: a “small inner constraint” rectangle and a “large outer constraint” rectangle.

codeforcescompetitive-programmingbrute-forcedata-structuresdpimplementation
CF 1722D - Line

We are given a row of people, each either facing left or right. The contribution of a person depends on how many people lie in the direction they are looking.

codeforcescompetitive-programminggreedysortings
CF 1722C - Word Game

Each test case describes a small three-player word submission game. Every player independently writes down the same number of short strings, each string having length exactly three. After all words are written, scoring is determined by how many people included each distinct word.

codeforcescompetitive-programmingdata-structuresimplementation
CF 1722B - Colourblindness

We are given a very small grid with exactly two horizontal strips and some number of vertical columns. Each cell contains one of three colors, but the viewer is colorblind in a specific way: green and blue are indistinguishable, while red remains distinct from both.

codeforcescompetitive-programmingimplementation