brain
tamnd's digital brain — notes, problems, research
43815 notes
We are given a set of points on a grid, each point having an integer position and a weight. For any rectangle anchored at the origin and defined by coordinates $(a, b)$, we look at all points whose $x$-coordinate is at most $a$ and whose $y$-coordinate is at most $b$.
We are given a tree on $n$ nodes where each edge has a weight. Over time, the tree is modified in a very controlled way: each day removes exactly one existing edge and adds exactly one new edge, and the structure always remains a tree.
We are given several short strings, and for each one we must decide whether it can be rearranged to form the word “hola”. Rearranging means we are allowed to permute the characters freely, but we cannot add or remove any character.
We are working with a rectangular grid that starts completely empty in the sense that every cell initially holds zero. Then we perform a sequence of operations.
We are given an array and we only care about its prefixes. For each prefix, we must decide whether it has a special property called “good”.
We are given multiple queries. Each query describes two integers $n$ and $k$, and asks us to work with the number formed by selecting $k$ distinct elements from a set of size $n$, ordered, which is the falling factorial $$P(n,k) = n cdot (n-1) cdot dots cdot (n-k+1).
We are given several test cases. Each test case describes a set of monsters placed on a number line and a set of weapons. Every monster sits at a single integer coordinate, and multiple monsters can share the same position.
We are working with a complete undirected graph on $n$ countries, but some edges have been destroyed. After these removals, we are left with a simple undirected graph.
We are given a single positive real number written as a string with a decimal point. The task is to compute its floor, meaning the greatest integer that does not exceed the value, and output that integer without any decimal part.
We are given an array of non-negative values representing rewards earned at each level of a game. For any contiguous segment starting at position l and ending at r, the player’s performance score is computed as the rounded average of that segment: take the sum of values on…
We are given a one-dimensional garden represented as a line of m cells. Several existing slabs are already placed along this line, each occupying a continuous interval.
We are given a collection of cards, each card carrying two numbers: one written on its front side and one on its back side.
We are given a collection of animals, each described by its species name and a numeric influence value. Among these animals, we must form a leadership council by selecting any subset, but the selection is constrained by a single special species called pigs.
We are given a fixed permutation $p$ of size $n$. We are allowed to choose another permutation $q$ of the indices $1$ to $n$.
We are given a permutation of length $n$. Jesse is allowed to split the positions into two nonempty groups. One group is colored yellow, the other blue.
We are counting how many pairs of arrays $a$ and $b$, both of length $n$, can be formed using values from $1$ to $m$, such that a specific symmetry condition holds between every pair of positions. Pick any two indices $i < j$.
We are given an integer X, and we consider all multisets made of powers of two such that their sum equals X. Each multiset is just a collection like {1, 1, 2, 8, 8} whose total sum is X. From each such multiset S, we imagine splitting its elements into two groups S1 and S2.
We are given an $n times n$ grid where each cell contains a value between 0 and 4. We must choose exactly one cell from every row and every column, which means we are effectively selecting a permutation of columns for the rows.
We are given an even number of students, specifically 2n, each with a numeric chemistry skill. The teacher must split them into n disjoint pairs, so every student belongs to exactly one pair.
We are given a weighted tree with up to half a million vertices, and each edge carries a weight that can change temporarily during each query. For every query we first modify exactly one edge weight, and then we are allowed to choose $k$ simple paths in the tree.
We are given a convex polygon with vertices ordered counterclockwise. Each vertex carries a value, and we are allowed to pick any subset of vertices.
We are given several test cases. Each test case describes a complete graph, but the graph is not defined on individual vertices directly. Instead, vertices are grouped by colors. For each color i, there are ai identical vertices.
We are given a string and we can rotate it cyclically to the left by some number of positions. A left shift by $d$ means taking the substring starting from position $d$ to the end and attaching the prefix $0 dots d-1$ at the end.
We are given a line of positions indexed from 0 to n − 1. Initially every position is marked red. Over time, we repeatedly pick one position and permanently flip it to blue. After each flip, we look at a collection of intervals, called sensors.
We are given an integer array and we are allowed to split it into exactly $k$ contiguous non-empty segments. Each segment contributes its sum, but the contribution is weighted by the segment’s position from the left.
We are given several test cases. In each test case, we receive a list of strings. We need to count how many triples of indices $(a, b, c)$ with $a < b < c$ satisfy a special “triangle” condition defined using string concatenation and lexicographic comparison.
We are given several printing machines that run independently but contribute to the same shared goal: producing at least $k$ total copies of a document. Each printer does not work at a constant long-term rate in a simple linear way. Instead, it follows a cycle.
We are given a convex polygon representing a pizza, and a circular region inside it representing a pineapple topping.
We are given a graph of cities connected by undirected roads, where each road belongs to a company and has a length. The structure is fixed, but movement is constrained by a sequence of tickets that must be used in order.
We are given a string and we are allowed to cyclically shift it. After choosing a shift, we look at the resulting string arranged in a circle, meaning the last character is considered adjacent to the first.
We are asked to build a permutation of numbers from 0 to n minus 1 such that when we read it from left to right, the XOR of every prefix is strictly positive.
We are given a sequence of events on a number line of integer cells. Each event is a coin that appears at a specific time and position, and it exists for exactly one second.
We are given several contests. Each contest has a “star rating” and a vector of properties. The score of a contest is simply the sum of all its properties. Some property values are already fixed, while others are missing and marked as unknown.
We are working on a very large grid, but only a sparse set of cells are relevant: some cells contain castles and some contain obstacles. Two castles can “see” each other if they lie in the same row or column and nothing important lies strictly between them.
We are given a rectangular board with $n$ rows and $m$ columns. Each cell is a hexagon in a honeycomb layout, which means every cell can touch up to six neighbors instead of the usual four in a grid.
We are given two rectangles. One represents a car trunk with sides a and b, the other represents a folded stroller with sides c and d. The stroller can be rotated by 90 degrees, meaning we can swap its sides, but we cannot deform it.
We are given a deterministic sequence of integers generated by repeatedly multiplying the previous value by a fixed factor and then taking a modulo. The sequence starts from a given initial value and produces exactly $n$ numbers.
We are given a database of questions, each question having a computed difficulty score derived from how many teams answered incorrectly relative to attempts. After scaling by 10000 and flooring, each question becomes a single integer rating.
We are given a very large grid, but only a small number of cells inside it are marked. From this state, we are allowed to choose a single empty cell and pick one of four cardinal directions.
We are given a binary grid that represents an image after a morphological operation called dilation has been applied. Each cell is either black () or white (.).
We are given several independent instances of a Nim game. Each instance consists of multiple piles, and a move consists of selecting one pile and removing a positive number of stones from it.
We are given a very specific geometric bug to exploit. A point is fixed at the origin, and we are asked to construct simple lattice polygons that truly enclose this point strictly inside them. “Strictly inside” means the origin cannot lie on any edge or vertex.
We are given a set of vertical line segments in the plane, each anchored on the x-axis and extending upward. Concretely, the i-th grass is a segment from $(xi, 0)$ to $(xi, yi)$, and all x-coordinates are distinct.
We are given a univariate polynomial $A(x)$ and we build a multivariate polynomial $D(x1, dots, xm)$ by taking two ingredients. The first is a copy of $A$ applied independently to each variable, so every variable contributes a factor $A(xi)$.
We are given a rooted binary tree with up to 300,000 nodes. Each node carries a weight a[i], and each node also has a target value b[i]. For every node i, we look only at the nodes on the path from the root to i, including i itself.
We are given two integers, a target sum s and a constraint value x. The task is to construct an array whose elements add up exactly to s, while every element in the array must be coprime with x. Coprime here means that each element shares no common prime factor with x.
We are given a target string $s$ and a fixed number of seconds $m$. Starting from an empty string $t$, each second we apply exactly one operation.
We are given a binary string and a parameter $k$. For each value of $k$ from $1$ up to $lfloor n/2 rfloor$, we are allowed to repeatedly apply a transformation that acts on a window of length $2k$.
We are given items that must be washed using one of three washing programs, A, B, or C. Each laundry load uses exactly one program and can contain at most $k$ items. Every item does not have a single fixed program, instead it comes with a set of allowed programs.
We are given a collection of $n$ jigsaw puzzles. Each puzzle has two attributes: the number of pieces it contains and a difficulty value that can be positive or negative. A “gift” is defined as choosing any subset of these puzzles.
We are given a collection of university names, a set of rivalries between some pairs of universities, and a sequence of news articles. For each article, we must decide whether it is “balanced enough” or whether it would anger at least one coach.
We are given a finite collection of cards, each card representing a unary operation on a shared integer state. Each move, a player picks an unused card and applies its operation to the current value. The players alternate until all cards are consumed.
We are working on a one-dimensional alley of positions from 1 to n. At certain positions we may place or remove lamps, each lamp having a positive brightness value.
We are given a collection of cuboid-shaped books, and each book can be freely rotated in 3D before being placed. All books must be placed upright on a shelf in a single horizontal row, meaning each book contributes exactly one rectangular footprint on the shelf surface, and…
We are given a social network of people where friendships form an undirected graph. The aliens cannot abduct individuals independently.
We are given a line of positions from 1 to N, and we must assign each position a value between 0 and K. On top of this array, there are M constraints. Each constraint specifies a segment [l, r] and demands that the sum of values inside that segment is exactly K.
We are simulating a probabilistic turn-based game where two players repeatedly play rock-paper-scissors, but the outcome does not immediately determine the winner.
We have a set of $N$ clubs whose scores are already fixed, and one additional club called RUN whose score we are free to choose at the end.
We start with an $N times N$ grid where every cell is initially white. The grid is then modified through a fixed sequence of operations, each operation recolors either an entire row or an entire column to black or white.
We are asked to construct a set of coin denominations that interact with the greedy change-making strategy in a very specific way. For any amount, the greedy strategy always picks the largest coin not exceeding the remaining sum.
Each test case gives two arrays of scores, one belonging to Arturo and one belonging to Benito. For every index we have a pair of values, but the pairing is completely unknown: we are free to assign Arturo’s numbers and Benito’s numbers to different contest problems in any…
We are given a line of stones, each stone having either a fixed color already assigned or being unpainted. Our task is to fill in all unpainted stones using a palette of c colors so that no two adjacent stones share the same color.
We start with an empty grid of size $n times m$, where every cell is initially white. The only way to modify the grid is to choose whole rows or whole columns and paint them completely black.
We are given several independent test cases. Each test case provides a list of positive integers. The task is to determine whether there exists at least one element in the list that can divide every element in the same list, including itself in a trivial way.
We are given a segment on a line, marked by two fixed points. Inside this segment there are several objects, each placed at a distinct coordinate. Every object is initially facing either left toward the first mark or right toward the second mark.
We are given a list of integers and asked to verify a very specific structural property: every pair of numbers in the list must share exactly the same greatest common divisor.
We are simulating a small economy that evolves over a fixed number of days. Alice starts with a single chicken that already produces eggs every day after it has finished its initial sleep requirement.
We are given a set of positions on a number line where eggs are placed. We are also allowed to place a fixed number of heat lamps, each at an integer coordinate.
We are given a collection of eggs, where each egg requires a specific amount of time to be fully cooked. Jacob has a fixed total time budget and a single pot, which means he can only cook one egg at a time without overlap.
We are given a deterministic process that generates a sequence of egg orientations. Each egg has a state in the range from 0 to 5, and the sequence starts from a fixed initial state for the first egg.
We are looking at a dynamical system over the finite field $mathbb{F}p$. We pick a starting point $x0$, then repeatedly apply a randomly chosen polynomial function $f : mathbb{F}p to mathbb{F}p$.
We are given a system that evolves over a limited number of days. Initially there is exactly one chicken and a stock of eggs that starts at zero.
We are given a one-dimensional landscape represented as an array of heights. Each index is a position in a mountain range, and the height value is the elevation at that position.
We are given a set of integers from 1 to n, each appearing exactly once, and we must arrange them in some order. From this arrangement, we look at contiguous segments and focus on those segments where values increase by exactly 1 at every step.
We start with a population of AI bots arranged in levels. Initially there are only level-n bots, and there are k of them. Time advances in fixed 5-minute steps, and at each step every bot performs exactly one action.
We are given several independent test cases. Each test case is a sequence of integers representing a row of cards.
We are asked to count how many integers in the range from 0 up to a given large number satisfy a positional digit rule. The rule depends on writing each number in decimal and looking at its digits from left to right using 1-based indexing.
We are given a set of coin denominations that follow a very structured pattern: each coin is a number consisting entirely of digit 1, and the lengths grow in a special way. So we get values like 11, 111, 1111, 11111, and so on, continuing indefinitely.
The problem describes a profit process that grows in a very structured way. On the first day Harsh earns nothing, and each next day his daily gain increases by exactly one more unit than the previous increase.
We are given a directed network of cities connected by roads, where each road has a non-negative cost representing how many monsters Phoenix must fight if he travels along it. Phoenix starts at city 1 and must reach city n using any sequence of directed roads.
We are given a string and we are allowed to rearrange its characters arbitrarily. After rearrangement, we want to split the resulting string into several consecutive blocks. Every block must be a palindrome and all blocks must have the same length.
We are given a long sequence of integers, each value lying between 1 and 18. From this sequence we are allowed to pick two contiguous subarrays, and then concatenate them in order to form a new sequence.
We are given a connected undirected graph with $n$ islands and $m$ tunnels. Each island has a cost $ai$, representing the energy needed to perform a ritual if you are currently on that island. Each tunnel connects two islands and has a travel cost.
We are given two permutations of the numbers from 1 to n. The task is to count how many sequences are simultaneously subsequences of both permutations, under a very specific structural constraint.
We are building a simplified membership system that behaves like a hash-filtered set with multiple hash functions. The system stores elements in a binary array of size n, initially all zeros.
We are given a target pattern string $s$ and we want to build strings of length $n$ using lowercase English letters. Inside each constructed string, we look for occurrences of $s$ as contiguous substrings.
We are given a line of n positions, each holding a 15-bit non-negative integer. We are allowed to perform an operation on any adjacent pair of positions.
We are given a tree that comes from a transformation process applied to some directed graph. The process runs a depth-first search, assigns discovery times, maintains a stack of vertices, and whenever a specific low-link condition is met it creates a new auxiliary node and…
We are given a collection of signals. Each signal has two numeric attributes: an energy value and a frequency value. The task is to consider every ordered pair of signals and accumulate a cost defined by a product of two independent parts.
We are given a tree of cities. Each query activates a consecutive block of “movie options”, and each option corresponds to selecting all cities along the unique tree path between two given endpoints.
We are given a set of points on a 2D plane, each representing a coin. A snake starts at the origin and can only move in two directions: right and up, meaning in whatever coordinate system we choose, its x coordinate and y coordinate never decrease along its path.
We are given a small list of numbers, each of which is a power of two. That means every element can be written as $2^{ki}$ where the exponent $ki$ is a small non-negative integer.
We are given a convex polygon that represents an initial infected region on an infinite plane. Over time, the infection expands outward in a very structured but not explicitly geometric way: the only guarantee is that the “shape family” preserves radial ordering from the…
We are given a one-dimensional board of size $N$, where a token starts at cell 1 and wants to reach cell $N$. Between these endpoints, some cells contain “snakes” that push the token left by a fixed amount whenever it lands there.
We are given two rooted binary trees on the same set of vertices labeled from 0 to N−1. The first tree is the initial configuration, and the second tree is the target configuration.
We are given a construction made of $N$ independent parts. Each part has a required standard weight $si$, and the current configuration has weight $ai$.
We are given an array-like buffer of length $2N$, but $N$ is unknown. The structure of this buffer is very specific: the first $N$ positions store nonzero bytes, while the remaining $N$ positions store zeros.
We are given a collection of items, each with a positive size, and a fixed number of scouts. Each item must be assigned to exactly one scout. A scout can carry at most two items, and the load of a scout is the sum of the sizes of items assigned to them.
A rope is initially stretched from the origin to a fixed point on the positive x-axis. We then start rotating this rope counter-clockwise around whichever point is currently acting as its pivot. At the beginning, the pivot is the origin.
We are given a social graph of employees where edges represent mutual acquaintance. The task is to split all employees into three groups such that no two people who know each other end up in the same group.