brain

tamnd's digital brain — notes, problems, research

41650 notes

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 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 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 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
CF 1746G - Olympiad Training

This is a Type B problem, a pure proof problem. The requirement is to prove the stated geometric claim: that the five points $C,K,L,O,N$ are concyclic. A coordinate proof is perfectly appropriate.

codeforcescompetitive-programmingbinary-searchdata-structuresdpflowsgeometryimplementationsortings
CF 1746A - Maxmina

We are given a binary array and two types of reduction operations that shrink the array while replacing segments with either a minimum or a maximum.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1746F - Kazaee

Producing a correct editorial for Codeforces 1746F requires reconstructing the intended probabilistic proof, the exact hashing scheme, the error analysis, and the implementation details used to achieve acceptance at $n,q le 3cdot 10^5$.

codeforcescompetitive-programmingdata-structureshashingprobabilities
CF 1746E1 - Joking (Easy Version)

In this problem, you are trying to identify a hidden integer x between 1 and n. You can ask whether x belongs to any subset of numbers you choose. Each response is either "YES" or "NO".

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsinteractiveternary-search
CF 1746E2 - Joking (Hard Version)

I can't reliably diagnose a timeout from the input/output pair alone. A timeout means the program is running too long, not that it produced an incorrect value. To identify the bug, I need to see the actual Python code that timed out.

codeforcescompetitive-programmingdpinteractive
CF 1746D - Paths on the Tree

I can't reliably diagnose a timeout from the input/output pair alone. A timeout means the program is running too long, not that it produced an incorrect value. To identify the bug, I need to see the actual Python code that timed out.

codeforcescompetitive-programmingdfs-and-similardpgreedysortingstrees
CF 1746B - Rebellion

We are given a binary array, containing only zeroes and ones, and we can perform an operation where we choose two distinct elements, add the value of the first element to the second, and then remove the first element. Each operation reduces the size of the array by one.

codeforcescompetitive-programmingconstructive-algorithmsgreedytwo-pointers
CF 1746C - Permutation Operations

The reviewer is correct that the original submission contains no solution at all. A complete solution must be built from the results reported in the cited paper of R. G. Stoneham, A Study of 60,000 Digits of the Transcendental $e$ (Amer. Math.

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementationmath
CF 1747E - List Generation

We are asked to count structures made of two non-decreasing sequences of integers that start at zero and end at $n$ and $m$, respectively. The sequences, which we can call $a$ and $b$, must satisfy that no consecutive pair of elements sum to the same value.

codeforcescompetitive-programmingcombinatoricsdpmath
CF 1747A - Two Groups

We are given a sequence of integers and we must split it into two disjoint groups. Every element must go into exactly one group, and both groups are allowed to be empty. Once the split is fixed, we compute the sum of each group.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1747D - Yet Another Problem

We are given a static array and multiple queries on contiguous segments. For each query segment, we are allowed to repeatedly apply a very specific transformation: pick any subsegment of odd length, compute the XOR of all values inside it, and overwrite the entire chosen…

codeforcescompetitive-programmingbinary-searchbitmasksconstructive-algorithmsdata-structures
CF 1747B - BAN BAN

Let the triangle be $ABC$, let $H$ be its orthocenter, and let $omega$ be its incircle with center $I$ and radius $r$. The beetles move along the altitudes. Since they all move with the same speed, after time $tau$ the distances traveled from the vertices are equal.

codeforcescompetitive-programmingconstructive-algorithms
CF 1747C - Swap Game

We are asked to determine the winner in a two-player game played on an array of positive integers. Alice moves first. On each turn, the player inspects the first element of the array. If it is zero, the player loses immediately.

codeforcescompetitive-programminggames
CF 1748F - Circular Xor Reversal

Let the triangle be $ABC$, let $H$ be its orthocenter, and let $omega$ be its incircle with center $I$ and radius $r$. The beetles move along the altitudes. Since they all move with the same speed, after time $tau$ the distances traveled from the vertices are equal.

codeforcescompetitive-programmingbitmasksconstructive-algorithms
CF 1748E - Yet Another Array Counting Problem

We are asked to count the number of arrays b of length n that satisfy a very particular property derived from an array a. Each element bi must be between 1 and m. For any subarray [l, r], the leftmost maximum in b[l..r] must be at the same position as in a[l..r].

codeforcescompetitive-programmingbinary-searchdata-structuresdivide-and-conquerdpflowsmathtrees
CF 1748A - The Ultimate Square

We are given a sequence of rectangular wooden blocks. The i-th block always has height 1, and its length grows slowly with i according to the rule ⌈i/2⌉.

codeforcescompetitive-programmingmath
CF 1748D - ConstructOR

Let the triangle be $ABC$, let $H$ be its orthocenter, and let $omega$ be its incircle with center $I$ and radius $r$. The beetles move along the altitudes. Since they all move with the same speed, after time $tau$ the distances traveled from the vertices are equal.

codeforcescompetitive-programmingbitmaskschinese-remainder-theoremcombinatoricsconstructive-algorithmsmathnumber-theory
CF 1748C - Zero-Sum Prefixes

We are given a sequence of integers, and we care about how often its prefix sums hit zero. A prefix sum at position i is the sum of the first i elements, and we score the array by counting how many of these prefix sums are exactly zero.

codeforcescompetitive-programmingbrute-forcedata-structuresdpgreedyimplementation
CF 1748B - Diverse Substrings

Let the triangle be $ABC$, let $H$ be its orthocenter, and let $omega$ be its incircle with center $I$ and radius $r$. The beetles move along the altitudes. Since they all move with the same speed, after time $tau$ the distances traveled from the vertices are equal.

codeforcescompetitive-programmingbrute-forceimplementationstrings
CF 1749E - Cactus Wall

The problem presents a rectangular grid representing a sand field in which some cells already have cacti. Cacti cannot be adjacent to each other horizontally or vertically.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similargraphsshortest-paths
CF 1749F - Distance to the Path

We are given a tree with $n$ vertices. Each vertex initially holds a value of zero. There are two kinds of queries. The first type asks for the current value of a specific vertex.

codeforcescompetitive-programmingdata-structuresdfs-and-similartrees
CF 1749A - Cowardly Rooks

Ah, now I see the real issue. The previous solution overgenerates operations. It blindly flips every 1 in a individually and then applies parity-fixing operations.

codeforcescompetitive-programminggreedyimplementation
CF 1749D - Counting Arrays

We are asked to count arrays of length up to $n$ with values between $1$ and $m$ where there exists more than one valid removal sequence.

codeforcescompetitive-programmingcombinatoricsdpmathnumber-theory
CF 1749B - Death's Blessing

We are asked to determine the asymptotic value of the probability that $k+1$ consecutive bits generated by $$Yn = (Y{n-1} + Y{n-2}) bmod 2$$ contain more 1s than 0s, under the conditions that $k 2l$ and the period length of this recurrence is $2^l - 1$, for large $k$.

codeforcescompetitive-programminggreedy
CF 1749C - Number Game

We are asked to analyze a two-player game played on an array of positive integers. Alice chooses a number of stages $k$ she wants to play, and in each stage she must remove an element from the array that is at most the number of the remaining stage.

codeforcescompetitive-programmingbinary-searchdata-structuresgamesgreedyimplementation
CF 1750H - BinaryStringForces

I can't reliably write a correct editorial for Codeforces 1750H from the statement alone. This is a 3500-rated problem, and producing a full editorial with proof, algorithm, complexity analysis, worked examples, and code requires knowing the actual accepted solution.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresdp
CF 1750G - Doping

Codeforces 1750G: Doping

codeforcescompetitive-programmingcombinatoricsdpmath
CF 1750F - Majority

We are asked to count how many binary strings of length $n$ can be fully turned on using a special operation called "electricity spread." Each string represents a line of servers, where 1 means the server is online and 0 means it is offline.

codeforcescompetitive-programmingcombinatoricsdpmathstrings
CF 1750C - Complementary XOR

We are given two binary strings of equal length. A single operation chooses a segment ([l,r]). Every bit of string (a) inside the segment is flipped, while every bit of string (b) outside the segment is flipped. The goal is not to transform one string into the other.

codeforcescompetitive-programmingconstructive-algorithmsimplementation
CF 1750B - Maximum Substring

We are given a binary string and asked to examine every contiguous segment. For each segment we count how many zeros and ones it contains, and then assign it a score based on those counts. If both symbols appear, the score is the product of the two counts.

codeforcescompetitive-programmingbrute-forcegreedyimplementation
CF 1750E - Bracket Cost

We are given a binary string made of parentheses, and we examine every contiguous segment of it independently. For each segment, we are allowed to transform it into a correct bracket sequence using two operations: we can insert single parentheses anywhere, and we can take any…

codeforcescompetitive-programmingbinary-searchdata-structuresdivide-and-conquerdpgreedystrings
CF 1750D - Count GCD

We are asked to count arrays $b$ that match a sequence of prefix greatest common divisors. Concretely, for each position $i$, the GCD of the first $i$ elements of $b$ must equal $ai$. Each element $bi$ must be an integer between 1 and $m$.

codeforcescompetitive-programmingcombinatoricsmathnumber-theory
CF 1750A - Indirect Sort

We are given a small permutation, meaning every number from 1 to n appears exactly once. The task is to determine whether we can transform this array into sorted order using a very specific operation that involves three indices i < j < k.

codeforcescompetitive-programmingconstructive-algorithmsimplementationmath
CF 1753F - Minecraft Series

The reported failure is not actually an algorithmic error. The traceback shows: This means the test harness tried to execute: but the submitted code did not define a function named solve. The program failed before reading the input or constructing any permutation.

codeforcescompetitive-programmingbrute-forcetwo-pointers
CF 1753E - N Machines

We are given a sequence of machines applied one after another to a single value starting from 1. Each machine either adds a fixed value or multiplies by a fixed value. The final result after running through the entire chain depends entirely on the order of machines.

codeforcescompetitive-programmingbinary-searchbrute-forcegreedy
CF 1753D - The Beach

We are given a grid representing a beach where each cell is either empty sand, an obstacle, or part of a sunbed. Each sunbed occupies exactly two adjacent cells and is encoded using directional halves, so each pair of cells forms a rigid domino.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similargraphsshortest-paths
CF 1753B - Factorial Divisibility

We are asked to determine whether the sum of factorials of an array of integers is divisible by another factorial. More concretely, we are given an array [a1, a2, ..., an] and a number x. We want to know if (a1! + a2! + ... + an!) is divisible by x!.

codeforcescompetitive-programmingmathnumber-theory
CF 1753C - Wish I Knew How to Sort

We are given a binary array, meaning every element is either 0 or 1. The array evolves through repeated random operations: at each step we pick a uniformly random pair of indices $(i, j)$ with $i < j$.

codeforcescompetitive-programmingdpmathprobabilities
CF 1753A1 - Make Nonzero Sum (easy version)

We are given an array consisting solely of 1s and -1s. Our task is to split this array into consecutive segments where each segment has an alternating sum defined as the first element minus the second plus the third minus the fourth, and so on.

codeforcescompetitive-programmingconstructive-algorithmsdpgreedy
CF 1753A2 - Make Nonzero Sum (hard version)

Something went wrong while generating the response. If this issue persists please contact us through our help center at [help.openai.com](https://help.openai.com/).

codeforcescompetitive-programmingconstructive-algorithmsdpgreedy
CF 1754B - Kevin and Permutation

We are asked to rearrange the integers from 1 to n in a sequence such that the smallest difference between any two consecutive numbers is as large as possible.

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 1754A - Technical Support

We are given a sequence of chat messages consisting only of two types: client questions and support answers. The conversation is written in time order, and the first message is always a question.

codeforcescompetitive-programminggreedy
CF 1758B - XOR = Average

We are asked to construct, for each test case, a sequence of integers whose XOR of all elements equals the arithmetic mean of the sequence. In other words, if we combine all numbers using XOR and also compute their sum divided by the length, these two values must match exactly.

codeforcescompetitive-programmingconstructive-algorithms
CF 1758F - Decent Division

I can't reliably write a complete editorial and accepted solution for Codeforces 1758F from memory alone. This is a highly nontrivial 3000-rated constructive/data-structure problem, and the official editorial text is not available through the sources I can access right now.

codeforcescompetitive-programmingconstructive-algorithmsdata-structures
CF 1758C - Almost All Multiples

We need to construct a permutation of the integers from 1 to n with three special requirements. The first position must contain x. The last position must contain 1. For every position i from 1 to n-1, the value placed there must be a multiple of i.

codeforcescompetitive-programminggreedynumber-theory
CF 1758E - Tick, Tock

We are given an $n times m$ grid where each cell either has a clock showing a number between 0 and $h-1$ or is empty. The allowed moves let us pick a row or column and advance all clocks in that row or column by one hour modulo $h$.

codeforcescompetitive-programmingcombinatoricsdfs-and-similardsugraphs
CF 1758D - Range = √Sum

We are asked to construct a sequence of distinct integers of length $n$ such that the difference between the maximum and minimum element equals the square root of the sum of all elements.

codeforcescompetitive-programmingbinary-searchbrute-forceconstructive-algorithmsmathtwo-pointers
CF 1758A - SSeeeeiinngg DDoouubbllee

We are given a string s. If we "double" the string, every character appears twice. For example, "abc" becomes the multiset of characters in "aabbcc". Our task is not to output the doubled string itself.

codeforcescompetitive-programmingconstructive-algorithmsstrings
CF 1759F - All Possible Digits

We have n quests. Quest i gives a[i] coins whenever it is completed. During d days we may perform at most one quest per day. After doing a quest, we must wait k days before doing that same quest again.

codeforcescompetitive-programmingbinary-searchdata-structuresgreedymathnumber-theory
CF 1759G - Restore the Permutation

We are given the array of pairwise maxima of an unknown permutation. The permutation has even length n. If we group its elements into pairs (p1, p2), (p3, p4), ... and replace each pair by its maximum, we obtain an array b of length n/2.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsdata-structuresgreedymath
CF 1759D - Make It Round

We are repeatedly given a starting integer and a limit on how much we are allowed to scale it. For each case, we choose a multiplier $k$ between 1 and $m$, multiply the original number by $k$, and obtain a candidate result.

codeforcescompetitive-programmingbrute-forcenumber-theory
CF 1759E - The Humanoid

We have a humanoid with initial power h and a collection of astronauts with powers a[i]. The humanoid can absorb an astronaut only if the astronaut's power is strictly smaller than the humanoid's current power.

codeforcescompetitive-programmingbrute-forcedpsortings
CF 1759C - Thermostat

We are given a thermostat whose current temperature is a, and we want to adjust it to a target temperature b. The thermostat has hard limits: it can only be set to temperatures between l and r inclusive, and any single adjustment must change the temperature by at least x.

codeforcescompetitive-programminggreedymathshortest-paths
CF 1759B - Lost Permutation

We are given several numbers that definitely belong to some unknown permutation. The missing numbers were lost, but we know the sum of all missing values.

codeforcescompetitive-programmingmath
CF 1759A - Yes-Yes?

We are given a short string for each query and we want to decide whether it could have appeared inside an infinitely repeated pattern formed by writing the word “Yes” over and over again without separators.

codeforcescompetitive-programmingimplementationstrings
CF 1760G - SlavicG's Favorite Problem

We are working with a weighted tree where each edge contributes a bitwise XOR value when traversed. A walk starts at node a with an accumulated value x = 0. Every time we move along an edge, we update x by XORing it with that edge’s weight.

codeforcescompetitive-programmingbitmasksdfs-and-similargraphs
CF 1760F - Quests

We have n quests. Quest i gives a[i] coins whenever it is completed. During d days we may perform at most one quest per day. After doing a quest, we must wait k days before doing that same quest again.

codeforcescompetitive-programmingbinary-searchgreedysortings
CF 1760D - Challenging Valleys

We are given an array of integers and need to determine whether it forms a "valley" according to a precise definition. Conceptually, a valley is a flat subarray that is lower than its neighbors on both sides.

codeforcescompetitive-programmingimplementationtwo-pointers
CF 1760E - Binary Inversions

We are working with a binary sequence where inversions come only from pairs where a 1 appears before a 0. The task allows us to optionally flip a single element, and we want to maximize the total number of such inversions after that single modification.

codeforcescompetitive-programmingdata-structuresgreedymath
CF 1760B - Atilla's Favorite Problem

We are given several lowercase strings. For each string, we want the smallest alphabet that contains every character appearing in that string. The alphabet is always a prefix of the English alphabet.

codeforcescompetitive-programminggreedyimplementationstrings
CF 1760A - Medium Number

The task is to determine the number that is neither the smallest nor the largest among three distinct integers. Each input case gives three numbers, and the output should identify the “middle” value.

codeforcescompetitive-programmingimplementationsortings
CF 1760C - Advantage

We have a list of competitors, each with a numeric strength. For every competitor, we want to compute their advantage over the strongest opponent that is not themselves. Concretely, if the array of strengths is [s1, s2, ...

codeforcescompetitive-programmingdata-structuresimplementationsortings
CF 1761G - Centroid Guess

We are given a hidden tree with n nodes, and we do not know its structure. Our goal is to identify its centroid, which is the unique node such that removing it leaves all connected components with at most n/2 nodes each.

codeforcescompetitive-programminginteractiveprobabilitiestrees
CF 1761E - Make It Connected

We are given an undirected graph and a special operation. Choosing a vertex flips all of its incident edges: every neighbor becomes a non-neighbor, and every non-neighbor becomes a neighbor.

codeforcescompetitive-programmingbinary-searchbrute-forceconstructive-algorithmsdsugraphsgreedymatricestreestwo-pointers
CF 1761F2 - Anti-median (Hard Version)

We are asked to count permutations of length $n$ that avoid a certain "bad" pattern in every odd-length subarray. A permutation is a rearrangement of numbers $1$ through $n$, and some entries may already be fixed while others are unknown.

codeforcescompetitive-programmingcombinatoricsdpmath