brain

tamnd's digital brain — notes, problems, research

43815 notes

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
CF 1761F1 - Anti-median (Easy Version)

We are asked to construct permutations of integers from 1 to (n) with a specific property: no subarray of odd length greater than or equal to three can have its middle element equal to the median of that subarray.

codeforcescompetitive-programmingdpmath
CF 1761D - Carry Bit

We are asked to count how many pairs of non-negative integers $a$ and $b$, each less than $2^n$, produce exactly $k$ carry bits when summed in binary.

codeforcescompetitive-programmingcombinatoricsmath
CF 1761C - Set Construction

We are given a binary $n times n$ matrix, and our task is to construct $n$ distinct non-empty sets of integers between $1$ and $n$.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similargraphsgreedy
CF 1761B - Elimination of a Ring

We are given a cyclic sequence, which means the first and last positions are also adjacent. Initially, no two adjacent elements are equal. At any moment, Muxii may choose one element and erase it. After that erasure, the ring checks whether equal values have become adjacent.

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementation
CF 1761A - Two Permutations

We are not asked to construct the permutations. We only need to decide whether two permutations of length n can exist such that they share exactly a positions at the beginning and exactly b positions at the end. Think about two permutations p and q.

codeforcescompetitive-programmingbrute-forceconstructive-algorithms
CF 1762G - Unequal Adjacent Elements

We are given an array of values and asked to reorder indices, not values, into a permutation. The permutation must satisfy two simultaneous constraints. First, every element from the third position onward must be strictly larger than the element two positions before it.

codeforcescompetitive-programmingconstructive-algorithmssortings
CF 1762C - Binary Strings are Fun

We are given a binary string s. For every prefix of s, we define a value f(prefix). To compute f(x), we look at all possible extensions of x. If x has length k, an extension has length 2k-1.

codeforcescompetitive-programmingcombinatoricsmath
CF 1762F - Good Pairs

We are asked to count the number of "good pairs" in an array. A pair of positions $(l, r)$ is good if we can move from index $l$ to $r$ by hopping forward in the array along a sequence of indices where each consecutive pair differs by at most $k$.

codeforcescompetitive-programmingbinary-searchdata-structuresdp
CF 1762E - Tree Sum

We are asked to consider edge-weighted trees with vertices numbered from 1 to $n$, where each edge has weight either $1$ or $-1$. A tree is called good if for every vertex, the product of the weights of all edges incident to that vertex equals $-1$.

codeforcescompetitive-programmingcombinatoricsmathtrees
CF 1762D - GCD Queries

We are asked to find an index of the element 0 in a hidden permutation of integers from 0 to n-1. The permutation is not given directly, but we can ask for the greatest common divisor (GCD) of any two distinct elements in the array.

codeforcescompetitive-programmingconstructive-algorithmsinteractivenumber-theory
CF 1762B - Make Array Good

We are asked to transform an array of positive integers into one that is "good" according to a divisibility property: for every pair of elements, the larger must be divisible by the smaller.

codeforcescompetitive-programmingconstructive-algorithmsimplementationnumber-theorysortings
CF 1762A - Divide and Conquer

We are given an array of positive integers and we are asked to make its sum even using a special operation: pick any element and replace it with its integer half, the floor of dividing by two.

codeforcescompetitive-programminggreedymathnumber-theory
CF 1763B - Incinerate

We are fighting a set of monsters. Every monster has a health value and a power value. Genos repeatedly performs attacks. If the current attack strength is k, every monster that is still alive loses k health simultaneously.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresimplementationmathsortings
CF 1763E - Node Pairs

We are given a directed graph on an unknown number of vertices. The graph is required to satisfy a structural condition: among all ordered pairs of vertices, there are exactly (p) pairs ((u,v)) with (u < v) such that both vertices can reach each other.

codeforcescompetitive-programmingdpgraphsmathnumber-theory
CF 1763F - Edge Queries

Codeforces 1763F: Edge Queries

codeforcescompetitive-programmingdata-structuresdfs-and-similardpdsugraphstrees
CF 1763D - Valid Bitonic Permutations

We are asked to count the number of permutations of the numbers from 1 to n that are bitonic and satisfy two fixed positions. A bitonic permutation is one that strictly increases up to a certain peak index, then strictly decreases afterward.

codeforcescompetitive-programmingcombinatoricsdpimplementationmathnumber-theory
CF 1763C - Another Array Problem

We are given an array of integers, and we are allowed to repeatedly apply a very specific transformation: pick two positions $i < j$, compute the absolute difference of the values at the ends, and overwrite the entire segment $[i, j]$ with that single value.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedy
CF 1763A - Absolute Maximization

We have an array of integers. An operation allows us to pick any two positions and a bit index, then swap the values of that bit between the two numbers. The crucial detail is that the bit position is fixed during a swap.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsgreedymath
CF 1764G3 - Doremy's Perfect DS Class (Hard Version)

We are given a hidden permutation of integers from 1 to $n$, and our goal is to identify the position of the number 1 with at most 20 interactive queries.

codeforcescompetitive-programmingbinary-searchinteractive
CF 1764G1 - Doremy's Perfect DS Class (Easy Version)

We are asked to locate the position of the number 1 in a hidden permutation of integers from 1 to n. The permutation is fixed, and we can query the permutation by providing a range [l, r] and a divisor k.

codeforcescompetitive-programmingbinary-searchinteractive
CF 1764H - Doremy's Paint 2

We have an array of n buckets, where each bucket initially contains a unique color equal to its 1-based index. There are m paint operations, each defined by a segment [li, ri].

codeforcescompetitive-programmingdata-structures
CF 1764G2 - Doremy's Perfect DS Class (Medium Version)

We are given a hidden permutation of numbers from 1 to n. We cannot see it directly, but we can interactively ask queries.

codeforcescompetitive-programmingbinary-searchinteractive
CF 1764F - Doremy's Experimental Tree

We are given a mysterious tree with n vertices where each edge has a positive integer weight. For every pair (i, j) with 1 ≤ j ≤ i ≤ n, a “virtual experiment” was done: an edge of weight 1 was temporarily added between vertices i and j.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdfs-and-similardsusortingstrees
CF 1764D - Doremy's Pegging Game

We are asked to count the number of sequences in which red pegs on a regular polygon can be removed while maintaining a geometric constraint: the rubber band around the remaining red pegs must not enclose the central blue peg.

codeforcescompetitive-programmingcombinatoricsdpmath
CF 1764B - Doremy's Perfect Math Class

We start with a finite set of positive integers. We are allowed to repeatedly pick two numbers, subtract the smaller from the larger, and insert the result if it is not already present. The process continues until no new numbers can be created.

codeforcescompetitive-programmingmathnumber-theory
CF 1764E - Doremy's Number Line

I can write a high-quality editorial only if I can first reconstruct the intended solution and proof. For Codeforces 1764E (rating 2400), the key difficulty is that the solution relies on a fairly intricate DP/greedy argument.

codeforcescompetitive-programmingdpgreedysortings
CF 1764C - Doremy's City Construction

We are asked to build a simple undirected graph with vertices labeled by altitudes. Each vertex has a number representing its altitude, and we may connect pairs of vertices by edges under two constraints. The first is standard: no self-loops or multiple edges.

codeforcescompetitive-programminggraphsgreedy
CF 1764A - Doremy's Paint

We are given an array and asked to choose a contiguous segment. For any chosen segment, we compute two quantities: its length and how many distinct values appear inside it. The score of a segment is the length minus the number of distinct values.

codeforcescompetitive-programminggreedy
CF 1765N - Number Reduction

Codeforces 1765N: Number Reduction

codeforcescompetitive-programminggreedy
CF 1765H - Hospital Queue

Got it. Let’s carefully trace what is happening. The previous solution attempt fails because it misinterprets the keyboard behavior. Mishka’s keyboard alternates between single-letter and double-letter presses globally, not per character. That is the key subtlety.

codeforcescompetitive-programmingbinary-searchgraphsgreedyimplementation
CF 1765M - Minimum LCM

We are asked to split a given integer n into two positive parts a and b so that their sum stays fixed at n. Among all such splits, we want the pair that makes the least common multiple of a and b as small as possible.

codeforcescompetitive-programmingmathnumber-theory
CF 1765L - Project Manager

Codeforces 1765L: Project Manager

codeforcescompetitive-programmingbrute-forcedata-structuresimplementation
CF 1765K - Torus Path

We are given a square grid of size $n times n$ where each cell has a non-negative integer. A chip starts at the top-left corner, and we want to move it to the bottom-right corner.

codeforcescompetitive-programminggreedymath
CF 1765I - Infinite Chess

Codeforces 1765I: Infinite Chess

codeforcescompetitive-programmingimplementationshortest-paths
CF 1765J - Hero to Zero

We are given two arrays, a and b, both of length n. From these, we can build a matrix c where each entry c[i][j] is the absolute difference The allowed operations are of two types: we can increment or decrement entire rows or columns, which affects multiple elements…

codeforcescompetitive-programminggraph-matchingsmath