brain
tamnd's digital brain — notes, problems, research
41650 notes
We are given multiple independent sequences, and for each one we want to transform it into a non-decreasing array using a very specific operation.
Each query describes a pool of students split into three groups. Some students are coders, some are mathematicians, and some have no specialization at all. A valid team must contain exactly three students and must include at least one coder and at least one mathematician.
We are given an $n times n$ table that was originally generated from some hidden array $a1, a2, dots, an$. Every entry of the table was formed by multiplying two elements of this array, so the cell in row $i$, column $j$ equals $ai cdot aj$.
Alan follows a fixed schedule of gym visits over $N$ days. On day $i$, he must lift exactly $X[i]$ grams, and he starts with a base strength $K$. He can permanently increase his strength by buying a pre-workout drink on any day he visits a gym.
We are given a directed functional graph defined by an array A. From every node i, there is exactly one outgoing edge to A[i]. Repeated application of this mapping defines a process where starting from a node x, we move along the graph m times.
We are given a creature with an initial number of heads, and a collection of attack types. Each attack type behaves in a very specific way: when used, it removes some number of heads, but after the strike, if the creature is still alive, it immediately regrows a fixed number…
We are given a conceptual infinite string formed by concatenating blocks of digits. The first block is just the number “1”. The second block is “12”.
We are given a ticket represented by a string of even length. Each position corresponds to a digit from 0 to 9, except that some positions are unknown and marked with a question mark. The unknown positions must eventually be filled with digits.
We are given a sequence of nonzero integers and asked to count how many subarrays produce a positive product and how many produce a negative product. A subarray is defined by choosing two indices $l le r$ and multiplying everything from $al$ to $ar$.
We are given three integers describing a small combinatorial setup. There are a fixed number of boys and girls in total, and exactly $n$ participants will attend an event, but we do not know how many of them are boys or girls.
We are given a weighted tree where every edge has a cost, and we are asked multiple questions about how “expensive” paths between pairs of vertices can be. For any two vertices $u$ and $v$, there is exactly one simple path between them because the graph is a tree.
We are given a list of integers, and we are allowed to repeatedly reduce any chosen number by replacing it with its half rounded down. Each such replacement costs one operation.
We are given an undirected graph with up to 500 vertices. The graph is known to come from a very specific hidden labeling process: each vertex originally had a number between 0 and 15, and an edge existed between two vertices if and only if their labels differ in exactly one…
We are given a multiset of player ratings. Each player can be used at most once, and our goal is to form as many disjoint teams as possible under a strict structure constraint. Every valid team consists of two homogeneous groups of players.
We are given a binary string s consisting only of '0' and '1'. A string is called coherent if it does not contain either of the following patterns as a subsequence: - "011" - "110" Recall that a subsequence does not need to occupy consecutive positions.
We are given an undirected weighted graph with n nodes and a list of weighted edges. We must travel from source to target. The key concept in this problem is the definition of a threshold.
We are given an array sides containing exactly three positive integers. Each integer represents the length of one side of a potential triangle. The task is to determine whether these three side lengths can form a triangle with positive area.
Each light in this problem behaves like a binary switch that flips its state over time. You are given an initial configuration where each light is either on or off.
We are given a small restaurant model where each query describes available ingredients and selling prices for two kinds of burgers. One burger requires buns plus beef, the other requires buns plus chicken.
We are given two collections of positive integers. One collection represents the possible values we can pick as the first number, and the second collection represents the possible values we can pick as the second number.
We are asked to build permutations of numbers from 1 to n such that a specific structural property holds on subarrays, and to control how many subarrays satisfy it.
We are asked to arrange the numbers from 1 to 2n around a circle. Once the circle is fixed, we look at every contiguous block of exactly n elements. Each such block produces a sum, and since the circle has 2n positions, there are 2n such blocks (wrapping around at the end).
We are given an unknown binary grid of size $n times n$, where $n$ is odd. Each cell contains either 0 or 1. Two facts are guaranteed: the top-left cell is 1 and the bottom-right cell is 0. We cannot directly read the grid.
We are given a tree with $n$ nodes. Each edge must be assigned a non-negative integer. Once the edges are labeled, every pair of nodes defines a path, and each path has a sum obtained by adding the values on its edges.
We are looking at all possible sequences of length $n+m$ made of exactly $n$ ones and $m$ minus ones. Every arrangement is considered once, so this is a multiset permutation problem.
We are given a binary string and we are allowed to construct another binary string of the same length. The requirement is not local, it is global over all substrings: for every interval of positions, the value of the longest non-decreasing subsequence inside that interval must…
We are given a binary string and asked to construct another binary string of the same length. The key requirement is not about matching the strings themselves, but about preserving a structural value computed on every substring: the length of the longest non-decreasing…
We are given a length n array of positive integers, but the array is not arbitrary. Every value in it must satisfy a strict structural rule: each number is either 1, or it is an even number whose half is also present somewhere in the array.
Each project can be thought of as an action that becomes available only when Polycarp’s current rating is high enough. Once he starts a project, his rating may go up or down, but it is never allowed to become negative at any point.
We are given two strings, s and t. The second string is guaranteed to already appear inside the first one as a subsequence, meaning we can pick characters from s in order and obtain t.
We are given several independent scenarios. In each scenario, a group of students is arranged in a fixed circular order, and we are shown that order as a linear list representing clockwise traversal around the circle.
We are given a source string s and a target string t, where t is already guaranteed to be a subsequence of s. In other words, we can pick characters from s in order and obtain t without reordering anything.
We are given two binary strings, which represent two integers. One of them, call it $x$, is fixed. The other, $y$, is effectively shifted left by some number of positions $k$, then added to $x$. After computing this sum, we take its binary representation and reverse it.
We are given a list of numbers and allowed to repeatedly increase any single element by one. Each such increment has a cost of one operation, and we have a total budget of at most $k$ operations.
We are given a grid with rows increasing upward and columns increasing left to right. We start at the bottom-left cell and want to collect all treasures placed on various cells.
We are given a directed graph where each vertex behaves like a deterministic machine with a twist: the outgoing edge is not fixed, but chosen based on a changing integer state $c$.
We are given an $n times n$ grid where each cell is either black or white. A single operation is allowed exactly once: we choose a top-left corner of a $k times k$ square and repaint every cell inside that square to white.
We are simulating a very small system: a hotel with exactly 10 rooms indexed from 0 to 9. Each room can either be empty or occupied.
A water lily is attached to the bottom of a lake by a straight stem. Initially the stem is perfectly vertical, so the flower sits directly above its root point on the lake bed. The flower is floating above the water surface by a known height (H).
We are given a binary grid where some cells are black and the rest are already white. Our only operation is to pick any axis-aligned rectangle and repaint every cell inside it to white. Each such operation has a cost equal to the larger of its height or width.
We are given an extremely large $n times n$ grid, but instead of listing individual black cells, the input describes black regions as up to 50 axis-aligned rectangles. Every cell outside these rectangles is white initially, and inside them is black.
We are given a sequence of sound intensities, each a non-negative integer. Think of it as a time series of sampled audio amplitudes.
We are given several undirected graphs, each with exactly $3n$ vertices. For each graph, we must construct one of two specific structures of size $n$: either a matching consisting of $n$ edges, or an independent set consisting of $n$ vertices.
We are maintaining a dynamic list of balances for a fixed set of citizens. Initially, each citizen has a known amount of money. Then a sequence of events modifies these balances in two different ways.
We are given a collection of matryoshka dolls. Each doll has two parameters: an outer volume and an inner empty volume. A doll can be placed inside another if the outer volume of the inner doll does not exceed the inner volume of the outer doll.
Each strip can be viewed as a line of positions, and each position holds a chip. A chip starts at the rightmost cell of its strip, and players alternately move exactly one chip per turn, pushing it left by 1, 2, or 3 positions, as long as the move stays inside the strip and is…
We are given several independent sets of wooden planks, where each plank has a fixed length and cannot be cut. From each set, we want to assemble a structure called a ladder with as many steps as possible. A k-step ladder is formed by selecting exactly k + 2 planks.
We are given a row of pillars, each initially holding exactly one disk. Each disk has a distinct radius, so we can think of the input as a permutation of values from 1 to n placed on positions 1 through n. The only allowed move is very restrictive.
We are given a sequence of numbers and asked to pick one contiguous segment, or skip picking anything at all, in order to maximize a specific score function. The score of a chosen segment is its plain sum minus a penalty that depends only on its length.
We are working on an infinite checkerboard indexed by positive integer coordinates. The cell at (1, 1) is fixed as white, and colors alternate like a standard chessboard: parity of (x + y) determines whether a cell is black or white.
We are given an undirected weighted graph where every pair of vertices is connected by at least one path. Between any two vertices, there is a well-defined shortest path length.
We are given a string made only of the letters R, G, and B. From this string we want to pick a contiguous block of fixed length k and modify characters so that this block matches some segment of an infinite repeating pattern "RGBRGBRGB...".
We are given several independent queries. Each query describes a set of robots placed on an infinite grid. Every robot starts at a fixed coordinate, and it also has a personal movement system described by which of the four cardinal directions it can use.
We are given several independent arrays. For each one, we must cut it into exactly k contiguous pieces, where each piece has an odd sum. The array order is fixed, so the only freedom is choosing cut positions.
We are given a string made only of three characters, R, G, and B. From this string, we want to find a contiguous segment of fixed length k that is as close as possible to the repeating pattern RGBRGBRGB....
We are given a sequence of convex polygons, and each polygon is described by its vertices in counterclockwise order. For any query interval $[l, r]$, we conceptually take all polygons in that range and compute their Minkowski sum.
We are given a large grid whose values are not stored explicitly but generated in row-major order from a linear recurrence. Each cell represents a height value.
We are simulating a process that evolves in discrete moves. There is a container that starts empty, and Alya performs exactly n actions. The first action is fixed: she always adds exactly one candy.
We are given a group of students, each of whom prefers exactly one type of drink. The drink types are numbered from 1 to k. The preferences form an array where each entry tells us which drink a particular student likes.
We are given an array of numbers, all written with the same number of digits. For every ordered pair of elements in this array, we must compute a special digit-interleaving function that builds a new number by taking digits from the two inputs in alternating order starting…
We are asked to count ordered pairs of positive integers $(x, y)$ with both coordinates at most a very large bound $n$, where $n$ can have up to 100 decimal digits.
We are given a collection of axis-aligned line segments in the plane. Each segment is either perfectly horizontal or perfectly vertical. Horizontal segments never overlap with other horizontal segments, and the same is true for vertical segments.
We are given a single chip placed at the right end of a linear strip of cells indexed from 0 up to n. Two players alternate moves starting from the rightmost position n, and each move consists of shifting the chip left by exactly 1, 2, or k positions, as long as the chip stays…
We start with a list containing the integers from 1 to n in increasing order. The process repeatedly removes elements from this list in a very specific way: on the first step we remove the first remaining element, on the second step we remove what is now the second remaining…
We are given several independent grids. Each grid is a matrix of characters where each cell is either already black or still white. We are allowed to turn white cells into black one at a time. The goal is to make the grid contain at least one “cross”.
We are given two simple polygons in the plane, an initial shape and a target shape. Both polygons have equal area, but their geometry can be completely different.
We are given a set of attractions and some planned one-way slides between pairs of them. After construction, each slide can be reversed or kept as is, independently of others. What we ultimately choose is therefore just a direction for every existing edge.
We are given a rooted tree where vertex 1 is the root, and each other vertex has exactly one parent, so the structure is fixed and acyclic. Some non-root vertices contain a single fruit.
We are given a collection of strings that can be placed on the edges of a cube. Each string has length between 3 and 10, and we are allowed to use any of them repeatedly. A valid construction consists of taking a cube and assigning one string to each of its 12 edges.
Codeforces 1192B: Dynamic Diameter
Codeforces 1191A: Tokitsukaze and Enhancement
We are given a long line of items indexed from 1 to $n$. Among them, $m$ positions are marked as special. These special items are removed in a repeated process that works in rounds.
We are given a set of points in the plane, and we are allowed to choose a special kind of region: a vertical strip between two x-coordinates, say between l and r, but open on the sides, combined with a horizontal threshold a such that we only take points strictly above that…
We are working in a plane where the origin represents the explosion point. A set of people are placed at integer coordinates, and we are allowed to draw up to $m$ infinite straight lines.
We are given a binary string representing a line of cards, each showing either 0 or 1. A move consists of choosing exactly k consecutive positions and forcing all of them to become identical, either all 0 or all 1. The rest of the array is unchanged.
We are given an array of digits. The array length is not arbitrary in queries: every query asks about a segment whose length is exactly a power of two. On each segment, we repeatedly compress the array in a very specific way.
I cannot reliably reconstruct the exact statement of Codeforces 1188A2 (“Add on a Tree: Revolution”) from memory alone, and this problem is one of those 2500-rated constructives where small misinterpretations completely change the solution.
We are given an array of integers, and we are allowed to repeatedly choose a single element and increase it by a power of two, where the chosen power can be any nonnegative exponent independently each time.
We are given an array and asked to examine every subsequence of a fixed length $k$. For each chosen subsequence, we sort its elements mentally and look at all pairwise differences.
We are given a small undirected graph representing a town, with a designated meeting point at node 1. Several people start at specified nodes and all want to reach node 1. Time is discrete, and each person can either wait at their current node or traverse one edge per minute.
We are given a tree where every vertex starts unpainted, and we gradually paint vertices black. The first move can start anywhere, and after that every move must pick a white vertex that is adjacent to at least one black vertex.
We are given two arrays of equal length and allowed to repeatedly pick any contiguous segment of the first array and sort only that segment in non-decreasing order.
We are given an array whose elements are not fixed numbers but independent random integers. Each position $i$ can take any integer in the interval $[li, ri]$, all values equally likely and independent across indices.
We are asked to construct any integer array of length $n$ that is consistent with a set of constraints about subarrays. Each constraint describes either that a segment must be non-decreasing or that it must fail to be non-decreasing.
Each query describes a collection of identical eggs. Every egg contains some combination of two possible items: a sticker and a toy. Across all eggs, there are exactly s stickers and exactly t toys in total, and every egg contributes either one or both of these items.
We are given an undirected simple graph. Every vertex has some initial degree, and we are allowed to delete edges. After deletions, each vertex must still keep at least half of its original incident edges, rounded up.
The construction described in this problem defines an infinite binary matrix generated from a small starting grid.
We are given an array of real numbers whose total sum is exactly zero. Each number has a fixed decimal precision, so every value can be thought of as a rational number with a known fractional part.
We are given a small distribution problem. There are several participants in a contest, and each participant must receive two items: one pen and one notebook.
We are given a collection of songs, each song having a duration and a genre label from a small set of three possible genres. We want to build an ordered playlist using some of these songs, with two strict rules.
We are given a small collection of songs. Each song has a duration and a genre, and we want to form an ordered playlist by selecting some of these songs without repetition. The playlist must satisfy three constraints at the same time.
Three people stand on an infinite number line at positions $a$, $b$, and $c$. They are allowed to move along the line, but movement is extremely restricted: at each second, exactly one person may move, and that move is always by one unit either left or right.
We are given a grid where each cell is either empty or contains a lowercase Latin letter. The final grid is claimed to have been formed by repeatedly drawing “snakes”, where each snake is a straight segment of identical letters placed either horizontally or vertically.
We are given a fixed sequence of students, each associated with a positive time value. If a student is allowed to pass the exam, they consume that amount of time, and this time accumulates strictly in order.
We are given a connected undirected graph where each edge represents a corridor with a unique energy cost. The Daleks always intend to build a minimum spanning tree, so among all possible spanning trees they will pick the one with minimum total cost, which is uniquely…
We are given an undirected connected graph with weighted edges, where each edge represents a corridor between two locations and has an associated energy value.
We are given a connected undirected graph where each edge represents a Time Corridor with an associated energy cost. The Daleks do not necessarily use all corridors.
We are simulating a probabilistic system that evolves a one-dimensional structure of length l, where a distinguished position called the Doctor’s current universe is fixed inside this structure.
We are given two strings of equal length and we want to force a collision under a polynomial rolling hash. The hash is defined by interpreting each string as coefficients of a polynomial in a base $r$, and then evaluating it modulo a prime $p$.
We are given a set of points on a 2D plane and a fixed radius in Manhattan distance. The task is to choose a center anywhere in the plane, not necessarily at an integer coordinate, and find the largest number of given points that lie within Manhattan distance at most r from…