brain

tamnd's digital brain — notes, problems, research

41650 notes

CF 1254B2 - Send Boxes to Alice (Hard Version)

We are given a line of boxes, each containing some number of chocolate pieces. A single move allows us to take one piece from a box and shift it to an adjacent box, so the cost of moving a piece is exactly the distance it travels along the line.

codeforcescompetitive-programmingconstructive-algorithmsgreedymathnumber-theoryternary-searchtwo-pointers
CF 1253E - Antenna Coverage

We are given a set of signal towers placed on a number line. Each tower has a fixed position and a symmetric coverage radius. A tower at position $xi$ with radius $si$ covers every integer point from $xi - si$ to $xi + si$.

codeforcescompetitive-programmingdata-structuresdpgreedysortings
CF 1253F - Cheap Robot

We are given a weighted undirected graph where a subset of nodes are “centrals”, meaning that whenever a robot arrives there its battery is instantly refilled to full capacity. The robot starts and must finish each query at a central node.

codeforcescompetitive-programmingbinary-searchdsugraphsshortest-pathstrees
CF 1252K - Addition Robot

The robot stores a binary instruction string over the alphabet {A, B}. When we process this string with an initial pair of values (A, B), each character acts like a small transformation step.

codeforcescompetitive-programmingdata-structuresmathmatrices
CF 1252L - Road Construction

We are given a set of cities where each city proposes exactly one possible road. City $i$ wants to connect to a specific other city $Ai$, so each proposal is an undirected edge $(i, Ai)$.

codeforcescompetitive-programmingflowsgraphs
CF 1252I - Mission Possible

We are given a rectangular region and several circular sensors placed inside it. Each sensor detects any point that lies strictly inside its circle.

codeforcescompetitive-programming
CF 1252C - Even Path

The grid in this problem is not given explicitly as an $N times N$ matrix. Instead, every cell value is determined by a simple additive structure: the value at position $(i, j)$ is $Ri + Cj$.

codeforcescompetitive-programmingdata-structuresimplementation
CF 1252D - Find String in a Grid

We are given a rectangular grid of uppercase letters and many query strings. For each query string, we need to count how many ways it can be traced inside the grid under a very specific movement rule: we start from some cell, first move only to the right any number of steps…

codeforcescompetitive-programmingdata-structuresdpstringstrees
CF 1250N - Wires

Each wire connects two contact points, and we say two wires are related if they share at least one endpoint, or if there is a chain of wires where consecutive wires share endpoints.

codeforcescompetitive-programmingdfs-and-similargraphsgreedy
CF 1250K - Projectors

We are given two sets of time intervals: one set represents lectures, the other represents seminars. Each lecture must be assigned a high-definition projector, while each seminar can use any projector, either HD or ordinary.

codeforcescompetitive-programmingflowsgraphs
CF 1250M - SmartGarden

The garden is an $n times n$ grid where each cell is either a plant that must be watered or a slab that must never be touched. The layout is highly structured: all diagonal cells are slabs, and every cell strictly below the diagonal that touches the diagonal also becomes a slab.

codeforcescompetitive-programmingconstructive-algorithmsdivide-and-conquer
CF 1250G - Discarding Game

We are given two sequences that evolve in lockstep over time. In each round, the human gains some amount of points while the computer also gains points. Both totals accumulate independently across rounds.

codeforcescompetitive-programmingdpgreedytwo-pointers
CF 1250I - Show Must Go On

We are given a list of dancers, each with a fixed awkwardness value. A “concert” is defined as choosing a subset of these dancers. Not all subsets are allowed: the total awkwardness of a chosen subset must not exceed a limit $k$.

codeforcescompetitive-programmingbinary-searchbrute-forcegreedyshortest-paths
CF 1250E - The Coronation

We are given several binary strings, each representing a necklace. Each position in a string is either 0 or 1, and we interpret this as two types of gems. We are allowed to reverse some of these strings.

codeforcescompetitive-programminggraphsimplementation
CF 1250C - Trip to Saint Petersburg

We are given a collection of projects, each defined by a time interval and a payment. If we choose a trip to Saint Petersburg, we also fix a continuous interval of days during which we stay in the city.

codeforcescompetitive-programmingdata-structures
CF 1250B - The Feast and the Bus

We are given a collection of employees, where each employee belongs to exactly one team. The only meaningful structure in the input is the frequency of each team, since employees from the same team must always travel together.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedymath
CF 1250D - Conference Problem

We are given several scientists, each staying at the conference for a time interval from day $li$ to $ri$, inclusive. Some scientists explicitly belong to a known country $ci 0$, while others have no country assigned ($ci = 0$).

codeforcescompetitive-programmingdp
CF 1242C - Sum Balance

We are given several containers, each holding a multiset of distinct integers. A single operation is performed exactly once: from every container, we must pick exactly one value, and then redistribute those chosen values back into the containers so that each container still…

codeforcescompetitive-programmingbitmasksdfs-and-similardpgraphs
CF 1242D - Number Discovery

We are asked to reconstruct a very unusual infinite sequence that is generated in rounds. Each round repeatedly looks at the smallest positive integers that have not yet appeared in the sequence.

codeforcescompetitive-programmingmath
CF 1242E - Planar Perimeter

We are asked to construct a planar structure made of polygonal faces, where each face is a simple cycle in a shared graph. Each face i must have exactly ai vertices on its boundary. Whenever two faces touch, they must share an entire edge, not just a vertex.

codeforcescompetitive-programmingconstructive-algorithmsgraphs
CF 1234C - Pipes

The grid consists of two horizontal rows, each with $n$ pipe pieces placed in a line. Water enters from the left side of the top row, specifically into cell $(1,1)$, and must travel through connected pipe openings until it eventually exits to the right side of the bottom row…

codeforcescompetitive-programmingdpimplementation
CF 1211E - Double Permutation Inc.

We are given a sequence of integers and must assign each position one of three colors: red, green, or blue. After coloring, we look only at red elements in their original order; they must form a permutation of consecutive integers starting from 1.

codeforcescompetitive-programming*specialbinary-searchgreedy
CF 1211H - Road Repair in Treeland

We are given a tree where each edge represents a road between two cities. Every road must be assigned to a company, and multiple roads can share the same company.

codeforcescompetitive-programming*specialbinary-searchdptrees
CF 1211A - Three Problems

We are given a list of problem difficulties, where each problem has an index and a numeric complexity value. The task is to select three distinct indices $a$, $b$, and $c$ such that the corresponding values form a strictly increasing chain: $ra < rb < rc$.

codeforcescompetitive-programming*specialimplementation
CF 1211C - Ice Cream

We are given a sequence of days, and on each day there is a price for buying a single ice cream portion. Each day also comes with constraints describing how many portions Tanya is allowed to eat on that day.

codeforcescompetitive-programming*specialgreedysortings
CF 1210D - Konrad and Company Evaluation

We are given a group of employees and an undirected “dislike” relation between some pairs. At any moment, each employee has a salary, and this salary induces a directed view of every dislike edge: between two connected employees, the one with higher salary brags to the one…

codeforcescompetitive-programminggraphs
CF 1210F2 - Marek and Matching (hard version)

We are given a complete bipartite structure between two sets of size $n$, where every potential edge $(elli, rj)$ exists independently with some probability $p{ij}/100$. The randomness is over the presence or absence of each edge, and all edges are independent.

codeforcescompetitive-programmingbrute-forceprobabilities
CF 1202B - You Are Given a Decimal String...

We are given a long decimal string that was produced as a subsequence of outputs from a very simple counter process. The counter always starts at value zero.

codeforcescompetitive-programmingbrute-forcedpshortest-paths
CF 1202E - You Are Given Some Strings...

We are given one long reference string t and a collection of strings s1 … sn. For every ordered pair of strings (si, sj), we form a new string by concatenating them, then we count how many times this concatenated string appears as a contiguous substring inside t.

codeforcescompetitive-programmingbrute-forcestring-suffix-structuresstrings
CF 1202D - Print a 1337-string...

We are asked to construct a string made only of the digits 1, 3, and 7 such that a very specific pattern appears a prescribed number of times as a subsequence.

codeforcescompetitive-programmingcombinatoricsconstructive-algorithmsmathstrings
CF 1202C - You Are Given a WASD-string...

A command string describes how a robot walks on an infinite grid. Each character moves the robot one step in one of four directions. If we choose a starting position and execute the whole sequence, the robot traces a path and must never leave a finite rectangular board.

codeforcescompetitive-programmingbrute-forcedata-structuresdpgreedyimplementationmathstrings
CF 1170H - Longest Saw

We are given a multiset of integers for each test case. From this multiset, we are allowed to pick any subset of elements and then permute them freely.

codeforcescompetitive-programming*specialconstructive-algorithms
CF 1170E - Sliding Doors

We are given a line of $m$ cells and a sequence of $n$ sliding doors. Each door occupies a contiguous block of cells, and the doors appear in a fixed left-to-right order.

codeforcescompetitive-programming*specialbinary-search
CF 1170G - Graph Decomposition

We are given an undirected multigraph where edges may repeat and self-loops are allowed. The task is to completely eliminate all edges by repeatedly choosing a simple cycle and removing all edges belonging to that cycle.

codeforcescompetitive-programming*specialgraphs
CF 1170F - Wheels

We are given an array of wheel pressures and we need to pick exactly $m$ of them. After selecting those $m$ wheels, we are allowed to change their pressures so that all of them end up equal to a single value.

codeforcescompetitive-programming*specialbinary-searchgreedy
CF 1170D - Decoding of Integer Sequences

We are given a single flattened sequence that was produced from several hidden integer sequences. The encoding process mixed all sequences together in “column order”: first all first elements of each sequence, then all second elements, then all third elements, and so on.

codeforcescompetitive-programming*specialdata-structuresimplementation
CF 1170C - Minus and Minus Give Plus

We are given two strings consisting only of two symbols, a “minus” and a “plus”. The only allowed move takes two neighboring minus signs and replaces them with a single plus sign, which shortens the string by one character.

codeforcescompetitive-programming*specialimplementationstrings
CF 1170A - Three Integers Again

We are given two numbers per query, and each query hides a simple structure built from three unknown positive integers $a$, $b$, and $c$. From these three values we can form three pairwise sums: $a+b$, $a+c$, and $b+c$.

codeforcescompetitive-programming*specialmath
CF 1167G - Low Budget Inception

The city is a sequence of unit square buildings placed along an infinite horizontal line. Each building occupies an interval of length one, starting at some integer coordinate $ai$. So building $i$ spans $[ai, ai + 1]$, and these positions are strictly increasing.

codeforcescompetitive-programmingbrute-forcegeometry
CF 1167E - Range Deleting

We are given an array where every element lies between 1 and x, and we consider a transformation defined by a value interval [l, r]. This transformation deletes every array element whose value falls inside that interval, while leaving all other elements in their original order.

codeforcescompetitive-programmingbinary-searchcombinatoricsdata-structurestwo-pointers
CF 1167B - Lost Numbers

We are given an unknown ordering of six fixed numbers: 4, 8, 15, 16, 23, and 42. Each number appears exactly once in an array of length six, but their positions are hidden.

codeforcescompetitive-programmingbrute-forcedivide-and-conquerinteractivemath
CF 1167F - Scalar Queries

We are given an array of distinct numbers, and we look at every possible contiguous subarray. For each subarray, we temporarily reorder its elements in increasing order, then assign weights based on position in that sorted subarray: the smallest element gets weight 1, the next…

codeforcescompetitive-programmingcombinatoricsdata-structuresmathsortings
CF 1106F - Lunar New Year and a Recursive Sequence

We are given a sequence that starts from a very simple base and then evolves through a multiplicative recurrence.

codeforcescompetitive-programmingmathmatricesnumber-theory
CF 1105E - Helping Hiasat

We are given a timeline of events. At any moment, Hiasat’s profile has a single visible handle, and he is allowed to change this handle only at specific moments marked in the input. Between changes, the handle stays fixed.

codeforcescompetitive-programmingbitmasksbrute-forcedpmeet-in-the-middle
CF 1103D - Professional layer

We are given a collection of judges. Each judge contributes two values: a number $ai$, which controls how “resistant” their opinion is, and a cost parameter $ei$, which is the time cost if we decide to interact with that judge. We may choose to play with a judge at most once.

codeforcescompetitive-programmingbitmasksdp
CF 1103B - Game with modulo

We are interacting with a hidden number $a$, which is fixed for each game and lies between 1 and $10^9$. We cannot query it directly. Instead, we can ask questions consisting of two non-negative integers $x$ and $y$, and the judge compares $x bmod a$ and $y bmod a$.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsinteractive
CF 1075B - Taxi drivers and Lyft

We are given a set of people positioned on a number line. Each person is either a rider or a taxi driver, and all positions are distinct and already sorted in increasing order.

codeforcescompetitive-programmingimplementationsortings
Kvant Physics Problem 43

A spherical planet of radius $R$ is filled with an incompressible жидкость of constant density $\rho$ in hydrostatic equilibrium under its own gravitational field.

kvantphysics
Kvant Physics Problem 42

A uniform rope of linear mass density $\lambda$ (kg/m) passes over a frictionless pulley.

kvantphysics
Kvant Physics Problem 41

The system consists of the Sun, the Moon, and an observer on Earth.

kvantphysics
Kvant Physics Problem 40

A neon lamp consists of two large parallel plate electrodes separated by a distance $d = 3 \times 10^{-3},\text{m}$.

kvantphysics
Kvant Physics Problem 39

A planet of mass $M$ and radius $R$ is surrounded by an atmosphere of height $H$.

kvantphysics
math
binary searchimplementation
math
data structuresgreedyimplementation
binary searchdata structuresdfs and similar
constructive algorithmsgraphsimplementation
dpgeometrymatricesprobabilities
constructive algorithmsdp
binary searchflows
math
implementation
data structuresimplementation
constructive algorithmsimplementationstrings
data structuresdp
data structuresdp
*specialstringstrees
dfs and similargraphstrees
data structurestrees
dpgreedy
binary searchflowsgreedytwo pointers
combinatoricsdata structuresmath
constructive algorithmsgreedy
constructive algorithms
implementationmath
mathnumber theory
data structuresgreedyimplementation
constructive algorithmsgeometry
constructive algorithmsstrings
*specialgraphsimplementation
binary searchconstructive algorithmsdfs and similargraphsinteractive
brute forceimplementation
math
brute forcemath
brute forcecombinatoricsdpgreedymath
bitmasksdfs and similardsugraphs
brute forcestrings
binary searchmathnumber theory
binary searchdata structures
greedysortings
data structuresdfs and similardsugraphsgreedysortingstrees
greedysortings
dfs and similardsugraphsgreedystrings
combinatorics
dp