brain
tamnd's digital brain — notes, problems, research
43815 notes
We are given a process that starts from task 1 and moves through a system that dynamically chooses the next task based on what we previously did. Each task has a score value and also a “jump limit” that affects where the next available task can come from if we skip.
We are given a vending machine with several hidden compartments, each containing some number of cans. There are also the same number of buttons, but the labels are lost, so each button is secretly wired to exactly one compartment via a fixed unknown permutation.
We are given a hidden string of length $n$, built from the first $k$ lowercase Latin letters. We are not given the string directly. Instead, we are given two pieces of information that uniquely determine it.
We are given an array of integers that represents terrain heights along a one-dimensional road. Each position has either surplus sand (positive value) or a deficit that must be filled (negative value).
We are given a collection of machines, and each machine can be configured in one of three productive roles or left unused.
We are given a list of integer sourness values representing candies. Alice is allowed to remove exactly $k$ candies from this list, leaving $n-k$ candies behind.
We are given a tree with one value on each node, representing how many candies sit in that container. The magician is allowed to delete edges, which breaks the tree into connected components.
We are given two axis-aligned squares on a 2D grid. Each square is described by the coordinates of its lower-left corner and a side length.
We are given a rectangular grid that behaves like a small city map. Some cells are roads, some are buildings that block movement, and some contain police officers who look in a fixed direction with limited vision.
We are given a queue of people standing in a fixed initial order from 1 to N. Each person has a workload Ri, representing how much processing time they need at a government office. The office works in rounds.
We are given a binary string consisting only of opening and closing parentheses. From this string, we consider subsequences, meaning we may delete characters without changing the order of the remaining ones.
We are given an interval of integers from a to b, and we need to count how many numbers inside this interval have exactly six positive divisors.
We are dealing with a situation where two baskets of apples exist. One basket contains a known amount $X$, the second contains an unknown positive number $Y$, strictly smaller than $X$.
We are given a rooted tree with vertices numbered from 1 to n, where each vertex except the root has a parent given explicitly. The task is to assign one of k colors to every vertex such that no edge connects two vertices of the same color.
The city is an undirected connected graph where each house is a vertex and each road is an unweighted edge. A postal hub must be placed at exactly one vertex.
We are given a linear sequence of service windows, and at each window there is exactly one possible transformation between documents: if you currently hold a specific document, you may choose to perform a procedure that converts it into another document.
We are given multiple independent scenarios. Each scenario provides three positive integers representing the lengths of three bone fragments left after a fracture.
We are given several independent scenarios. In each one, there are many cookies, each cookie belongs to a type and has a deadline time when it disappears.
We are given a string of lowercase letters representing an SMS message. Pedro is required to shorten it by deleting exactly $n - k$ characters while keeping the relative order of the remaining characters unchanged.
We are given multiple independent test cases. Each test case consists of two strings of equal length, and some positions in both strings may contain unknown characters represented by a question mark.
We are given a grid of size $n times m$ filled with two types of cells, black and white. The goal is to turn every cell into white using a specific operation.
We are given a single integer $n$, and we conceptually evaluate a function $f(n, i)$ for every integer $i$ from 1 up to $n$. Each value of $f(n, i)$ is defined by a procedure that scans integers downward from $i$ to 2 and checks divisibility against $n$.
We start with a collection of positive integers that represent edge lengths of an $n$-dimensional hyper-rectangle. Two aggregate values matter: the sum of all edge lengths and the product of all edge lengths.
There are $m$ marbles, each moving on the real line. Each marble first picks one of $n$ fixed starting positions on the negative side of the axis uniformly at random, independently of all others.
We are asked to construct a compact representation of all binary numbers in a given inclusive interval $[L, R]$. Instead of listing these numbers directly, we must build a directed acyclic graph with a single source and a single sink, where every valid path from source to sink…
We are repeatedly choosing axis-aligned rectangles inside an $n times m$ grid whose corners lie on integer coordinates.
We are given a sequence generated by a linear recurrence modulo a fixed integer $M$. The sequence starts from two initial values $a0$ and $a1$, and every next element is formed by combining the previous two using fixed coefficients $A$ and $B$, then reducing the result modulo…
We are given a sequence of cars that arrive in a fixed order. Each car has a maximum possible speed, and we are allowed to assign each car to one of two lanes. The order of cars inside each lane is the same as the original order, so each lane forms a subsequence.
We are given a square matrix and asked to compute a very specific derived matrix. For every cell $(i, j)$, we conceptually remove row $i$ and column $j$ from the original matrix and compute the determinant of the remaining $(n-1) times (n-1)$ matrix.
We are maintaining a dynamic ordering of $n$ distinct items representing artists in a concert lineup. The lineup is stored as a sequence, and we repeatedly apply operations that depend on positions inside the current sequence. Each operation gives an even number $k$.
We are given a grid with $n$ rows and $m$ columns. For each column $j$, we must choose exactly $aj$ cells to paint black. All other cells remain white. The choices inside each column are free, as long as the number of black cells per column is fixed.
We are given a line of positions representing towers, and for each position we are told how many other towers that tower must be able to “see” or communicate with. Two towers can communicate if, between them, there is no tower strictly higher than both endpoints.
We are given a tree where every operation changes the structure in a very specific way. One type of operation inserts a new vertex and connects it to exactly one existing vertex, effectively creating a new leaf.
We are given a set of distinct integers, and we are allowed to repeatedly apply two operations: bitwise AND and bitwise OR between any two elements. Every time we apply one of these operations, the result must also belong to the set.
We are counting how many multisets of non-negative integers satisfy three simultaneous constraints, but the constraints are expressed in a slightly indirect way. Each multiset has size $n$, so it contains exactly $n$ elements when multiplicities are expanded.
We are given a fridge divided into several independent slots. Each slot already contains some number of cold soda bottles, and each slot also has a fixed maximum capacity.
We are given the complete results of a round-robin tournament among $n$ contestants, but the results are encoded incrementally. For every pair of contestants $i < j$, we know whether contestant $j$ defeated contestant $i$.
The tree describes a system where every node carries a nonnegative “flow value”. Leaves represent independent sources of water and may take any positive integer value. Every internal node represents a confluence, and its value is exactly the sum of the values of its children.
We are simulating a selection process on a circular arrangement of children. The children stand in a fixed clockwise order, and we repeatedly remove one child at a time based on a counting rule defined by a given rhyme, which is just a sequence of words.
We are given three rectangular buildings, each with fixed side lengths, and we are allowed to rotate each rectangle by 90 degrees. The goal is to place all three rectangles on a single larger axis-aligned rectangle such that they do not overlap.
We are given a rectangular chocolate bar made of unit squares arranged in an n by m grid. We repeatedly take a single rectangular piece and split it into two smaller rectangles by making one straight cut, either horizontally or vertically.
Each attendee requests a number of pizza slices, and every requested slice has a specified topping. A pizza shop sells pizzas in only one topping per pizza, and each pizza is always cut into exactly 8 equal slices.
We start with a single string made of lowercase letters. Each letter is not static: it expands into another string according to a fixed substitution table of size 26. If a character is x, it is replaced by the string px.
We are given a tree representing a palace, where each room is a node and corridors are edges. Some rooms are special: exactly the leaves of the tree, those with only one corridor, contain doors. Two groups enter the tree from two different leaves.
We are given a string of digits for each test case and asked to count how many of its contiguous substrings represent integers divisible by 11. Each substring is interpreted as a decimal number, but substrings may start with zero, so leading zeros do not affect divisibility.
We are working with a sequence of strings where each term is constructed from the previous one by describing it in terms of consecutive runs of digits.
We are given a sequence of constraints that come from a hidden permutation of the numbers from 1 to n. Instead of the permutation itself, we receive, for each position i, a value ci that counts how many earlier positions contain values smaller than the value placed at position i.
We are asked to count how many valid “roller coasters” can be formed from a fixed number of segments, where each segment moves one unit horizontally and either goes up or down by one unit vertically.
Each test case gives a shop structured as several independent stacks of items. In each stack, items are arranged in a fixed order from top to bottom, and you are only allowed to access the next item in a stack if you have already bought everything above it.
We start with an empty multiset $S$. Each operation either inserts one occurrence of a number $x$ into $S$, or removes one occurrence of $x$ that is guaranteed to exist.
We are given a long string made of lowercase letters. We are allowed to choose a pattern string T of length three.
We are given a directed graph on up to 500 vertices. Every vertex has the same number of outgoing and incoming edges, and the graph is strongly connected.
We are given a rectangular grid with $n$ rows and $m$ columns, and two kinds of tetromino pieces. Each piece occupies exactly four unit cells, and we are allowed to rotate or reflect each piece arbitrarily before placing it on the grid.
The system is a rooted tree that models an electrical setup. The root is a single socket with a fixed power limit, and every other node is either an electrical device or a power strip.
We are given a scoreboard written in the form A-B, where A represents Alex’s score and B represents the opponent’s score. Both values are single digits from 0 to 9. The system applies a “score illusion” operation that simply swaps the two values.
We are given a sequence of numbers and allowed to perform a fixed number of operations. Each operation chooses a single position and decreases that value by exactly one. After doing this up to k times in total, we want to maximize how many indices become “valleys”.
We are given a single array of odd length. The process runs for exactly half of its length rounded down, and each round always removes the first two elements after allowing a single adjacent swap somewhere in the array.
We are given an array that contains each integer from 1 to n exactly twice, but the order is arbitrary. Think of it as a sequence of 2n labeled cards where every label appears exactly two times. Two players then play a game on this sequence.
We are scheduling actions over a short time horizon of at most 18 steps. At each time step, we must choose exactly one of four skills.
We are working on a one-dimensional number line from 1 to n. On this line there are two types of special points: p starting positions for independent agents (called catworms in the statement), and k teleport portals. There is also a single target position g.
We are simulating a library system where books are stored in a stack and readers interact with the system over a sequence of time-stamped events. The books are initially arranged so that book number 1 is at the bottom and book number n is at the top.
We are tracking how a point light source moves in a horizontal plane while two fixed convex “gates” in space restrict which points on the ground can be illuminated.
We are given a list of positive values $si$, each representing the daily demand of a product type. We must partition these $n$ items into exactly $m$ non-empty groups. For each group $j$, we assign a positive real parameter $kj$. Two quantities are defined from this construction.
We are given a line of n volunteers, each position already partially assigned one of three costume types or left unassigned. The fixed assignments are immutable, while the unassigned positions must be filled using costumes of type a, b, or c.
We are given four kinds of puzzle pieces, labeled A, B, C, and D, with limited quantities of each. Each piece has special edge geometry, and pieces can only be placed next to each other if their touching edges are compatible in a complementary way, meaning one side must “fit…
We are given a sequence of positive integers. For each number $ai$, we must choose a divisor $di$. After making all choices, we look at the product $D = prod di$. Among all possible choices, we only care about those where this product is a perfect square.
We are given a single long string consisting only of uppercase letters. We are allowed to rearrange its characters arbitrarily. After rearranging, we look at how many times the pattern “CCPC” appears as a contiguous substring in the resulting string.
We are given a line of water-filled chambers, each with its own initial water level. All adjacent chambers are separated by gates, and initially every gate is closed, so nothing is connected.
We are given a large rectangular grid where each cell is either usable terrain or blocked terrain. A usable cell can be part of a training course, while a blocked cell cannot.
We are given a directed graph where each node represents an intersection and each edge corresponds to a one-way road in one of the four cardinal directions.
We are given a fixed large interval on a number line, together with several smaller intervals. Each small interval contributes coverage to some portion of the large interval.
We are given a sequential process of “reactions” indexed from 1 to n. At each step i, we assign a value p[i], and this value is constrained from above by a global limit pmax.
We are simulating a bus moving through a sequence of traffic lights. Between intersections, the bus spends a fixed amount of travel time, and at each intersection it may need to wait depending on the current state of a periodic traffic signal.
We are given a sequence of rooms indexed from 1 onward, and we process them strictly in order. While moving through the prefix of rooms, we maintain a single integer value called the current answer. Each room contributes in one of two ways.
We are given an array of integers, and for each element we are allowed to repeatedly turn off any single set bit, but only up to once per bit per element, which is equivalent to saying each number can be reduced to any value obtainable by subtracting a sum of distinct powers…
We start with a row of $n$ positions, each containing a distinct element. A pointer $p$ is also given, initially somewhere between $0$ and $n$, inclusive. We repeatedly remove elements from the current row until nothing remains.
We are given a binary string and a threshold value $K$. The string is considered “bad” if it contains a run of $K$ or more identical consecutive characters, meaning a block like $0000$ when $K = 4$, or $111$ when $K = 3$.
We are given a row of $N$ identical toilets, all initially empty. People arrive one after another, and each person must choose a toilet that is currently empty and also has no occupied neighbor on either side.
We are given a single uppercase string that was produced by a two-step process. First, someone had an original string t. Then they created a second string by taking all distinct letters of t, sorting them alphabetically, and writing each letter once.
We are asked to pay an exact amount using only two coin types, one worth 2 units and the other worth 5 units. The goal is not just to determine whether the sum can be formed, but to construct a combination of coins whose total value is exactly the required amount and uses as…
We are working with numbers formed from decimal strings, but only two digits actually matter: 6 and 9. A number is considered “nice” if it can be interpreted under a very specific ordering rule that effectively treats these two digits as comparable states, and all other…
We are given a permutation of size $n$, meaning each number from $1$ to $n$ appears exactly once but in arbitrary order across positions $1$ to $n$. The task is to transform this permutation into the sorted order where value $i$ sits at position $i$.
We are given a multiset of positive integers written on cards. From these cards, we may select any subset, and the value of that subset is defined as the product of all selected numbers.
We are asked to construct a simple polygon with exactly n vertices placed on integer grid points within a large bounding box.
The task simulates a fixed registration dialogue for a contest team, where the only variable part is the team name.
We are given a sequence of fixed points $C1, C2, dots, Cn$ on a plane and a special point $D$. For each $Ci$, we must choose a circle centered at $Ci$, with radius $ri$.
We are given a connected undirected graph that forms a tree, rooted at room 1. Each room contains a number of exhibits, and the total number of exhibits across all rooms is at most 2 · 10^5. Petya starts at room 1 and must end at room 1.
We are given a fixed 32-bit unsigned integer $a$. For each test case, we must find all 32-bit unsigned integers $b$ such that two quantities become identical when viewed modulo $2^{32}$: the first quantity is the power $a^b$, computed in the usual mathematical sense, and the…
We are given a sequence of bytes, each value initially in the range from 0 to 255. The process repeatedly compresses adjacent pairs by repeatedly selecting a specific ordered pair of values and collapsing all its occurrences in one batch operation.
We are given a collection of independent encounters indexed by $i$. For each encounter there are two time costs, $ai$ and $bi$, corresponding to how much work is required if it is handled by two different fighters.
We are given a sequence of tasks laid out in a line, where each task has an integer difficulty. A character named Vanya has a skill level that starts at a low value and can increase as he completes tasks.
The problem asks us to evaluate a real number that is given in a mixed decimal form, where part of the decimal expansion does not repeat and another part repeats forever.
Each test case describes a very small scheduling system that receives a list of tasks. Every task has an identifier and a priority value, and the system must decide the order in which tasks are executed.
We are asked to split a given number of soldiers into several nonempty groups whose sizes are positive integers summing to $N$.
We are given a tree describing a network of storage rooms. Each room is a node, and each connection is a railroad. The structure is not arbitrary: it has a strong restriction that every node lies within distance at most two from a single central path.
We are given a production system that can be modeled as a directed acyclic graph of jobs. Each job takes a fixed amount of time to process, and moving from one job to another incurs an additional transfer time.
We are given several test cases. Each test case describes an undirected simple graph, but not in the usual edge-list form. Instead, the graph is specified indirectly as a collection of triangles.
We are given a fixed amount of cash and a list of bank deposit opportunities. Each opportunity requires spending a specific amount of money to participate, and in return it yields a fixed amount of interest.
We are given a set of items and a set of boxes. Each box has a fixed capacity $T$. Each item has one of two possible sizes, and these sizes are very “polarized”: every item is either very small (at most $T/4$) or very large (at least $3T/4$).
We are given a set of axis-aligned rectangular slabs placed inside a larger rectangular garden. Each slab has a fixed vertical position, meaning its bottom and top y-coordinates are immutable, but we are allowed to shift slabs horizontally left or right.