brain

tamnd's digital brain — notes, problems, research

43815 notes

CF 1842B - Tenzing and Books

We have three stacks of books. Each stack contains n books arranged from top to bottom. Every book has a non-negative integer written on it. Tenzing starts with knowledge equal to 0.

codeforcescompetitive-programmingbitmasksgreedymath
CF 1842A - Tenzing and Tsondu

The proposed “solution” does not address the mathematical exercise at all. Instead, it discusses a Python runtime error and competitive programming implementation details unrelated to Exercise 3.3.1.

codeforcescompetitive-programminggamesmath
Kvant Math Problem 2632

Working

kvantmathematicsolympiad
CF 1843F2 - Omsk Metro (hard version)

The problem models a growing tree structure representing the Omsk metro system. Each node in the tree is a station, starting with station 1 with weight +1. New stations are added one by one, each connected to an existing station, and each having a weight of either +1 or -1.

codeforcescompetitive-programmingdata-structuresdfs-and-similardivide-and-conquerdpmathtrees
CF 1843B - Long Long

The problem here is entirely structural, not algorithmic. Your test harness calls solve(), but in the code you ran, solve was never defined in the same script.

codeforcescompetitive-programminggreedymathtwo-pointers
CF 1843F1 - Omsk Metro (simple version)

We are given a growing tree, representing the Omsk metro, where each station has a weight of either 1 or -1. The tree initially has a single station numbered 1 with weight 1.

codeforcescompetitive-programmingdata-structuresdfs-and-similardpgraphsgreedymathtrees
CF 1843D - Apple Tree

We are given a rooted tree with n vertices, rooted at vertex 1. Each vertex may have zero or more children. Two apples are placed on arbitrary vertices x and y. When the tree is shaken, each apple moves down to a child at every step until it reaches a leaf, where it falls.

codeforcescompetitive-programmingcombinatoricsdfs-and-similardpmathtrees
CF 1843E - Tracking Segments

We start with an array of length n filled entirely with zeros. There are m segments. A segment is considered beautiful when the number of ones inside it is strictly greater than the number of zeros inside the same segment.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structurestwo-pointers
CF 1843A - Sasha and Array Coloring

We are given an array of integers. Every element must be assigned to exactly one color, and we may use any number of colors. For each color, we look at all values assigned to that color.

codeforcescompetitive-programminggreedysortingstwo-pointers
CF 1843C - Sum in Binary Tree

The problem describes an infinite complete binary tree where nodes are numbered sequentially layer by layer. The root has number 1, its left child is 2, right child is 3, and the pattern continues such that each node gets two children with the next available numbers.

codeforcescompetitive-programmingbitmaskscombinatoricsmathtrees
CF 1844H - Multiple of Three Cycles

We are asked to process a sequence of updates on an initially empty array of length $n$. Each update sets a single position in the array to a number, and after all updates, the array becomes a permutation of $1$ through $n$.

codeforcescompetitive-programmingcombinatoricsdata-structuresdpdsumath
CF 1844G - Tree Weights

We are given a tree with n nodes and n-1 edges, where the edges are unlabeled with weights. Instead, we are provided with the sum of weights along the paths between consecutive nodes from 1 to n.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsdata-structuresdfs-and-similarimplementationmathmatricesnumber-theorytrees
Kvant Math Problem 2576

The problem concerns tilings of an $8\times8$ board with dominoes of size $1\times2$ (horizontal) or $2\times1$ (vertical).

kvantmathematicsolympiad
CF 1844C - Particles

We are given a sequence of particles arranged in a line, each with an integer charge. We have a device that allows us to remove any particle, after which the two neighboring particles merge into one particle whose charge is the sum of the two neighbors.

codeforcescompetitive-programmingdpgreedyimplementationmath
CF 1844F2 - Min Cost Permutation (Hard Version)

We are given an array of positive integers and an integer $c$, which can be negative. The task is to reorder the array into a permutation that minimizes the sum of absolute differences $ In practical terms, we are aligning the differences between consecutive elements to match…

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsdata-structuresgreedymathsortings
CF 1844F1 - Min Cost Permutation (Easy Version)

We are given an array of positive integers and a number $c$ that can be negative, zero, or positive. The task is to reorder the array into a permutation that minimizes the sum of absolute differences between consecutive elements, adjusted by $c$.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedymath
CF 1844E - Great Grids

We are working with an $n times m$ grid where every cell must be assigned one of three symbols: $A$, $B$, or $C$. The grid is not arbitrary, because two structural rules constrain it heavily.

codeforcescompetitive-programming2-satconstructive-algorithmsdfs-and-similardsugraphs
CF 1844D - Row Major

We need to construct a string of length n using as few distinct lowercase letters as possible. The catch is that the string must remain valid for every possible grid shape whose row-major traversal produces that string.

codeforcescompetitive-programmingconstructive-algorithmsgreedymathnumber-theorystrings
CF 1844A - Subtraction Game

We are given two move sizes, $a$ and $b$, with $a < b$. Two players play a subtraction game starting from a pile of $n$ stones. On each turn, a player must remove exactly $a$ or exactly $b$ stones. A player who cannot make a valid move loses immediately.

codeforcescompetitive-programmingconstructive-algorithmsgames
CF 1844B - Permutations & Primes

We are asked to construct a permutation of the integers from 1 to $n$ such that a particular metric, which we call "primality," is maximized. Primality is defined as the number of contiguous subarrays whose minimum excluded number (MEX) is a prime.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1845A - Forbidden Integer

We are asked to determine whether a target sum n can be formed using any number of integers from 1 to k, excluding a single forbidden integer x. If it is possible, we must construct one valid sequence of integers whose sum is exactly n.

codeforcescompetitive-programmingconstructive-algorithmsimplementationmathnumber-theory
CF 1845F - Swimmers in the Pool

We have a pool of length $l$ and $n$ swimmers. Each swimmer starts at the same time from one end and moves to the other at a constant speed $vi$. Upon reaching the far end, they immediately turn around and continue swimming back and forth indefinitely.

codeforcescompetitive-programmingdpfftmathnumber-theory
CF 1845E - Boxes and Balls

We are given a row of n boxes, some containing a ball and some empty. The allowed operation is to move a ball from a box into an adjacent empty box, with adjacency defined as consecutive indices.

codeforcescompetitive-programmingdpimplementationmath
CF 1845D - Rating System

We are simulating a rating that starts at zero and is updated after each match by adding an integer delta from an array. Positive values increase the rating, negative values decrease it. There is an extra constraint controlled by a parameter $k$.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresdpdsugreedymathtwo-pointers
CF 1845B - Come Together

We are working on a grid where two people, Bob and Carol, start from the same cell and must travel to their own destinations using shortest paths in Manhattan distance.

codeforcescompetitive-programminggeometryimplementationmath
CF 1845C - Strong Password

We are asked to determine whether Monocarp can construct a password of exactly length m that satisfies three conditions: each digit must lie between the corresponding digits of two strings l and r, the password must only use digits 0 through 9, and it must not appear as a…

codeforcescompetitive-programmingbinary-searchdpgreedystrings
CF 1846B - Rudolph and Tic-Tac-Toe

We are given a final state of a very small board, always 3 by 3, for a simplified tic-tac-toe variant with three different symbols. One player places X, another places O, and the third places plus signs. Some cells may still be empty.

codeforcescompetitive-programmingbrute-forceimplementationstrings
CF 1846G - Rudolf and CodeVid-23

We are given a set of symptoms that Rudolf currently has, along with a list of medicines. Each medicine takes a certain number of days to take, removes some symptoms, and may induce new symptoms as side effects.

codeforcescompetitive-programmingbitmasksdpgraphsgreedyshortest-paths
CF 1846F - Rudolph and Mimic

We are given a collection of positions, each holding an object with a visible type label. Hidden among them is a single special entity, the mimic.

codeforcescompetitive-programmingconstructive-algorithmsimplementationinteractive
CF 1846E2 - Rudolf and Snowflakes (hard version)

We are given a construction process that builds a special kind of tree-like graph. It starts from a single root vertex. From there, every time a vertex becomes a leaf, it “expands” by attaching exactly k new vertices to it, where k 1.

codeforcescompetitive-programmingbinary-searchbrute-forceimplementationmath
CF 1846E1 - Rudolf and Snowflakes (simple version)

We are asked to determine whether it is possible to construct a "snowflake" graph with exactly $n$ vertices, following a recursive branching rule. The graph starts with a single vertex. From this vertex, we attach $k 1$ new vertices.

codeforcescompetitive-programmingbrute-forceimplementationmath
CF 1846D - Rudolph and Christmas Tree

We are given a stylized drawing made of several identical triangular “branches” placed along a vertical line. Each branch is an isosceles triangle with a fixed base length d and height h.

codeforcescompetitive-programmingconstructive-algorithmsgeometrymath
CF 1846A - Rudolph and Cut the Rope

We are given a set of nails on a wall, each at a different height, and each nail has a rope of a certain length tied to it. The other ends of all the ropes are connected to a candy, forming a single point that is suspended somewhere in the air.

codeforcescompetitive-programmingimplementationmath
CF 1846C - Rudolf and the Another Competition

Each participant in the contest is given the same list of problems, but each person needs a different amount of time to solve each problem. The competition lasts for a fixed number of minutes, and every participant chooses an order in which to solve problems.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresdpgreedysortings
CF 1847C - Vampiric Powers, anyone?

We are given an array of small integers, and we are allowed to repeatedly extend it. Each extension picks a suffix starting at some position and appends its XOR to the end of the array.

codeforcescompetitive-programmingbitmasksbrute-forcedpgreedy
CF 1847F - The Boss's Identity

We are given a sequence that starts with a finite prefix of length $n$. After that point, the sequence does not stop; instead, every new element is formed by combining the previous $n$ elements using bitwise OR between two adjacent shifted values.

codeforcescompetitive-programmingbinary-searchbitmasksdata-structuresdfs-and-similargreedymathsortings
CF 1847E - Triangle Platinum?

We are given an array of $n$ hidden integers, each between $1$ and $4$. We cannot see these numbers directly, but we can ask queries about triples of indices. Each query returns a number related to the area of a triangle formed by the three values at those indices.

codeforcescompetitive-programmingbrute-forcecombinatoricsimplementationinteractivemathprobabilities
CF 1847D - Professor Higashikata

We are given a binary string s and a fixed collection of intervals over it. Each interval extracts a substring, and all extracted substrings are concatenated in order to form a new string t(s).

codeforcescompetitive-programmingdata-structuresdsugreedyimplementationstrings
CF 1847B - Hamon Odyssey

We are given several independent test cases. In each test case, we start with an array of integers, and we are allowed to split this array into contiguous segments. Every element must belong to exactly one segment.

codeforcescompetitive-programmingbitmasksgreedytwo-pointers
CF 1847A - The Man who became a God

The problem asks us to split a sequence of villagers, each with a numerical suspicion level, into exactly k contiguous groups in a way that minimizes the total "power" of these groups.

codeforcescompetitive-programminggreedysortings
CF 1848B - Vika and the Bridge

We are given a linear bridge represented as an array of plank colors. Vika starts before the first plank and wants to reach the end.

codeforcescompetitive-programmingbinary-searchdata-structuresgreedyimplementationmathsortings
CF 1848F - Vika and Wiki

We are given an array of size $n$ where $n$ is guaranteed to be a power of two. The array contains non-negative integers.

codeforcescompetitive-programmingbinary-searchbitmaskscombinatoricsdivide-and-conquerdpmath
CF 1848D - Vika and Bonuses

We are asked to maximize the total discount Vika can obtain from her bonus system in a cosmetics store. She currently has s bonuses and will make k more purchases.

codeforcescompetitive-programmingbinary-searchbrute-forcemathternary-search
CF 1848E - Vika and Stone Skipping

We are asked to count the number of distinct positive integer forces that make a stone land exactly at a given point on the water.

codeforcescompetitive-programmingbrute-forceimplementationmathnumber-theory
CF 1848C - Vika and Price Tags

We are given two arrays representing the old and new prices of a set of items. Vika repeatedly computes the absolute differences between corresponding elements of these arrays, swaps the arrays, and repeats the process.

codeforcescompetitive-programmingmathnumber-theory
CF 1848A - Vika and Her Friends

We are asked to model a pursuit scenario on a rectangular grid representing a mall. Vika starts in a specific room, and her friends start in other rooms.

codeforcescompetitive-programminggamesmath
CF 1849D - Array Painting

We are given a line of cells, each containing a value 0, 1, or 2. Every cell starts unpainted, and the goal is to paint all cells. We are allowed to spend coins in two different ways. The first is direct painting: we can pick any unpainted cell, paint it, and pay one coin.

codeforcescompetitive-programmingconstructive-algorithmsgreedytwo-pointers
CF 1849F - XOR Partition

We are given a set of distinct integers and we need to split them into two subsets such that the minimum XOR among all pairs in each subset is as large as possible. The value of a partition is the smaller of the two subset costs. Each element must belong to exactly one subset.

codeforcescompetitive-programmingbinary-searchbitmasksdata-structuresdivide-and-conquergreedytrees
CF 1849E - Max to the Right of Min

We are given a permutation of length $n$, which means we have a sequence containing every integer from $1$ to $n$ exactly once.

codeforcescompetitive-programmingbinary-searchdata-structuresdivide-and-conquerdpdsutwo-pointers
CF 1849B - Monsters

The problem describes a scenario where Monocarp fights a group of monsters, each with an initial health value. Monocarp can repeatedly hit the monster with the highest current health, reducing it by a fixed amount $k$ per attack.

codeforcescompetitive-programminggreedymathsortings
CF 1849C - Binary String Copying

We are asked to analyze the effect of sorting substrings on multiple copies of a binary string. Each test case gives us a string consisting of zeros and ones, and a set of operations, one per copy.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structureshashingstrings
CF 1849A - Morning Sandwich

Monocarp wants to make the tallest sandwich possible given a certain number of bread slices, cheese slices, and ham slices. A valid sandwich must always start and end with a piece of bread, and the layers alternate between bread and filling (either cheese or ham).

codeforcescompetitive-programmingimplementationmath
CF 1850H - The Third Letter

Each soldier must be assigned an integer coordinate on a number line, and multiple soldiers are allowed to share the same coordinate. Every constraint connects two soldiers and specifies an exact signed distance between their positions.

codeforcescompetitive-programmingdfs-and-similardsugraphsgreedyimplementation
CF 1850F - We Were Both Children

The previous solution is not just buggy in implementation, it is fundamentally misaligned with the structure of the problem.

codeforcescompetitive-programmingbrute-forceimplementationmathnumber-theory
CF 1850D - Balanced Round

We are given a list of problem difficulties, and we are allowed to discard any subset of them and then reorder the remaining ones arbitrarily. After reordering, we want the sequence to be “smooth” in the sense that every adjacent pair differs by at most $k$.

codeforcescompetitive-programmingbrute-forcegreedyimplementationsortings
CF 1850G - The Morning Star

We are given a set of distinct points on a 2D integer grid. For every ordered pair of points, we imagine placing a compass at the first point and pointing it toward the second point.

codeforcescompetitive-programmingcombinatoricsdata-structuresgeometryimplementationmathsortings
CF 1850E - Cardboard for Pictures

Each test case describes a collection of square pictures. Every picture with side length $si$ is placed on a larger square cardboard sheet. The cardboard forms a uniform frame of width $w$ around the picture, and also covers the area behind the picture itself.

codeforcescompetitive-programmingbinary-searchgeometryimplementationmath
Kvant Math Problem 2496

Consider a finite set of $n$ cities in the plane, with $n$ odd, such that all pairwise distances between cities are distinct.

kvantmathematicsolympiad
CF 1850C - Word on the Paper

We are given several independent 8 by 8 character grids. Each grid contains dots and lowercase letters, but only one meaningful structure exists inside each grid: a single column contains a vertically written word with no gaps. Every other cell is irrelevant noise.

codeforcescompetitive-programmingimplementationstrings
CF 1850B - Ten Words of Wisdom

The task is to find the winning response in a short-answer game show. Each participant submits a response, which has two attributes: the number of words it contains and its quality score.

codeforcescompetitive-programmingimplementationsortings
CF 1850A - To My Critics

We are asked to work with three digits, call them a, b, and c, each ranging from 0 to 9. The task is to determine if we can pick any two distinct digits among these three so that their sum is at least 10. We repeat this for t independent test cases.

codeforcescompetitive-programmingimplementationsortings
Kvant Math Problem 2445

Let $A_{k+1} = A_1$, and let $q = p^t$ be an arbitrary prime power dividing the odd integer $n$.

kvantmathematicsolympiad
CF 1851A - Escalator Conversations

We are given a fixed escalator structure and a set of people with known heights. Vlad also has a height. The escalator has equally spaced steps, and each step increases in height by a constant value.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsmath
CF 1852E - Rivalries

We are given an array $a$. From this array, we are asked to construct another array $b$ of the same length, consisting of positive integers, but not arbitrary ones.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresgreedy
CF 1852D - Miriany and Matchstick

We are given a grid with two rows and $n$ columns. The entire first row is already fixed as a string consisting of A and B. The second row is completely free to choose, but must also be filled with A and B. Once both rows are filled, we look at adjacency in the grid.

codeforcescompetitive-programmingconstructive-algorithmsdpgreedy
CF 1852F - Panda Meetups

Codeforces 1852F: Panda Meetups

codeforcescompetitive-programmingdata-structuresdpflows
CF 1852B - Imbalanced Arrays

Working

codeforcescompetitive-programmingconstructive-algorithmsgraphsgreedymathsortingstwo-pointers
CF 1852C - Ina of the Mountain

We start with an infinite sorted sequence of positive integers. Each day, we repeatedly delete several positions from the current ordered set.

codeforcescompetitive-programmingdata-structuresdpgreedymath
CF 1852A - Ntarsis' Set

We are given an initially infinite-like set $S$ consisting of integers $1, 2, 3, dots$. Each day, Ntarsis removes specific elements from this set.

codeforcescompetitive-programmingbinary-searchmathnumber-theory
CF 1853F - Miriany and Matchstick

I’m sorry, but I can’t reliably write a complete editorial and verified solution for this problem from memory alone. For a Codeforces 2800-rated constructive/DP problem, producing a full editorial with proof and code without first reconstructing or veri

codeforcescompetitive-programmingconstructive-algorithmsdpgreedy
CF 1853E - Ina of the Mountain

We are given a row of n octopuses, each with a health value between 1 and k. The goal is to bring all octopuses to health k. We can throw boulders that reduce the health of a contiguous range of octopuses by 1.

codeforcescompetitive-programmingdata-structuresgreedymath
CF 1853B - Fibonaccharsis

We are given two integers, n and k. We want to count how many Fibonacci-like sequences of length k end with value n.

codeforcescompetitive-programmingbinary-searchbrute-forcemath
CF 1853A - Desorting

We are given an array of integers, and we are allowed to repeatedly apply an operation that shifts value from the right side of a chosen split point to the left side in a very structured way.

codeforcescompetitive-programmingbrute-forcegreedymath
CF 1854D - Michael and Hotel

We are given a directed graph on $n le 500$ vertices where each vertex has exactly one outgoing edge. From every room $i$, a teleporter sends us deterministically to room $ai$.

codeforcescompetitive-programmingbinary-searchinteractivetrees
CF 1854E - Game Bundles

We are asked to select a collection of games, each with a positive enjoyment value, such that the number of distinct subsets of these games that sum to exactly 60 equals a given integer $m$.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdpgreedymath
CF 1854F - Mark and Spaceship

We are working in a four-dimensional integer grid. From the origin, a spaceship executes a sequence of moves, where each move chooses one of the four coordinate axes and steps by one unit in either direction.

codeforcescompetitive-programmingbrute-forcedp
Kvant Math Problem 2226

Let $A(k,n)$ denote the number of integer $k$-tuples $(x_1,\dots,x_k)$ satisfying the inequality

kvantmathematicsolympiad
CF 1854C - Expected Destruction

We are given a set of distinct integers S drawn from the range 1 to m. Every second, we perform a stochastic operation: we select an element x from S uniformly at random, remove it, and if x+1 is within bounds and absent from S, we add x+1 back into the set.

codeforcescompetitive-programmingcombinatoricsdpmathprobabilities
CF 1854A2 - Dual (Hard Version)

We are given an integer array. In one operation we choose two positions i and j and add the value at position j into position i. The goal is not to sort the array. We only need the final array to be non-decreasing, meaning every element is at least as large as the previous one.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1854A1 - Dual (Easy Version)

We are given an array of integers that may be positive, negative, or zero. We are allowed to perform operations where we pick any two indices $i$ and $j$ and add the value of $aj$ to $ai$.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1854B - Earn or Unlock

We are given a scenario where a player wants to maximize their earnings while unlocking skills in a game. There are n skills, each requiring certain previously unlocked skills and providing a coin reward if unlocked.

codeforcescompetitive-programmingbitmasksbrute-forcedp
Kvant Math Problem 1595

Since $AB=BC$ and $\angle ABC=80^\circ$, the base angles of triangle $ABC$ are both $50^\circ$.

kvantmathematicsolympiad
CF 1855F - Michael and Hotel

We are given a hotel with n rooms, numbered 1 through n, each equipped with a teleporter that deterministically sends anyone in that room to a fixed target room.

codeforcescompetitive-programmingbinary-searchinteractive
CF 1855E - Expected Destruction

We are given a set of distinct integers between 1 and some maximum value m. At each second, we remove a random element x from the set. After removing it, if x+1 is within bounds and not already in the set, we add x+1.

codeforcescompetitive-programmingdpmathprobabilities
CF 1855D - Earn or Unlock

We are given a sequence of cards arranged in a line. Each card has a numeric value and starts either locked or unlocked depending on its position: initially only the first card can be used, while all others become usable only after being unlocked through earlier actions.

codeforcescompetitive-programmingbitmasksbrute-forcedp
CF 1855C2 - Dual (Hard Version)

We are given an array of integers, which can be positive, negative, or zero, and the task is to transform this array into a non-decreasing sequence. The only allowed operation is to pick two indices $i$ and $j$ and add the value at $aj$ to $ai$.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1855C1 - Dual (Easy Version)

We are allowed to repeatedly pick two positions in an array and add the value of one position into another. The source element is not consumed or changed when it is used, so the operation behaves like a reusable “transfer of value” between indices.

codeforcescompetitive-programmingconstructive-algorithms
CF 1855A - Dalton the Teacher

The problem asks us to make every student in a classroom "happy" by ensuring that no student sits on a chair with the same number as their own. We are given an initial permutation of students to chairs.

codeforcescompetitive-programminggreedymath
CF 1855B - Longest Divisors Interval

We are asked to work with a positive integer $n$ and find the longest contiguous range of positive integers $[l, r]$ such that each number in this interval divides $n$. In other words, for every integer $i$ between $l$ and $r$, $n bmod i = 0$.

codeforcescompetitive-programmingbrute-forcecombinatoricsgreedymathnumber-theory
CF 1856E2 - PermuTree (hard version)

I have analyzed the issue carefully. The reason your previous solution produces the wrong results is that it miscalculates the expected value for black nodes.

codeforcescompetitive-programmingbitmasksdfs-and-similardpfftgreedyimplementationmathtrees
CF 1856D - More Wrong

We are asked to find the position of the maximum element in a hidden permutation of length $n$ by using queries that tell us the number of inversions in a subarray.

codeforcescompetitive-programmingdivide-and-conquerinteractive
CF 1856E1 - PermuTree (easy version)

We are given a rooted tree with n vertices, labeled 1 through n, where vertex 1 is the root. Each non-root vertex i has a parent pi, defining the edges of the tree.

codeforcescompetitive-programmingdfs-and-similardptrees
Kvant Math Problem 1593

Let $f_n(m)$ denote the number of ways to represent an integer $m$ as a sum of signed powers of two up to $2^n$, where each coefficient $a_k$ can take values in ${-1,0,1}$.

kvantmathematicsolympiad
CF 1856B - Good Arrays

We are given an array of positive integers. We want to know whether it is possible to construct another array of the same length such that every position changes its value, but the total sum stays exactly the same. The second array is not arbitrary.

codeforcescompetitive-programmingimplementationmath
CF 1856A - Tales of a Sort

We are given an array of positive integers. Alphen can perform a single operation repeatedly, where every element of the array is reduced by one, but no element can go below zero.

codeforcescompetitive-programmingimplementation
CF 1856C - To Become Max

We are given an array of integers and a number of allowed operations. Each operation lets us pick an index $i$ such that the element at $i$ is less than or equal to its right neighbor, and increase $ai$ by one.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresdp
CF 2220E - Coloring a Red Black Tree

We are given a tree with n nodes, where each node is either red or black. The goal is to make all nodes red using a stochastic operation: you select a node and recolor it with the color of one of its neighbors chosen uniformly at random.

codeforcescompetitive-programmingdpgreedyprobabilitiessortingstrees
CF 2220D2 - Unique Values (Hard version)

We are given an array of length $2n+1$. Every number from $1$ to $n$ appears exactly twice, except for one special value that appears three times. This creates a very rigid structure: all values are paired except one value that has an “extra copy”.

codeforcescompetitive-programmingbinary-searchinteractive
CF 2220F - MEX Replacement on Tree

We have a rooted tree. Every vertex carries a unique value from the permutation $0,1,dots,n-1$. For a vertex $v$, look at all vertices on the root-to-$v$ path. Their values form a set $Sv$.

codeforcescompetitive-programming
CF 2220D1 - Unique Values (Easy version)

In the original interactive problem, there is a hidden array of length $2n+1$. Every value from $1$ to $n$ appears exactly twice, except for one special value that appears three times. The task is to identify the three positions containing that special value.

codeforcescompetitive-programmingbinary-searchinteractive