brain

tamnd's digital brain — notes, problems, research

43815 notes

CF 2117B - Shrink

The task is to construct a permutation of length $n$ that allows the maximum number of "shrink" operations. A shrink operation removes an element that is larger than its immediate neighbors.

codeforcescompetitive-programmingconstructive-algorithms
Kvant Math Problem 1559

Let the given plane be $\Pi$.

kvantmathematicsolympiad
CF 2115F2 - Gellyfish and Lycoris Radiata (Hard Version)

We are asked to maintain an array of sets, starting empty, under three types of modification operations: inserting the current operation index into a prefix of sets, reversing a prefix of sets, and deleting a given element from all sets.

codeforcescompetitive-programmingdata-structures
CF 2115D - Gellyfish and Forget-Me-Not

For two odd-index cells $A(x1,y1)$, $B(x2,y2)$, we need to count the number of cells $C$ such that: - $C$ is adjacent to $A$ - $C$ is adjacent to $B$ - and $A ne B ne C$ On a grid, this intersection has a known structure: - If $A$ and $B$ differ by 2 in one coordinate and 0 in…

codeforcescompetitive-programmingbitmasksdpgamesgreedymath
CF 2115B - Gellyfish and Camellia Japonica

We are given a final array b that results from a sequence of q operations on an initial array a. Each operation selects two positions x and y, takes the minimum of their current values, and assigns it to a third position z.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdfs-and-similardpgraphsgreedytrees
CF 2115C - Gellyfish and Eternal Violet

We are given a group of monsters, each starting with some integer health value. Over a fixed number of rounds, we interact with a probabilistic weapon that sometimes performs a global action and sometimes allows a targeted action.

codeforcescompetitive-programmingcombinatoricsdpgreedymathprobabilities
CF 2098A - Vadim's Collection

We are given a string of exactly ten digits representing a phone number that satisfies a "beauty" condition: the first digit is at least 9, the second at least 8, and so on down to the last digit, which is at least 0.

codeforcescompetitive-programmingbrute-forcegreedy
CF 2097E - Clearing the Snowdrift

We are given a runway divided into n sections, each covered with some snow. The snow in the i-th section has height ai. A snowplow can operate on any contiguous segment of at most length d.

codeforcescompetitive-programmingdata-structuresdfs-and-similardpgreedy
CF 2097D - Homework

We are given two binary strings of the same length, and we are allowed to repeatedly apply a very specific transformation that acts on halves of substrings and mixes corresponding bits using XOR-like behavior.

codeforcescompetitive-programmingbitmasksmathmatrices
CF 2097B - Baggage Claim

The task is to reconstruct a simple path on a rectangular grid where only the cells with odd indices are known. Specifically, the path alternates between "known" and "unknown" cells, starting and ending with known cells.

codeforcescompetitive-programmingcombinatoricsdfs-and-similardpdsugraphsimplementationmathtrees
CF 2097C - Bermuda Triangle

The plane moves inside a right triangle with corners at $(0,0)$, $(n,0)$, and $(0,n)$. The aircraft starts strictly inside this triangle at $(x,y)$ and moves with a constant velocity vector $(vx, vy)$.

codeforcescompetitive-programmingchinese-remainder-theoremgeometryimplementationmathnumber-theory
CF 2097A - Sports Betting

We are given several independent scenarios. In each scenario, there are multiple students, and for each student we are told a day $ai$.

codeforcescompetitive-programming2-satbrute-forcemathsortings
Kvant Math Problem 1524

Let the incenters of the triangles $ABP$, $BCP$, $CDP$, $DAP$ be $X,Y,Z,W$ respectively.

kvantmathematicsolympiad
CF 2066F - Curse

We are given two arrays of integers, a and b, and we are asked whether we can transform a into b using a very particular operation.

codeforcescompetitive-programmingconstructive-algorithmsdpmath
CF 2066D2 - Club of Young Aircraft Builders (hard version)

We are asked to restore missing information in a sequence of airplane launches by residents in a building. Each floor has exactly one resident, and the residents launch paper airplanes sequentially.

codeforcescompetitive-programmingcombinatoricsdpmath
CF 2066E - Tropical Season

We are given a changing multiset of barrel volumes. Each barrel has a numeric value, and exactly one barrel is “special” in the sense that it carries an invisible poison.

codeforcescompetitive-programmingbinary-searchdata-structuresgreedyimplementation
CF 2066D1 - Club of Young Aircraft Builders (easy version)

We are asked to count the number of valid sequences of airplane launches from a building with n floors. Each floor has exactly one resident, and all residents want to collectively launch at least c airplanes. The building has m total launches.

codeforcescompetitive-programmingcombinatoricsdpmath
CF 2066A - Object Identification

The failure you show is not enough to diagnose the algorithm itself. Let's trace what happened: The input contains 5 test cases: The program produced only: instead of: This means the code successfully processed the first test case and then terminated before handling the…

codeforcescompetitive-programminggraphsgreedyimplementationinteractive
CF 2066B - White Magic

We are given an array of non-negative integers, and we are allowed to pick a subsequence from it. From that subsequence, we want to keep as many elements as possible while ensuring a very specific prefix-suffix condition holds at every split point.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresdpgreedyimplementation
CF 2066C - Bitwise Slides

We are building a process that evolves three integers, initially all zero. We read an array from left to right, and for each element we must assign it to exactly one of the three variables. Assigning means XORing that value into the chosen variable.

codeforcescompetitive-programmingbitmaskscombinatoricsdpmath
CF 2060G - Bugged Sort

The failure you show is not enough to diagnose the algorithm itself. Let's trace what happened: The input contains 5 test cases: The program produced only: instead of: This means the code successfully processed the first test case and then terminated before handling the…

codeforcescompetitive-programmingdpgreedysortings
CF 2060F - Multiplicative Arrays

We are asked to count arrays of integers where the product of all elements equals a specific target number. More concretely, for given integers $k$ and $n$, we need to determine, for every number $x$ from $1$ to $k$, how many arrays $a$ exist such that each element is between…

codeforcescompetitive-programmingcombinatoricsdpnumber-theory
CF 2060E - Graph Composition

We are given two undirected graphs on the same set of vertices. One graph, call it the working graph, is the structure we are allowed to modify. The second graph is a fixed reference structure that we must eventually “match” in terms of connectivity.

codeforcescompetitive-programmingdfs-and-similardsugraphsgreedy
CF 2060D - Subtract Min Sort

We are given an array of positive integers. We are allowed to repeatedly choose two adjacent elements and perform a “balancing subtraction” operation: we look at a pair, subtract the smaller value from both entries, and continue.

codeforcescompetitive-programminggreedy
CF 2060B - Farmer John's Card Game

We are given several independent test cases. In each one, a set of cows holds disjoint collections of cards, and every card has a unique integer value across all cows.

codeforcescompetitive-programminggreedysortings
CF 2060A - Fibonacciness

We are given four known values that represent an array of five integers with the middle element missing. The missing position is the third one, and we are free to choose any integer value for it, including negatives or zero.

codeforcescompetitive-programmingbrute-force
CF 2038G - Guess One Character

We are given an interactive problem where the judge has a hidden binary string s of length n. Our goal is to identify at least one character in s by asking up to three queries per test case. Each query asks how many times a binary substring t occurs contiguously in s.

codeforcescompetitive-programmingconstructive-algorithmsimplementationinteractive
CF 2038N - Fixing the Expression

We are given a very small expression of fixed length three. The first and last characters are digits, and the middle character is a comparison operator: less than, equal, or greater than.

codeforcescompetitive-programmingimplementation
CF 2038M - Royal Flush

We are repeatedly simulating a constrained card game where the only thing that ultimately matters is whether we ever manage to hold a very specific 5-card pattern: the Royal Flush of some suit.

codeforcescompetitive-programmingdpimplementation
Kvant Math Problem 1501

For small $x$, the functions admit linear approximations $\sin(kx)\sim kx$ and $\sin x\sim x$.

kvantmathematicsolympiad
CF 2038E - Barrels

We are asked to maximize the water volume in the first of a sequence of connected barrels by adding clay into any barrel. Each barrel has a water column, and adjacent barrels are connected by horizontal pipes at given heights.

codeforcescompetitive-programmingdata-structuresgreedymath
CF 2038F - Alternative Platforms

We are given a collection of bloggers, where each blogger has two independent activity counts: how many videos they uploaded to platform A and how many to platform B. A user does not necessarily watch all bloggers equally.

codeforcescompetitive-programmingcombinatoricsdata-structuresfftmathsortings
CF 2038D - Divide OR Conquer

We are given an array of integers and asked to count the number of ways to partition it into contiguous subarrays such that the bitwise OR of each subarray is non-decreasing from left to right. Each element must belong to exactly one subarray.

codeforcescompetitive-programmingbinary-searchbitmasksdata-structuresdpimplementation
CF 2038C - DIY

We are given a list of integers, and each integer can represent either an x-coordinate or a y-coordinate. The task is to choose eight integers from this list and form four points in the 2D plane so that these four points become the corners of a rectangle whose sides are…

codeforcescompetitive-programmingdata-structuresgeometrygreedysortings
CF 2038A - Bonus Project

We have a team of engineers, each with a promised bonus and a personal cost for doing one unit of work. The team needs to complete a project that requires exactly $k$ units of work, and every engineer will decide individually how much to contribute.

codeforcescompetitive-programminggamesgreedy
CF 2038B - Make It Equal

The failure you show is not enough to diagnose the algorithm itself. Let's trace what happened: The input contains 5 test cases: The program produced only: instead of: This means the code successfully processed the first test case and then terminated before handling the…

codeforcescompetitive-programmingbinary-searchbrute-forcegreedymath
Kvant Math Problem 1469

Each integer $n$ with exactly three ones in binary has the form

kvantmathematicsolympiad
CF 2036G - Library of Magic

We are dealing with a very large universe of book types, from 1 up to n where n can be as large as 10^18. Every type normally appears exactly twice in a hidden collection.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsdivide-and-conquerinteractivemathnumber-theory
CF 2036D - I Love 1543

The input describes several rectangular grids of digits. Each grid is split conceptually into concentric “rings” or layers, starting from the outer border and moving inward. Every layer forms a closed cycle if you walk along its border clockwise.

codeforcescompetitive-programmingbrute-forceimplementationmatrices
CF 2036F - XORificator 3000

The failure you show is not enough to diagnose the algorithm itself. Let's trace what happened: The input contains 5 test cases: The program produced only: instead of: This means the code successfully processed the first test case and then terminated before handling the…

codeforcescompetitive-programmingbitmasksdpnumber-theorytwo-pointers
CF 2036E - Reverse the Rivers

We are given a world with n countries, each divided into k regions, where each region has an initial water value a[i][j]. The sages have built channels so that water in a region flows downstream through countries in the same region index.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsdata-structuresgreedy
CF 2036B - Startup

The failure you show is not enough to diagnose the algorithm itself. Let's trace what happened: The input contains 5 test cases: The program produced only: instead of: This means the code successfully processed the first test case and then terminated before handling the…

codeforcescompetitive-programminggreedysortings
CF 2036C - Anya and 1100

We are given a binary string that changes over time. Each query updates a single position, flipping that character to either 0 or 1. After every update, we must answer a very specific question: does the current string contain the pattern “1100” as a contiguous block anywhere?

codeforcescompetitive-programmingbrute-forceimplementation
CF 2036A - Quintomania

A melody here is just a short sequence of integer pitches. Each pitch is an integer between 0 and 127, and what matters is not the absolute values but the differences between neighboring notes.

codeforcescompetitive-programmingimplementation
Kvant Math Problem 953

Each special point is an intersection of three lines determined by pairs of the six given points.

kvantmathematicsolympiad
CF 2037G - Natlan Exploring

We are asked to count the number of distinct paths from the first city to the last city in a region of Natlan, where each city has an attractiveness value. The paths follow a simple rule: from city $i$ you can travel to city $j$ if $i < j$ and $gcd(ai, aj) neq 1$.

codeforcescompetitive-programmingbitmaskscombinatoricsdata-structuresdpmathnumber-theory
CF 2037E - Kachina's Favorite Binary String

We are tasked with reconstructing a hidden binary string of length $n$ by querying a function $f(l, r)$, which counts the number of subsequences "01" in the substring from index $l$ to $r$. A subsequence is any selection of characters maintaining the original order.

codeforcescompetitive-programmingdpgreedyinteractivetwo-pointers
CF 2037D - Sharky Surfing

We are asked to model a surfboard journey along a one-dimensional path from position 1 to position $L$. Mualani starts with jump power 1, which allows her to move from her current position $x$ to any position in $[x, x+k]$, where $k$ is her current jump power.

codeforcescompetitive-programmingdata-structuresgreedytwo-pointers
CF 2037F - Ardent Flames

We are given a line of enemies, each with a fixed health and a fixed position. Xilonen can attack from a single chosen position p, and each attack reduces an enemy’s health by m - The first key observation is that the damage from each attack decreases linearly with distance.

codeforcescompetitive-programmingbinary-searchdata-structuresmathsortingstwo-pointers
CF 2037C - Superultra's Favorite Permutation

We are asked to construct a permutation of numbers from 1 to n such that the sum of every pair of consecutive numbers is composite. In other words, for a permutation p of length n, every p[i] + p[i+1] must not be a prime. If no such permutation exists, we return -1.

codeforcescompetitive-programmingconstructive-algorithmsgreedymathnumber-theory
CF 2037A - Twice

We are given a small array of integers. Kinich can score points by repeatedly selecting two distinct indices containing equal values, with the restriction that each index can be used at most once. The task is to determine the maximum number of such pairings for each test case.

codeforcescompetitive-programmingimplementation
CF 2037B - Intercepted Inputs

The failure you show is not enough to diagnose the algorithm itself. Let's trace what happened: The input contains 5 test cases: The program produced only: instead of: This means the code successfully processed the first test case and then terminated before handling the…

codeforcescompetitive-programmingbrute-forceimplementation
CF 2038L - Bridge Renovation

We are asked to compute the minimum number of standard-length planks, each 60 units long, needed to cover three bridges that have different widths. Each bridge requires n planks to span its width: the first bridge needs planks of length 18, the second 21, and the third 25.

codeforcescompetitive-programmingbrute-forcedpgreedymathtwo-pointers
Kvant Math Problem 851

Place the square in a coordinate system so that computations can be expressed in terms of two parameters.

kvantmathematicsolympiad
CF 2038H - Galactic Council

Each turn in this game is a small strategic decision that affects two coupled systems at once. There are n political parties, each maintaining a power value that starts at zero and only increases over time.

codeforcescompetitive-programmingflows
CF 2038K - Grid Walk

We are asked to move through an $n times n$ grid from the top-left corner to the bottom-right corner, only stepping right or down. Every cell $(i, j)$ contributes a cost that depends only on its row index and column index through greatest common divisors: $gcd(i, a) + gcd(j, b)$.

codeforcescompetitive-programmingbrute-forcedpgreedymathnumber-theory
CF 2038J - Waiting for...

We process a timeline of events at a bus stop. There are two kinds of events. A P x event means x ordinary passengers arrive and start waiting. A B x event means a bus arrives with x free seats. When a bus arrives, ordinary passengers always board before Monocarp.

codeforcescompetitive-programminggreedyimplementation
CF 2038I - Polyathlon

We are asked to simulate a multi-sport elimination competition with a twist: each participant has a binary skill vector indicating which sports they are proficient in.

codeforcescompetitive-programmingbinary-searchdata-structureshashingstring-suffix-structuresstrings
CF 2039H2 - Cool Swap Walk (Hard Version)

I can't reliably produce a complete, correct editorial with verified implementation code for Codeforces 2039H2 from first principles alone.

codeforcescompetitive-programmingconstructive-algorithmsimplementationsortings
CF 2039F1 - Shohag Loves Counting (Easy Version)

We are asked to count arrays with elements from 1 to $m$ that satisfy a very particular property: if we compute $f(k)$ for every length $k$ of subarray, no two values $f(i)$ and $f(j)$ are equal.

codeforcescompetitive-programmingcombinatoricsdpmathnumber-theory
CF 2039H1 - Cool Swap Walk (Easy Version)

We are given an array of length $n$. The only allowed operation is quite unusual: we imagine an $n times n$ grid, and we traverse it from the top-left corner to the bottom-right corner, moving only right or down.

codeforcescompetitive-programmingconstructive-algorithmsimplementationsortings
CF 2039F2 - Shohag Loves Counting (Hard Version)

We are asked to count arrays of arbitrary length, where each element is an integer from 1 to $m$, such that for every subarray length $k$, the GCD of the maximums of all subarrays of that length - denoted $f(k)$ - is distinct for different lengths.

codeforcescompetitive-programmingdpnumber-theory
Kvant Math Problem 785

The hypothesis states that for every integer $k>1$ there exists a constant $b_k$ such that

kvantmathematicsolympiad
CF 2039G - Shohag Loves Pebae

The failure you show is not enough to diagnose the algorithm itself. Let's trace what happened: The input contains 5 test cases: The program produced only: instead of: This means the code successfully processed the first test case and then terminated before handling the…

codeforcescompetitive-programmingmathnumber-theory
CF 2039D - Shohag Loves GCD

The failure you show is not enough to diagnose the algorithm itself. Let's trace what happened: The input contains 5 test cases: The program produced only: instead of: This means the code successfully processed the first test case and then terminated before handling the…

codeforcescompetitive-programmingconstructive-algorithmsgreedymathnumber-theory
CF 2039E - Shohag Loves Inversions

We are asked to count the number of distinct arrays of length $n$ that can be generated starting from the array $[0, 1]$ by repeatedly inserting the current inversion count anywhere in the array. An inversion is a pair of indices $(i, j)$ such that $i < j$ and $ai aj$.

codeforcescompetitive-programmingcombinatoricsdpimplementationmath
CF 2039C2 - Shohag Loves XOR (Hard Version)

We are asked to count integers $y$ in the range from 1 to $m$ such that $x oplus y$ is divisible by at least one of $x$ or $y$. Here, $oplus$ is the bitwise XOR operator.

codeforcescompetitive-programmingbitmasksbrute-forcemathnumber-theory
CF 2039A - Shohag Loves Mod

We need to construct an increasing sequence of length $n$, where every value lies between 1 and 100. The sequence must satisfy a special condition involving remainders. For each position $i$, consider the value $ai bmod i$.

codeforcescompetitive-programmingconstructive-algorithmsnumber-theory
CF 2039B - Shohag Loves Strings

The failure you show is not enough to diagnose the algorithm itself. Let's trace what happened: The input contains 5 test cases: The program produced only: instead of: This means the code successfully processed the first test case and then terminated before handling the…

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementationstrings
CF 2039C1 - Shohag Loves XOR (Easy Version)

We are given a number $x$ and a very large upper bound $m$. For each test case, we must count how many integers $y$ in the range $1 le y le m$ satisfy a condition defined through XOR. For a candidate $y$, we compute $z = x oplus y$.

codeforcescompetitive-programmingbitmasksbrute-forcemathnumber-theory
CF 2040D - Non Prime Tree

We are given a tree with $n$ vertices, and we must assign each vertex a distinct integer from the range $1$ to $2n$, using exactly $n$ of those numbers. The assignment is arbitrary except that every vertex gets a unique value.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdfs-and-similargreedynumber-theorytreestwo-pointers
CF 2040F - Number of Cubes

We have an $a times b times c$ toroidal grid of unit cubes. Each cell receives one of $k$ colors, and color $i$ must appear exactly $di$ times. Two colorings are considered the same if one can be transformed into the other by cyclic shifts along the three coordinate axes.

codeforcescompetitive-programmingcombinatoricsdpmathnumber-theory
CF 2040E - Control of Randomness

We are given a tree, an undirected connected acyclic graph, with n vertices rooted at vertex 1. A robot starts at some vertex v ≠ 1 and moves toward the root. Odd-numbered steps are deterministic: the robot always moves one step along a shortest path toward vertex 1.

codeforcescompetitive-programmingcombinatoricsdfs-and-similardpgraphsgreedymathprobabilitiestrees
CF 2040B - Paint a Strip

Codeforces 2040B: Paint a Strip

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 2040C - Ordered Permutations

We are asked to work with permutations of numbers from 1 to n, and each permutation has a sum defined by taking every contiguous subarray and adding its minimum. Among all permutations of length n, some permutations maximize this sum.

codeforcescompetitive-programmingbitmaskscombinatoricsconstructive-algorithmsgreedymathtwo-pointers
CF 2040A - Game of Division

We are looking at a decision problem where one player tries to “trap” another player using modular arithmetic on array values. We are given an array of integers. The first player picks a single position in the array and commits to that value.

codeforcescompetitive-programminggamesmath
Kvant Math Problem 679

Let the circles be $\omega_1,\omega_2,\omega_3,\omega_4$ with consecutive tangency points $A,B,C,D$.

kvantmathematicsolympiad
CF 2041N - Railway Construction

The failure you show is not enough to diagnose the algorithm itself. Let's trace what happened: The input contains 5 test cases: The program produced only: instead of: This means the code successfully processed the first test case and then terminated before handling the…

codeforcescompetitive-programming
CF 2041M - Selection Sort

We are given a single array of integers, and we want to transform it into a non-decreasing sequence. The only tool allowed is a special sorting routine that behaves like a selection-sort variant: it repeatedly compares a fixed position with all later positions and swaps…

codeforcescompetitive-programmingbinary-searchdata-structuresgreedytwo-pointers
CF 2041L - Building Castle

I can't provide a correct editorial for Codeforces 2041L from the problem statement alone because the key geometric optimization step is nontrivial, and I do not have enough information about the official solution to reconstruct a provably correct accepted algorithm.

codeforcescompetitive-programming
CF 2041J - Bottle Arrangement

The failure you show is not enough to diagnose the algorithm itself. Let's trace what happened: The input contains 5 test cases: The program produced only: instead of: This means the code successfully processed the first test case and then terminated before handling the…

codeforcescompetitive-programmingdata-structuresdivide-and-conquerdpdsugreedy
CF 2041I - Auto Complete

We are asked to simulate an advanced text editor that supports four operations: adding patterns for auto-complete, deleting patterns, appending text to the current editor content, and deleting characters from the end of the current content.

codeforcescompetitive-programmingbinary-searchdata-structureshashingimplementationsortingsstringstrees
CF 2041K - Trophic Balance Species

We are given an ecosystem modeled as a directed graph, where each node represents a species and each directed edge represents a feeding relationship from prey to predator. For each species, we want to identify whether it is a trophic balance species.

codeforcescompetitive-programmingbinary-searchbrute-forcedfs-and-similargraphs
CF 2041G - Grid Game

We have an enormous $n times n$ grid, where $n$ can be as large as $10^9$. Some cells are painted black by drawing vertical segments inside columns. Every cell covered by at least one segment becomes black.

codeforcescompetitive-programming
CF 2041H - Sheet Music

Alice wants to count all sequences of notes of length n using pitches from 1 to k, but sequences that "move" the same way are considered identical.

codeforcescompetitive-programmingcombinatoricsdpmath
CF 2041D - Drunken Maze

We have a rectangular maze represented as a grid of characters. Empty cells are walkable, walls block movement, and two special cells mark the start and target positions.

codeforcescompetitive-programmingbrute-forcedfs-and-similargraphsshortest-paths
CF 2041F - Segmentation Folds

We are given a segment on the number line defined by two integers $ell$ and $r$, and Peter can fold this segment in two specific ways: from left to right (LTR) and from right to left (RTL).

codeforcescompetitive-programmingbrute-forcedfs-and-similarnumber-theory
CF 2041E - Beautiful Array

We are asked to construct an integer array such that its mean is exactly a and its median is exactly b. The input consists of two integers, a and b, which are the desired mean and median, respectively.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 2041B - Bowling Frame

The failure you show is not enough to diagnose the algorithm itself. Let's trace what happened: The input contains 5 test cases: The program produced only: instead of: This means the code successfully processed the first test case and then terminated before handling the…

codeforcescompetitive-programmingbinary-searchbrute-forcemath
CF 2041A - The Bento Box Adventure

The problem presents a scenario where a person visits one restaurant each day from Monday to Thursday, choosing a different restaurant each day from a set of five possible restaurants. The input gives the sequence of four distinct restaurants visited, one per day.

codeforcescompetitive-programmingimplementationsortings
CF 2041C - Cube

We are given a cube of size $n times n times n$, where every cell contains a weight. The task is to pick exactly $n$ cells such that no two chosen cells share the same coordinate in any dimension.

codeforcescompetitive-programmingbitmasksdfs-and-similardp
Kvant Math Problem 571

The condition gives control only on a sparse subsequence of the sequence, namely the indices $1,4,9,\dots,n^2$, and the weights are harmonic in $k$.

kvantmathematicsolympiad
CF 2042F - Two Subarrays

We have two arrays, a and b. For any subarray [l, r], its value is not just the sum of the elements of a inside it. We also add bl and br, the values attached to the two endpoints.

codeforcescompetitive-programmingdata-structuresdpimplementationmatrices
CF 2042D - Recommendations

Each user in the system is described by a closed interval on the number line. If we think of track IDs as positions on a huge axis from 1 to 10^9, then user i likes exactly the integer points in the segment $[li, ri]$.

codeforcescompetitive-programmingdata-structuresimplementationsortingstwo-pointers
CF 2042E - Vertex Pairs

The failure you show is not enough to diagnose the algorithm itself. Let's trace what happened: The input contains 5 test cases: The program produced only: instead of: This means the code successfully processed the first test case and then terminated before handling the…

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresdfs-and-similardivide-and-conquergreedyimplementationtrees
CF 2042B - Game with Colored Marbles

We are asked to compute Alice's final score in a sequential marble-taking game. There is a collection of n marbles, each with a specific color. Alice and Bob alternate turns, starting with Alice. Each turn consists of removing one marble.

codeforcescompetitive-programminggamesgreedy
CF 2042C - Competitive Fishing

The failure you show is not enough to diagnose the algorithm itself. Let's trace what happened: The input contains 5 test cases: The program produced only: instead of: This means the code successfully processed the first test case and then terminated before handling the…

codeforcescompetitive-programminggreedy
CF 2042A - Greedy Monocarp

We are given several independent test cases. In each one there is a collection of chests, each starting with some number of coins. We are allowed to increase the number of coins in any chests, with no limit on how many we add, but we are trying to minimize the total coins we add.

codeforcescompetitive-programminggreedysortings
CF 2043G - Problem with Queries

We are given an array of integers and need to handle two types of queries. The first type updates a single element in the array. The second type asks for the number of pairs of indices within a specified subarray that contain different values.

codeforcescompetitive-programmingbrute-forcedata-structuresimplementation
CF 2043F - Nim

We are asked to consider multiple rounds of the game Nim played on contiguous subarrays of an array of integers. Each integer represents a pile of stones.

codeforcescompetitive-programmingbitmasksbrute-forcecombinatoricsdpgamesgreedyimplementationshortest-paths