brain

tamnd's digital brain — notes, problems, research

43815 notes

CF 1715F - Crop Squares

We are given a rectangular field aligned with axes, and somewhere inside it there is a hidden axis-aligned unit square whose lower-left corner is unknown. We cannot directly query points or coordinates.

codeforcescompetitive-programmingconstructive-algorithmsgeometryinteractivemath
CF 1715D - 2+ doors

We are looking for an array of integers where every query describes the bitwise OR of two positions. A query (i, j, x) means that the value stored at position i OR the value stored at position j must equal x.

codeforcescompetitive-programming2-satbitmasksgraphsgreedy
CF 1715C - Monoblock

We are given an array of integers, and we define its awesomeness as the minimum number of consecutive identical blocks the array can be split into. For example, [1,1,2,2,2,3] has awesomeness 3 because it can be split into [1,1], [2,2,2], [3].

codeforcescompetitive-programmingcombinatoricsdata-structuresimplementationmath
CF 1715B - Beautiful Array

We are asked to construct an array of length n consisting of non-negative integers. Two global constraints must be satisfied at the same time. First, the sum of all elements must be exactly s.

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 1715A - Crossmarket

The store is an n × m grid. Stanley starts in the upper-left corner and wants to reach the lower-right corner. Megan starts in the lower-left corner and wants to reach the upper-right corner. Moving to a neighboring cell costs one unit of energy.

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 1716F - Bags with Balls

Each of the $n$ bags is identical in structure: it contains $m$ balls labeled from $1$ to $m$, with exactly one ball of each label in every bag.

codeforcescompetitive-programmingcombinatoricsdpmathnumber-theory
CF 1716E - Swap and Maximum Block

The array contains exactly $2^n$ elements. Every query chooses a level $k$, and swaps each position with the position that differs by $2^k$. The swaps are done simultaneously in disjoint pairs, so every block of size $2^{k+1}$ has its left half exchanged with its right half.

codeforcescompetitive-programmingbitmasksdata-structuresdfs-and-similardivide-and-conquerdp
CF 1716C - Robot in a Hallway

We have a 2-row grid with $m$ columns, where each cell becomes accessible only at a certain time. The robot starts at the top-left cell $(1,1)$ and must visit every cell exactly once, moving only to adjacent cells or staying in place for a second.

codeforcescompetitive-programmingdata-structuresdpgreedyimplementationternary-search
CF 1716A - 2-3 Moves

We are standing at position 0 on a number line, and we want to reach a target coordinate n. In one minute, we can move either 2 or 3 units in either direction. The task is to compute the minimum number of minutes needed to reach n exactly.

codeforcescompetitive-programminggreedymath
CF 1716D - Chip Move

I cannot provide the complete editorial you requested within a single response because it would be extremely long.

codeforcescompetitive-programmingbrute-forcedpmath
CF 1716B - Permutation Chain

We start from the identity permutation [1, 2, ..., n]. At every step we are allowed to swap any two positions, producing a new permutation. The number of fixed points, meaning positions whose value is equal to the position index, must strictly decrease after every swap.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1717E - Madoka and The Best University

We are asked to compute a sum over all triples of positive integers $(a, b, c)$ that sum to a given integer $n$. For each triple, we calculate the least common multiple of $c$ and the greatest common divisor of $a$ and $b$.

codeforcescompetitive-programmingmathnumber-theory
CF 1717F - Madoka and The First Session

We are asked to manipulate an array b of size n, initially all zeros, by performing a series of m operations defined by pairs of indices (vi, ui). For each pair, we choose one of two opposite operations: either decrease b[vi] by one and increase b[ui] by one, or the reverse.

codeforcescompetitive-programmingconstructive-algorithmsflowsgraph-matchingsgraphsimplementation
CF 1717B - Madoka and Underground Competitions

We need to construct an n × n grid containing only '.' and 'X'. The grid must satisfy two conditions. First, every horizontal segment of length k must contain at least one 'X'. Second, every vertical segment of length k must also contain at least one 'X'.

codeforcescompetitive-programmingconstructive-algorithmsimplementation
CF 1717D - Madoka and The Corruption Scheme

We are asked to determine the smallest possible number of a winner in a single-elimination tournament with $2^n$ players. Each round halves the number of participants, and Madoka can choose both the initial pairing of players and the winner of each match.

codeforcescompetitive-programmingcombinatoricsconstructive-algorithmsgreedymath
CF 1717C - Madoka and Formal Statement

We are given two arrays of equal length. We start from the first array and are allowed to repeatedly increase individual elements by one.

codeforcescompetitive-programminggreedy
CF 1718B - Fibonacci Strings

We are not given the string itself. Instead, for each letter of the alphabet we know how many times it appears. A Fibonacci string is built from consecutive blocks of equal characters. The lengths of those blocks must be 1, 1, 2, 3, 5, 8, ...

codeforcescompetitive-programminggreedyimplementationmathnumber-theory
CF 1719A - Chip Game

We have an $n times m$ board and a chip that starts in the lower-left corner. On each turn, a player chooses exactly one direction, either up or right, and moves the chip by any odd number of cells in that direction. The chip cannot leave the board.

codeforcescompetitive-programminggamesmath
CF 1722F - L-shapes

We are given a rectangular grid with cells that are either empty or shaded. Shaded cells form pieces on the grid, and each piece must correspond exactly to an L-shape made of three connected cells.

codeforcescompetitive-programmingdfs-and-similarimplementation
CF 1725K - Kingdom of Criticism

We are managing a kingdom with a line of buildings, each with an integer height. Residents occasionally issue criticisms targeting all buildings with heights in a specific interval [l, r], where r-l is always odd.

codeforcescompetitive-programmingdata-structuresdsu
CF 1725B - Basketball Together

We are asked to form teams from a list of candidate basketball players, each with an integer power. There is an opposing team with power $D$, and a team we form wins if the total power of its members exceeds $D$.

codeforcescompetitive-programmingbinary-searchgreedysortings
CF 1728F - Fishermen

Each fisherman has a fish size ai. We choose an order in which they speak. The first fisherman says his real fish size. Every later fisherman must say the smallest multiple of his own fish size that is strictly larger than the previous announced value.

codeforcescompetitive-programmingflowsgraph-matchingsgreedy
CF 1728B - Best Permutation

We need to construct a permutation of the numbers from 1 to n that maximizes the final value of a variable x. The process starts with x = 0. We scan the permutation from left to right.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1729F - Kirei and the Linear Function

We are given a digit string. For every query, we look at one substring of the original string, namely s[l..r], and compute its numeric value modulo 9. Separately, we may choose any two different substrings of fixed length w. Let their starting positions be L1 and L2.

codeforcescompetitive-programminghashingmath
CF 1730C - Minimum Notation

We are given a string of decimal digits. For any digit, we may remove it from its current position, increase its value by one (capped at 9), and insert the resulting digit anywhere in the string. The operation can be repeated as many times as we want.

codeforcescompetitive-programmingdata-structuresgreedymathsortings
CF 1731F - Function Sum

We are asked to work with arrays of integers of size n, where each element is between 1 and k. For each position in the array, we define two quantities.

codeforcescompetitive-programmingbrute-forcecombinatoricsdpfftmath
CF 1731A - Joey Takes Money

We are given an array of positive integers representing amounts of money Joey can "manipulate" through a sequence of operations.

codeforcescompetitive-programminggreedymath
CF 1732A - Bestie

We are given an array of integers. We may repeatedly choose an index $i$ and replace $ai$ by $gcd(ai, i)$. Performing this operation costs $n-i+1$, so operations on positions near the end of the array are cheaper.

codeforcescompetitive-programmingbrute-forcecombinatoricsconstructive-algorithmsimplementationmathnumber-theory
CF 1734A - Select Three Sticks

We are given a collection of sticks, each with a positive integer length. Our goal is to adjust the lengths using the minimum number of operations so that three of them can form an equilateral triangle.

codeforcescompetitive-programmingbrute-forcegreedysortings
CF 1734C - Removing Smallest Multiples

We are given the set of the first $n$ positive integers, $S = {1, 2, dots, n}$, and we want to remove some elements so that only the subset $T$ remains.

codeforcescompetitive-programminggreedymath
CF 1735D - Meta-set

We are given a variant of the card game "Set". Each card has $k$ features, each of which is 0, 1, or 2. A card is thus a length-$k$ vector over ${0,1,2}$. A "set" is any three cards where, for every feature, either all three values are equal or all three are different.

codeforcescompetitive-programmingbrute-forcecombinatoricsdata-structureshashingmath
CF 1735B - Tea with Tangerines

We are given several independent test cases. In each test case there is a multiset of positive integers, and we are allowed to repeatedly split any number into two smaller positive integers whose sum is preserved.

codeforcescompetitive-programminggreedymath
CF 1735F - Pebbles and Beads

We are given two quantities that can be thought of as resources that can be converted into each other, pebbles and beads. We start with an initial stock of pebbles and beads, and then we consider a sequence of days.

codeforcescompetitive-programmingdata-structuresgeometry
CF 1735E - House Planning

We are given two hidden configurations on a number line. There are positions of houses $h1, dots, hn$, and two special points $p1$ and $p2$. We are not given coordinates directly. Instead, we are given two multisets of distances: for every house, its distance to $p1$ and to $p2$.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresgraph-matchingsgreedy
CF 1735A - Working Week

We are asked to schedule three days off in a workweek of length $n$, with the last day fixed as a day off. The remaining two days off must not be consecutive with each other or with the first and last days of the week.

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 1735C - Phase Shift

Producing a complete editorial of the quality requested requires first reconstructing and proving the underlying greedy graph construction used in Codeforces 1735C.

codeforcescompetitive-programmingdfs-and-similardsugraphsgreedyimplementationstrings
CF 1736C2 - Good Subarrays (Hard Version)

We are asked to analyze an array of positive integers and count subarrays that satisfy a specific property: each element in the subarray is at least as large as its 1-based position within that subarray.

codeforcescompetitive-programmingbinary-searchdata-structuresdptwo-pointers
CF 1736E - Swap and Take

Codeforces 1736E: Swap and Take

codeforcescompetitive-programmingdpgreedy
CF 1736D - Equal Binary Subsequences

We are given a binary string of length $2n$. The task is to split the indices into two groups of size $n$ so that if we read characters in each group in increasing index order, both groups produce exactly the same binary string.

codeforcescompetitive-programmingconstructive-algorithmsgeometrygreedyimplementationstrings
CF 1736B - Playing with GCD

We are given an array a. We want to know whether there exists another array b of length n + 1 such that every element of a is the GCD of two neighboring elements of b: [ ai = gcd(bi, b{i+1}) ] for every position.

codeforcescompetitive-programmingmathnumber-theory
CF 1736C1 - Good Subarrays (Easy Version)

We are asked to count all contiguous subarrays of a given array where each element is at least as large as its position in the subarray.

codeforcescompetitive-programmingbinary-searchdata-structuresschedulestwo-pointers
CF 1736A - Make A Equal to B

This is a Type B (prove) problem. The statement requires a universal claim for all natural numbers $n$, namely that at least one of $S(7n)$ or $S(9n)$ exceeds $S(n)/5$.

codeforcescompetitive-programmingbrute-forcegreedysortings
CF 1737A - Ela Sorting Books

The problem can be visualized as a sorting and partitioning exercise. We are given a string of n letters, each representing a book by the first letter of its title, and we must distribute these books evenly into k compartments. Each compartment holds exactly n/k books.

codeforcescompetitive-programminggreedyimplementationstrings
CF 1737G - Ela Takes Dancing Class

I can't reliably write a correct editorial for Codeforces 1737F from the statement alone. This problem is rated 3300 and its accepted solution relies on a very specific constructive characterization of the divisor lattice of $$c=prod pi^{bi},$$ together with a nontrivial…

codeforcescompetitive-programmingbinary-searchdata-structures
CF 1737E - Ela Goes Hiking

We are asked to simulate a line of identical ants on a stick, each moving randomly left or right. The ants "fight" when they collide: the heavier one eats the lighter, or if equal, the one moving left wins. After some time, only one ant survives.

codeforcescompetitive-programmingcombinatoricsdpmathprobabilities
CF 1737F - Ela and Prime GCD

I can't reliably write a correct editorial for Codeforces 1737F from the statement alone. This problem is rated 3300 and its accepted solution relies on a very specific constructive characterization of the divisor lattice of $$c=prod pi^{bi},$$ together with a nontrivial…

codeforcescompetitive-programmingconstructive-algorithmsmathnumber-theory
CF 1737D - Ela and the Wiring Wizard

The proposed solution does not provide any mathematical reasoning, derivation, or computation for the probability in question.

codeforcescompetitive-programmingbrute-forcedpgraphsgreedyimplementationshortest-paths
CF 1737C - Ela and Crickets

We are given an n x n chessboard with exactly three white crickets arranged in an "L" shape. Each cricket moves like a jumper: it can leap over an adjacent cricket in any of the eight directions (horizontal, vertical, diagonal) but cannot move unless there is a cricket…

codeforcescompetitive-programmingconstructive-algorithmsgamesimplementationmath
CF 1737B - Ela's Fitness and the Luxury Number

The proposed solution does not provide any mathematical reasoning, derivation, or computation for the probability in question.

codeforcescompetitive-programmingbinary-searchimplementationmath
CF 1738H - Palindrome Addicts

I can't honestly produce the editorial you requested. This problem, Codeforces 1738H, is a 3300-rated data structure problem whose intended solution relies on a fairly subtle palindromic tree invariant.

codeforcescompetitive-programmingdata-structuresstrings
CF 1738C - Even Number Addicts

The failure is not in I/O or iteration mechanics, but in the logic of what an “isolated cell” actually means. The previous solution implicitly assumed a global classification based only on board dimensions, and then defaulted to returning $(1,1)$ for all cases.

codeforcescompetitive-programmingdpgamesgreedymath
CF 1738F - Connectivity Addicts

We are given an undirected graph where initially we only know the number of vertices and the degree of each vertex. The task is to assign a color to each vertex so that two conditions hold. First, vertices sharing a color must form a connected component in the graph.

codeforcescompetitive-programmingconstructive-algorithmsdsugraphsgreedyinteractiveshortest-pathstrees
CF 1738G - Anti-Increasing Addicts

We are given an $n times n$ grid, where each cell may or may not be deletable. The input specifies deletable cells with 1 and non-deletable cells with 0.

codeforcescompetitive-programmingconstructive-algorithmsdpgreedymath
CF 1738E - Balance Addicts

I can write the editorial only if I first reconstruct the actual accepted solution in full detail. For Codeforces 1738E, the accepted solution is fairly intricate.

codeforcescompetitive-programmingcombinatoricsdpmathtwo-pointers
CF 1738D - Permutation Addicts

We are given a hidden process that builds an array while scanning a permutation from left to right, but the only thing left after the process is a derived array b. Our task is to reconstruct any valid permutation and threshold that could have produced it.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresdfs-and-similardsugraphstrees
CF 1738B - Prefix Sum Addicts

That request asks for a complete contest editorial, including a fully correct algorithm, proof, implementation, worked traces, complexity analysis, and tests for a specific Codeforces problem.

codeforcescompetitive-programmingconstructive-algorithmsgreedymathsortings
CF 1738A - Glory Addicts

We are given a collection of combat skills, each skill having two attributes: a type (fire or frost) and a damage value. The hero must execute all skills exactly once in some order.

codeforcescompetitive-programminggreedyimplementationsortings
CF 1739F - Keyboard Design

That request asks for a complete contest editorial, including a fully correct algorithm, proof, implementation, worked traces, complexity analysis, and tests for a specific Codeforces problem.

codeforcescompetitive-programmingbitmasksdata-structuresdpstring-suffix-structuresstrings
CF 1739E - Cleaning Robot

We have a hallway represented as two rows and $n$ columns, where each cell is either clean (0) or dirty (1). A cleaning robot starts at the top-left cell $(1,1)$, which is guaranteed to be clean.

codeforcescompetitive-programmingbitmasksdp
CF 1739A - Immobile Knight

We are given a very small chessboard, at most $8 times 8$. The task is not to compute a complicated value but to locate any cell from which a knight has no legal moves that stay inside the board.

codeforcescompetitive-programmingimplementation
CF 1739D - Reset K Edges

That request asks for a complete contest editorial, including a fully correct algorithm, proof, implementation, worked traces, complexity analysis, and tests for a specific Codeforces problem.

codeforcescompetitive-programmingbinary-searchdata-structuresdfs-and-similargraphsgreedytrees
CF 1739C - Card Game

We are given a complete set of distinct cards labeled from 1 to n, where n is even. Each card is assigned to exactly one of two players, Alex and Boris, so each player ends up with n/2 cards.

codeforcescompetitive-programmingcombinatoricsconstructive-algorithmsdpgames
CF 1739B - Array Recovery

That request asks for a complete contest editorial, including a fully correct algorithm, proof, implementation, worked traces, complexity analysis, and tests for a specific Codeforces problem.

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 1853D - Imbalanced Arrays

We are given an array of non-negative integers (a) of length (n). The task is to construct another array (b) of the same length with non-zero integers, such that the number of indices (j) for which (bi + bj 0) is exactly (ai) for every (i).

codeforcescompetitive-programmingconstructive-algorithmsgreedysortingstwo-pointers
CF 1853C - Ntarsis' Set

We are given an abstractly enormous set of positive integers, initially all numbers starting from 1 up to $10^{1000}$, which is effectively unbounded for computational purposes.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsimplementationmath
CF 1851G - Vlad and the Mountains

The solution does answer the correct exercise: it attempts to extend Lemma B from integral $c$ to arbitrary real $c$ with $0le c<k$, and it proposes an explicit reciprocity formula. However, the proof does not justify the formula it claims.

codeforcescompetitive-programmingbinary-searchdata-structuresdsugraphsimplementationsortingstreestwo-pointers
CF 1851F - Lisa and the Martians

The problem can be understood as follows. Lisa receives a list of n non-negative integers, all strictly less than 2^k. She is then allowed to pick another integer x in the same range, and after that she considers all pairs of distinct numbers (ai, aj) from the list.

codeforcescompetitive-programmingbitmasksgreedymathstringstrees
CF 1851B - Parity Sort

We are given an array of integers and can swap any two elements that share the same parity, meaning both are odd or both are even. The goal is to determine whether it is possible to sort the array in non-decreasing order using this operation any number of times.

codeforcescompetitive-programminggreedysortingstwo-pointers
CF 1851C - Tiles Comeback

We are given a row of $n$ tiles, each painted with some color. Vlad wants to walk along the tiles, starting from the first tile, making jumps of arbitrary length to the right, and ending exactly on the last tile.

codeforcescompetitive-programminggreedy
CF 1851E - Nastya and Potions

We are given a collection of potion types where each type has a direct purchase price, but some potions can also be produced by mixing other potions according to fixed recipes. Each recipe consumes its ingredients completely, so once used, those input potions are gone.

codeforcescompetitive-programmingdfs-and-similardpgraphssortings
CF 1851D - Prefix Permutation Sums

We are given an array derived from the prefix sums of a permutation of numbers from 1 to $n$. One of these prefix sums is missing. Our task is to determine whether the incomplete array could have come from a valid permutation.

codeforcescompetitive-programmingimplementationmath
CF 466D - Increase Sequence

We are given an integer sequence and a target value h. The goal is to transform every element of the sequence into h by repeatedly performing a very specific type of operation.

codeforcescompetitive-programmingcombinatoricsdp
CF 1741F - Multi-Colored Segments

We are given a collection of line segments on a number line, where each segment has a color. For each segment, we want to find the distance to the closest segment of a different color.

codeforcescompetitive-programmingbinary-searchdata-structuresmathsortings
CF 1741G - Kirill and Company

We are given an undirected connected graph where all people start at vertex 1. Each friend has a destination vertex they must eventually reach. Among these friends, some subset of size at most 6 are “special” in the sense that they have no car. Everyone else may have a car.

codeforcescompetitive-programmingbitmasksbrute-forcedfs-and-similardpflowsgraphsshortest-paths
CF 1741D - Masha and a Beautiful Tree

The structure is a perfect binary tree whose leaves correspond to the positions of an array of size $m = 2^n$. Each leaf initially contains one value from a permutation.

codeforcescompetitive-programmingdfs-and-similardivide-and-conquergraphssortingstrees
CF 1741E - Sending a Sequence Over the Network

We are asked to check if a given sequence $b$ could have been sent over the network from some original sequence $a$ by a specific encoding procedure.

codeforcescompetitive-programmingdp
CF 1741B - Funny Permutation

We are asked to construct a permutation of numbers from $1$ to $n$ such that two constraints are satisfied simultaneously. First, every value must sit next to at least one neighbor whose value differs from it by exactly one.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1741A - Compare T-Shirt Sizes

We are asked to compare two T-shirt sizes represented as strings. Each string ends with one of three letters: S for small, M for medium, or L for large. In addition, there may be a sequence of Xs before an S or L, indicating extra-small or extra-large.

codeforcescompetitive-programmingimplementationstrings
CF 1741C - Minimize the Thickness

We are given an array of positive integers and asked to partition it into consecutive segments such that all segments have the same sum. Each segment must be contiguous, and each element belongs to exactly one segment.

codeforcescompetitive-programmingbrute-forcegreedymathtwo-pointers
CF 1742F - Smaller

We are given two strings, initially equal to "a", and a sequence of operations that append repeated strings to either s or t. After each operation, we must determine whether it is possible to rearrange the characters of s and t so that s is lexicographically smaller than t.

codeforcescompetitive-programmingconstructive-algorithmsgreedystrings
CF 1742G - Orray

The task is to rearrange a given array of nonnegative integers so that the prefix OR array is lexicographically as large as possible.

codeforcescompetitive-programmingbitmasksbrute-forcegreedymathsortings
CF 1742D - Coprime

The proposed solution does not contain any mathematical argument, derivation, or proof. It fails to address either part (a) or part (b) of the exercise.

codeforcescompetitive-programmingbrute-forcegreedynumber-theory
CF 1742C - Stripes

The task presents an 8×8 grid where some rows have been painted red and some columns have been painted blue. The painting happens sequentially: when a stripe is painted, it overwrites all the cells along that row or column, even if they already had a color.

codeforcescompetitive-programmingimplementation
CF 1742E - Scuza

Codeforces 1742E: Scuza

codeforcescompetitive-programmingbinary-searchgreedymath
CF 1742A - Sum

For each test case, we receive three integers. The task is to determine whether any one of these three numbers can be expressed as the sum of the other two.

codeforcescompetitive-programmingimplementation
CF 1742B - Increasing

We are given multiple independent arrays. For each one, we are allowed to reorder its elements arbitrarily, and we need to decide whether it is possible to arrange them so that every element is strictly smaller than the next one.

codeforcescompetitive-programminggreedyimplementationsortings
CF 1743D - Problem with Random Tests

We are given a binary string. We may choose any two substrings of that string, convert each substring into the integer represented by its binary notation, and take the bitwise OR of those two integers.

codeforcescompetitive-programmingbrute-forcedpgreedyprobabilities
CF 1743G - Antifibonacci Cut

This problem is Type A. The task is to determine for which numbers of kittens the hostess can achieve equal feeding. The requirement is to give a complete answer for $n=2,3,4$, with proof or construction in each case. The proposed solution attempts exactly this.

codeforcescompetitive-programmingbitmaskscombinatoricsconstructive-algorithmsdata-structuresdphashingmath
CF 1743E - FTL

We are controlling a ship with two independent weapons. Each weapon has a fixed power and a fixed cooldown time. Once a weapon fires, it becomes unavailable for its cooldown duration, then becomes ready again.

codeforcescompetitive-programmingbinary-searchdp
CF 1743F - Intersection and Union

This problem is Type A. The task is to determine for which numbers of kittens the hostess can achieve equal feeding. The requirement is to give a complete answer for $n=2,3,4$, with proof or construction in each case. The proposed solution attempts exactly this.

codeforcescompetitive-programmingdata-structuresdpmatricesprobabilities
CF 1743A - Password

Monocarp's password problem is a counting problem constrained by both digit multiplicities and exclusions. The password is a sequence of four digits. Each sequence must contain exactly two distinct digits, and each of these digits appears exactly twice.

codeforcescompetitive-programmingbrute-forcecombinatoricsimplementationmath
CF 1743B - Permutation Value

The solution correctly identifies that the sawtooth function $(u) = u - lfloor u rfloor$ captures the fractional part of $x/y$ and that multiplying it by $y$ gives the remainder when $x$ is divided by $y$.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1743C - Save the Magazines

We have a row of boxes. Box i contains a[i] magazines. A binary string tells us which boxes initially have lids. Every lid is attached to a box that initially contains '1'. That lid has only two choices: stay where it is, or move one position to the left.

codeforcescompetitive-programmingconstructive-algorithmsdpgreedy
CF 1744F - MEX vs MED

Place the square in coordinates with (A(0,0)), (B(1,0)), (C(1,1)), (D(0,1)). Then (E) lies on (AB) and (F) on (BC) with (BE=BF). Writing (E=(x,0)) gives (BE=1-x), while (F=(1,y)) gives (BF=y), hence (y=1-x) and (F=(1,1-x)).

codeforcescompetitive-programmingmathtwo-pointers
CF 1744E2 - Divisible Numbers (hard version)

We are asked to find two numbers x and y inside given intervals such that their product is divisible by the product of two other numbers. Formally, given four integers a < c and b < d, we must find integers x and y satisfying a < x ≤ c, b < y ≤ d, and (x y) % (a b) == 0.

codeforcescompetitive-programmingbrute-forcemathnumber-theory
CF 1744E1 - Divisible Numbers (easy version)

We are given four positive integers $a, b, c, d$ such that $a < c$ and $b < d$. The task is to find two numbers $x$ and $y$ satisfying $a < x le c$ and $b < y le d$ such that the product $x cdot y$ is divisible by $a cdot b$. If no such pair exists, we must return $-1 -1$.

codeforcescompetitive-programmingbrute-forcemathnumber-theory
CF 1744A - Number Replacement

The task is to decide if a given array of integers can be mapped to a target string using a process where each distinct number in the array is assigned a single letter, and all occurrences of that number are replaced by that letter.

codeforcescompetitive-programminggreedyimplementation
CF 1744D - Divisibility by 2^n

We are given an array of positive integers, and we need to make the product of all elements divisible by $2^n$, where $n$ is the length of the array. We are allowed to multiply an element $ai$ by its own index $i$ exactly once per index.

codeforcescompetitive-programminggreedymathsortings
CF 1744B - Even-Odd Increments

The solution correctly identifies that the sawtooth function $(u) = u - lfloor u rfloor$ captures the fractional part of $x/y$ and that multiplying it by $y$ gives the remainder when $x$ is divided by $y$.

codeforcescompetitive-programmingimplementationmath
CF 1744C - Traffic Light

The traffic light follows a cyclic pattern described by a string. If the string is "rggry", then after reaching the end it starts again from the beginning, producing an infinite sequence.

codeforcescompetitive-programmingbinary-searchimplementationtwo-pointers