brain

tamnd's digital brain — notes, problems, research

41650 notes

CF 1608G - Alphabetic Tree

We are given a tree with nodes connected by edges, each labeled with a lowercase letter. In addition, we have a collection of strings. For any two nodes in the tree, the path connecting them defines a string by concatenating the letters along that path in traversal order.

codeforcescompetitive-programmingbinary-searchdata-structuresdfs-and-similarhashingstring-suffix-structuresstringstrees
CF 1608F - MEX counting

We are building an array step by step from left to right, and after each position we look at the prefix we have constructed so far. From that prefix we compute its MEX, which is the smallest nonnegative integer that does not appear in the prefix.

codeforcescompetitive-programmingcombinatoricsdpimplementation
Kvant Physics Problem 48

A mass $m$ is attached to a rope wound around the shaft of a dynamo armature.

kvantphysics
CF 1608D - Dominoes

We are given a collection of dominoes, each represented by two cells: left and right. Some cells are already colored black or white, while others are undecided.

codeforcescompetitive-programmingcombinatoricsfftgraphsmathnumber-theory
CF 1608C - Game Master

We are asked to determine, for each player in a tournament, whether they can possibly win if the tournament is conducted optimally. There are two maps, and each player has a strength on both maps.

codeforcescompetitive-programmingdata-structuresdfs-and-similardpgraphsgreedytwo-pointers
CF 1608B - Build the Permutation

We are asked to construct a permutation of the numbers from 1 to n that has exactly a local maxima and b local minima in the interior positions. A local maximum is a number larger than its immediate neighbors, and a local minimum is a number smaller than its immediate neighbors.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1608A - Find Array

We are asked to construct an increasing sequence of integers for each test case, with a specific restriction on consecutive elements. The sequence must be strictly increasing, and additionally every next element must not be divisible by the previous one.

codeforcescompetitive-programmingconstructive-algorithmsmath
Kvant Physics Problem 47

**Solution to patch**

kvantphysics
CF 1609B - William the Vigilant

The mismatch you are seeing (“correct count but invalid orientation”, sometimes even extra vertices counted) is a strong signal that the previous construction is not just buggy, but conceptually wrong.

codeforcescompetitive-programmingimplementationstrings
CF 1609H - Pushing Robots

We are asked to simulate the movement of robots on a number line. Each robot occupies a unit segment and follows a cyclic program of instructions that can push it left, right, or leave it stationary.

codeforcescompetitive-programming
CF 1609G - A Stroll Around the Matrix

We are working with two integer arrays, one of size $n$ and one of size $m$. Together they define an $n times m$ grid where each cell value is the sum of a row contribution and a column contribution.

codeforcescompetitive-programmingdata-structuresgreedymath
CF 1609F - Interesting Sections

We are given a long array of non-negative integers. The task is to count how many contiguous subarrays have a specific property that depends on two extreme values inside the subarray: its minimum and its maximum.

codeforcescompetitive-programmingdata-structuresdivide-and-conquermeet-in-the-middletwo-pointers
CF 1609E - William The Oblivious

We are working with a mutable string consisting only of the characters a, b, and c. After each update, we must answer a structural question about the string: how many positions must be changed so that the string no longer contains abc as a subsequence.

codeforcescompetitive-programmingbitmasksdata-structuresdpmatrices
CF 1609D - Social Network

We are given a group of people who initially have no relationships at all. Over time, we are shown a sequence of pairs, and each pair represents a constraint that must eventually be satisfied: the two people in the pair must end up connected, meaning there exists a chain of…

codeforcescompetitive-programmingdsugraphsgreedyimplementationtrees
CF 1609C - Complex Market Analysis

We are given an array of integers and a step size e. For each starting index i, we can form a subsequence by taking every e-th element: a[i], a[i+e], a[i+2e], ... up to the point where the index does not exceed the array bounds.

codeforcescompetitive-programmingbinary-searchdpimplementationnumber-theoryschedulestwo-pointers
CF 1609A - Divide and Multiply

We are given several independent test cases. Each test case consists of a small array of integers, and we are allowed to repeatedly redistribute factors of two between elements.

codeforcescompetitive-programminggreedyimplementationmathnumber-theory
CF 1610F - Mashtali: a Space Oddysey

We are given an undirected weighted graph where each edge has a weight of either 1 or 2. Our task is to assign a direction to each edge to maximize the number of vertices whose outgoing and incoming edge sums differ by exactly 1.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similargraphs
Kvant Physics Problem 42

A flexible rope passes over an ideal pulley.

kvantphysics
Kvant Physics Problem 44

The physical system consists of two dolphins moving through water along the same straight line toward one another.

kvantphysics
Kvant Physics Problem 43

A planet is modeled as a sphere of radius $R$ filled with an incompressible liquid of constant density $\rho$.

kvantphysics
CF 1610I - Mashtali vs AtCoder

We are given a tree of $n$ vertices. The game is played on the tree by two players who take turns deleting edges. After an edge is removed, any connected component that contains no “pinned” vertex is completely discarded. The first player who cannot make a move loses.

codeforcescompetitive-programminggamestrees
CF 1610H - Squid Game

We are given a tree with n vertices and m players. Each player selects two vertices on the tree, which we will call xi and yi. A player can only be eliminated if Mashtali chooses a vertex v and the closest vertex w to v on the path from xi to yi is strictly between xi and yi.

codeforcescompetitive-programmingdata-structuresdfs-and-similargreedytrees
CF 1610G - AmShZ Wins a Bet

We are given a string of parentheses S that has been modified by repeatedly performing a wrapping operation. Each operation allows you to take any contiguous substring B and surround it with a pair of parentheses, inserting it back into its original place in the string.

codeforcescompetitive-programmingdata-structuresgreedyhashing
CF 1610E - AmShZ and G.O.A.T.

We are given a nondecreasing array and asked to remove as few elements as possible so that the remaining array avoids a very specific kind of “badness” condition.

codeforcescompetitive-programmingbinary-searchbrute-forcegreedyimplementationmath
CF 1610D - Not Quite Lee

We are given an array and we look at every non-empty subsequence of it. Each subsequence is interpreted as a list of lengths, and for every length $bi$ we are allowed to build a contiguous block of exactly $bi$ consecutive integers.

codeforcescompetitive-programmingcombinatoricsdpmathnumber-theory
Kvant Physics Problem 40

A neon-filled discharge tube is placed between two large parallel plate electrodes separated by a distance

kvantphysics
CF 1610B - Kalindrome Array

We are given an array and allowed to perform a very specific type of transformation: we may pick one value x and remove any occurrences of that value from the array, not necessarily all of them.

codeforcescompetitive-programminggreedytwo-pointers
CF 1610C - Keshi Is Throwing a Party

We are given a collection of people where each person has a fixed wealth equal to their index, so person 1 has 1 dollar, person 2 has 2 dollars, and so on up to n. We want to choose a subset of these people to invite to a party. Each person comes with two constraints.

codeforcescompetitive-programmingbinary-searchgreedy
CF 1610A - Anti Light's Cell Guessing

We are given a rectangular grid with $n$ rows and $m$ columns. Somewhere inside this grid, an adversary hides a single cell $(x, y)$. We are allowed to “probe” a fixed set of $k$ cells of our choice. For each chosen cell, we receive its Manhattan distance to the hidden cell.

codeforcescompetitive-programmingmath
Kvant Physics Problem 39

Consider a planet of radius $R$ and mass $M$ surrounded by an atmosphere of uniform density $\rho$.

kvantphysics
CF 1611G - Robot and Candies

We are given a rectangular grid of size $n times m$, where each cell either contains a candy ('1') or is empty ('0'). A robot can start on any cell in the top row and move diagonally down-left or down-right until it leaves the grid.

codeforcescompetitive-programmingdata-structuresgraph-matchingsgreedy
CF 1611F - ATM and Students

The problem involves simulating an ATM that starts with a fixed amount of money and must serve a queue of students. Each student either deposits a positive amount or withdraws a negative amount from the ATM.

codeforcescompetitive-programmingbinary-searchdata-structurestwo-pointers
CF 1611E1 - Escape The Maze (easy version)

The maze is an undirected tree rooted at room 1. Vlad starts at room 1 and wants to reach any leaf node that is not room 1. A leaf is any node with exactly one adjacent corridor. At the same time, several friends are already placed on distinct nodes.

codeforcescompetitive-programmingdfs-and-similargreedyshortest-pathstreestwo-pointers
CF 1611D - Weights Assignment For Tree Edges

We are given a tree where each vertex has a pointer to its parent, except for the root which points to itself. This parent array b encodes the tree unambiguously.

codeforcescompetitive-programmingconstructive-algorithmstrees
Kvant Physics Problem 37

Two vertical cylinders of cross-sectional areas $S_1$ and $S_2$ are open to the atmosphere at their upper ends.

kvantphysics
CF 1611E2 - Escape The Maze (hard version)

We are given a tree of rooms. Vlad starts from room 1 and tries to escape by reaching any leaf node that is not room 1. A leaf is a room with exactly one corridor. At the same time, several friends are placed on distinct nodes.

codeforcescompetitive-programmingdfs-and-similardpgreedyshortest-pathstrees
CF 1611C - Polycarp Recovers the Permutation

We are given a sequence a of length n that was generated by repeatedly removing the smallest element from either end of a hidden permutation p of the numbers from 1 to n. If the smallest element is at the left, it is prepended to a; if it is at the right, it is appended to a.

codeforcescompetitive-programmingconstructive-algorithms
CF 1611A - Make Even

We are given a number written in decimal form with no zero digits. The only operation allowed is to take a prefix of the number and reverse the order of digits inside that prefix. The prefix length can be anything from 1 up to the full length of the number.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1611B - Team Composition: Programmers and Mathematicians

We are given two groups of students: programmers and mathematicians. From these students, we want to form as many teams as possible, where every team contains exactly 4 students.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsmath
CF 1612F - Armor and Weapons

In this problem, Monocarp starts with the weakest armor and weapon, labeled 1. He can spend one hour to acquire a new armor set or weapon, but there is a catch: to obtain the $k$-th armor or weapon, he must already possess some armor and weapon combination whose total power is…

codeforcescompetitive-programmingbrute-forcedpgreedyshortest-paths
CF 1612G - Max Sum Array

We are given a multiset of labels, where label i appears exactly ci times. We must arrange all these occurrences into a single array. Once the array is fixed, we look at every pair of identical values and add the distance between their positions.

codeforcescompetitive-programmingcombinatoricsconstructive-algorithmsgreedysortings
CF 1612E - Messages

We have a group of students, each of whom Monocarp wants to read a specific message in a chat. Every student has a limit on how many messages they will read in a day.

codeforcescompetitive-programmingbrute-forcedpgreedyprobabilitiessortings
CF 1612D - X-Magic Pair

We are given a pair of integers $a$ and $b$, and another integer $x$. We are allowed to repeatedly replace either $a$ or $b$ with the absolute difference $ The constraints allow $a, b, x$ to go up to $10^{18}$, and there can be up to $10^4$ test cases.

codeforcescompetitive-programmingmathnumber-theory
CF 1612A - Distance

We are working on a grid where movement is measured using Manhattan distance, meaning the cost between two points is the sum of horizontal and vertical separations. One point is fixed at the origin, while the second point lies at coordinates $(x, y)$.

codeforcescompetitive-programmingbrute-forceconstructive-algorithms
CF 1612B - Special Permutation

We are asked to construct a permutation of numbers from 1 to n, where n is even. The permutation is split into two equal halves: the first n/2 elements form the left half, and the remaining n/2 elements form the right half. Two conditions must be satisfied simultaneously.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1612C - Chat Ban

We are asked to simulate a chat scenario where a user wants to send an "emote triangle" consisting of messages with increasing then decreasing numbers of emotes.

codeforcescompetitive-programmingbinary-searchmath
CF 1613F - Tree Coloring

We are given a rooted tree where vertex 1 is fixed as the root. The task is to assign a distinct label from 1 to n to every vertex, so the labels form a permutation of 1 to n.

codeforcescompetitive-programmingcombinatoricsdivide-and-conquerfft
CF 1613D - MEX Sequences

We are asked to count subsequences of an array where every prefix of the subsequence behaves in a very specific “MEX-stable” way.

codeforcescompetitive-programmingdpmath
CF 1613E - Crazy Robot

We are given a rectangular grid of size n × m containing three types of cells: free cells, blocked cells, and a single lab. The robot can occupy any free cell, and at each step we can issue one of four commands: move up, down, left, or right.

codeforcescompetitive-programmingdfs-and-similargraphs
CF 1613B - Absent Remainder

We are given a sequence of distinct positive integers. Our task is to construct roughly half as many pairs of numbers as the length of the sequence, where for each pair $(x, y)$, both numbers come from the sequence, they are distinct, and the remainder when $x$ is divided by…

codeforcescompetitive-programminggreedyimplementationsortings
CF 1613A - Long Comparison

Each number in this problem is not given in its expanded form, but as a compact description. Instead of writing the full integer, we are given a base value x and a number of trailing zeros p, meaning the actual number is x × 10^p.

codeforcescompetitive-programmingimplementationmath
CF 1613C - Poisoned Dagger

We are given a sequence of attack times and a dragon with h hit points. Each attack applies a poison that lasts k seconds and deals 1 damage per second. If the dragon is already poisoned when a new attack lands, the poison timer resets.

codeforcescompetitive-programmingbinary-search
CF 1614B - Divan and a New Project

- a = [3,1,4,9,2,5,6] - The edges form a path: 1→2→3→4→5→6→7 - res = a[:] = [3,1,4,9,2,5,6] - Process topologically: 1. Node 1 → Node 2: res[1] = min(1,3) = 1 OK 2.

codeforcescompetitive-programmingconstructive-algorithmssortings
Kvant Physics Problem 35

The physical system consists of a satellite in low Earth orbit photographing the surface of the Earth.

kvantphysics
CF 1614E - Divan and a Cottage

We are asked to simulate the evolution of the temperature inside Divan's cottage over a sequence of days, where the temperature adjusts by one unit per day towards the outside temperature.

codeforcescompetitive-programmingbinary-searchdata-structures
Kvant Physics Problem 34

A hollow insulated conducting sphere of radius $R$ is charged by water drops falling from a vertical tube.

kvantphysics
CF 1614D2 - Divan and Kostomuksha (hard version)

We are given a multiset of positive integers and allowed to permute them in any order. After choosing an order, we repeatedly take prefixes of this order and compute the gcd of each prefix, then sum all those gcd values.

codeforcescompetitive-programmingdpnumber-theory
CF 1614D1 - Divan and Kostomuksha (easy version)

We are given a list of positive integers, and we are allowed to reorder them arbitrarily. After fixing an order, we look at all prefixes of this order.

codeforcescompetitive-programmingdpnumber-theory
CF 1614C - Divan and bitwise operations

We are asked to reconstruct the sum of XORs over all non-empty subsequences of an array, knowing only the bitwise OR of several contiguous segments of that array. Each array element appears in at least one segment, so every element contributes to the OR values we are given.

codeforcescompetitive-programmingbitmaskscombinatoricsconstructive-algorithmsdpmath
CF 1614A - Divan and a Store

Divan wants to buy chocolate bars under three constraints: he only considers bars within a price range [l, r], and he cannot exceed his total budget k.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedy
CF 1615H - Reindeer Games

Your input: Structure: - t = 4 - Each test case: - one integer n - one line with n integers So format is consistent: Expected: Now observe carefully: [1, 7] → 1 [1, 5, 4] → -1 [12345678, 87654321, 20211218, 23571113] → 4 [1,2,3,4,18,19,5,6,7] → 2 So the output is: not…

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsdata-structuresdivide-and-conquerflowsgraphsshortest-paths
Kvant Physics Problem 31

Consider a sphere of radius $R$ illuminated by a parallel beam of sunlight.

kvantphysics
CF 1615G - Maximum Adjacent Pairs

We are given an array with some fixed integers and some positions marked as zero. Each zero must be replaced by any integer from 1 to n, and different zero positions can be filled independently, even with the same value.

codeforcescompetitive-programmingconstructive-algorithmsgraph-matchings
CF 1615D - X(or)-mas Tree

We are given a tree with n nodes and n-1 edges, where each edge can store a non-negative integer representing lights, or -1 if the value is unknown.

codeforcescompetitive-programmingbitmasksdfs-and-similardsugraphstrees
CF 1615F - LEGOndary Grandmaster

We are given a one-dimensional Lego strip of length n, where some positions may or may not contain a Lego block. Our memory of the starting and ending configurations is partial: for each position we either know it has a block (1), we know it is empty (0), or we don't remember (?

codeforcescompetitive-programmingcombinatoricsdpmath
CF 1615E - Purple Crayon

We are given a rooted tree with $n$ nodes, rooted at node 1, where all nodes start white. Two players, Red and Blue, take turns coloring nodes. Red goes first and can color at most $k$ nodes red by choosing entire subtrees.

codeforcescompetitive-programmingdata-structuresdfs-and-similargamesgraphsgreedymathsortingstrees
CF 1615C - Menorah

We have a row of candles on a Hanukkah menorah, and each candle is either lit or unlit. The current state is given as a binary string a, where 1 indicates a lit candle and 0 indicates unlit. We are asked to reach a target configuration b using a special operation.

codeforcescompetitive-programmingbrute-forcegraphsgreedymath
Kvant Physics Problem 32

Let the side length of the square cross section be $a$.

kvantphysics
CF 1615B - And It's Non-Zero

We are given many test cases, and each test case describes a contiguous array of integers from $l$ to $r$. The array is not arbitrary, it is always a full interval with no gaps.

codeforcescompetitive-programmingbitmasksgreedymath
CF 1615A - Closing The Gap

We have a row of towers, each with a certain number of blocks stacked vertically. The goal is to make the heights of all towers as close as possible. On any day, we can take a block from one tower and place it on another tower.

codeforcescompetitive-programminggreedymath
CF 1616G - Just Add an Edge

The problem presents a directed acyclic graph (DAG) where every edge points from a smaller-numbered vertex to a larger-numbered one.

codeforcescompetitive-programmingdfs-and-similardpgraphs
CF 1616H - Keep XOR Low

We are asked to count all non-empty subsets of an array where the XOR of every pair of elements does not exceed a given number x. Concretely, if we take any subset of indices from the array, and compute the XOR for every pair of values in that subset, each XOR must be ≤ x.

codeforcescompetitive-programmingbitmaskscombinatoricsdata-structuresdivide-and-conquerdpmath
CF 1616D - Keep the Average High

We are given an array of integers and a target value x. The task is to select as many elements as possible from this array, with a constraint on consecutive selected elements: any contiguous subarray of length at least two that is entirely selected must have an average at…

codeforcescompetitive-programmingdpgreedymath
CF 1616F - Tricolor Triangles

We are given a small undirected graph where every edge is supposed to end up painted with one of three colors. Some edges are already fixed with a color, while others start uncolored and must be assigned a value in {1, 2, 3}.

codeforcescompetitive-programmingbrute-forcegraphsmathmatrices
CF 1616E - Lexicographically Small Enough

We are given two strings of equal length, and we are allowed to modify the first string only by swapping adjacent characters. Each swap costs one operation.

codeforcescompetitive-programmingbrute-forcedata-structuresgreedystrings
CF 1616A - Integer Diversity

We are given a list of integers and we are allowed to negate any subset of them. The goal is to maximize the number of distinct integers in the array after possibly negating some elements.

codeforcescompetitive-programmingimplementation
CF 1616B - Mirror in the String

A valid output is constructed by choosing a split point k in a string. After choosing k, the visible string becomes the prefix s[1..k] followed by its reverse. So every candidate answer is a palindrome that is “built from a prefix”.

codeforcescompetitive-programminggreedystrings
CF 1616C - Representative Edges

We are given an array of integers, and we are allowed to freely replace elements with any real numbers. The goal is to transform the array so that a very strong structural property holds: every subarray must satisfy a linear averaging condition that ties its sum only to its…

codeforcescompetitive-programmingbrute-forcegeometryimplementationmath
CF 1617C - Paprika and Permutation

Your “actual output” is: That means the program likely: - crashed early, or - never entered the solve loop, or - mis-parsed the first token and exited silently Now look at the input: Your code almost certainly does: So it reads: Correct.

codeforcescompetitive-programmingbinary-searchgreedymathsortings
CF 1617E - Christmas Chocolates

We are given a box of chocolates, each with a distinct type represented by a non-negative integer. Icy wants to make at least one pair of chocolates have the same type, but before any exchanges, she chooses two chocolates, say at indices $x$ and $y$.

codeforcescompetitive-programmingdfs-and-similardpgamesgraphsimplementationmathnumber-theoryshortest-pathstrees
CF 1617D2 - Too Many Impostors (hard version)

We are given a group of n players, each labeled from 1 to n, where n is always a multiple of 3. Some of these players are impostors, and the rest are crewmates. We do not know the number of impostors k in advance, but we are guaranteed that it is strictly between n/3 and 2n/3.

codeforcescompetitive-programmingconstructive-algorithmsimplementationinteractivemath
CF 1617D1 - Too Many Impostors (easy version)

We are given a set of players, each of whom is either an impostor or a crewmate. The total number of players, $n$, is divisible by three.

codeforcescompetitive-programmingconstructive-algorithmsimplementationinteractive
Kvant Physics Problem 33

Two beads of masses $m_1$ and $m_2$ move without friction on a smooth horizontal circular wire ring of circumference $L$.

kvantphysics
CF 1617B - GCD Problem

We are asked to construct three distinct positive integers $a$, $b$, and $c$ such that their sum equals a given integer $n$ and the greatest common divisor of the first two numbers equals the third: $gcd(a, b) = c$.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsmathnumber-theory
CF 1617A - Forbidden Subsequence

We are given a string S of arbitrary lowercase letters and a string T that is always a permutation of "abc". The task is to rearrange the letters of S into a new string S' that is the lexicographically smallest possible while ensuring that T does not appear as a subsequence.

codeforcescompetitive-programmingconstructive-algorithmsgreedysortingsstrings
CF 1618A - Polycarp and Sums of Subsequences

Thanks. Now we have more clarity. The previous solution was using brute-force divisor counting, which explains why: - Small numbers like 10 → 4 and 1 → 1 worked. - 25 → 3 (wrong) because brute-force counted divisors incorrectly.

codeforcescompetitive-programmingmathsortings
Kvant Physics Problem 30

A car moves along a straight road with its wheels rolling without slipping.

kvantphysics
CF 1618F - Reverse

We are allowed to repeatedly transform a positive integer by operating directly on its binary representation. In one move, we take the current binary string of the number, append either a 0 or a 1 at the end, reverse the entire resulting string, strip leading zeros, and…

codeforcescompetitive-programmingbitmasksconstructive-algorithmsdfs-and-similarimplementationmathstrings
CF 1618G - Trader Problem

In this problem, Monocarp has a set of items, each with an integer price, and he can trade these items with another character’s items.

codeforcescompetitive-programmingdata-structuresdsugreedysortings
CF 1618E - Singers' Tour

We have a circular arrangement of $n$ towns, each with a singer who has an initial repertoire of $ai$ minutes. Every singer tours all towns in clockwise order, performing in each town.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1618D - Array and Operations

We are given a multiset of integers. We repeatedly remove two elements exactly $k$ times, and each removal produces a value that is added to a running score. After these $k$ operations, whatever elements remain are also added directly to the score.

codeforcescompetitive-programmingdpgreedymath
Kvant Physics Problem 29

The solution correctly addresses the exercise.

kvantphysics
CF 1618C - Paint the Array

We are given an array of positive integers. The task is to pick a positive integer $d$ and color the elements of the array in two colors: red for elements divisible by $d$, and blue for elements not divisible by $d$.

codeforcescompetitive-programmingmath
CF 1618B - Missing Bigram

We are given a sequence of overlapping two-letter strings, or bigrams, derived from a word consisting of only 'a' and 'b'.

codeforcescompetitive-programmingimplementation
CF 1619B - Squares and Cubes

Now we can clearly separate the real issue from all the noise in earlier attempts. Your “solution” is not consistently failing on a single algorithmic idea.

codeforcescompetitive-programmingimplementationmath
CF 1619G - Unusual Minesweeper

Each test case gives a set of mines placed on a 2D grid. Every mine has a position and a “natural lifetime”, meaning it will explode automatically after a given number of seconds if nothing triggers it earlier. The key twist is that explosions propagate.

codeforcescompetitive-programmingbinary-searchdfs-and-similardsugreedysortings
CF 1619H - Permutation and Queries

We are given a permutation of integers from 1 to $n$. Conceptually, this is an array of length $n$ in which every integer from 1 to $n$ appears exactly once, so every index maps to a unique value. On top of this array, we have two types of queries.

codeforcescompetitive-programmingbrute-forcedata-structuresdivide-and-conquertwo-pointers
CF 1619F - Let's Play the Hat?

We are asked to organize a fair schedule for a multi-table game. There are $n$ players, $m$ tables, and $k$ rounds. Each round, every table must host either $lfloor n/m rfloor$ or $lceil n/m rceil$ players.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedymath
CF 1619E - MEX and Increments

We are given an array of non-negative integers and we can increment any element by 1 any number of times. The task is to determine for each integer from 0 up to the array length whether it is possible to transform the array so that its MEX (minimum excluded value) equals that…

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresdpgreedyimplementationmathsortings
CF 1619D - New Year's Problem

We are given several independent scenarios. In each scenario, Vlad has a fixed number of friends and a fixed number of shops. Each shop offers a value for every friend, representing how much joy that friend would get if their gift is bought there.

codeforcescompetitive-programmingbinary-searchgreedysortings