brain
tamnd's digital brain — notes, problems, research
43815 notes
We are given an array of nonnegative integers, and we are allowed to append at most three additional numbers. The goal is to make the final multiset of numbers satisfy a very specific algebraic condition: the sum of all elements must equal twice their bitwise XOR.
We are given an unknown array of distinct integers. We cannot read it directly. Instead, we can query any subset of exactly k positions, and the device returns the position and value of the element that would rank as the m-th smallest among those k values.
We are given a permutation of the numbers from 1 to n. The goal is to understand how expensive it is, in terms of adjacent swaps, to force the numbers 1 through k to appear as a contiguous block in increasing order somewhere inside the array.
We are given a multiset of applications, each belonging to a category. The only thing that matters about a category is how many apps it contains, so the input can be compressed into frequencies of each distinct category. We must place all apps into “screens”.
We are maintaining a text editor that supports three kinds of operations: moving a cursor left or right along a growing line, and overwriting the character at the current cursor position.
We are given a line of positions from 0 to n+1. A group of soldiers starts at position 0 together with the player character. Each soldier has a strength value, and traps placed along the line may kill soldiers whose strength is too low when they enter certain positions.
We are given a complete system of lockers where each locker belongs to one person and has a weight. We are allowed to install exactly $m$ undirected connections between distinct lockers. Each connection between locker $u$ and $v$ costs $au + av$.
We are given a hidden permutation of size $n$, but we never see it directly. Instead, we see every consecutive block of three elements from that permutation. Each block is then scrambled internally, and all blocks are shuffled among themselves.
We are given a tree with $n$ nodes, where each node initially holds a unique label from $1$ to $n$. Someone then performs a process that is equivalent to choosing an ordering of all edges and, for each edge in that order, swapping the labels of its two endpoints.
We are given an undirected graph on vertices labeled from 1 to n, and we are allowed to add edges. The goal is to make the graph satisfy a very specific reachability constraint that depends on the natural ordering of vertices.
We are given a one-dimensional yard of length $N$, where each position is either usable soil or blocked by a rock. We want to place tiles on this line to maximize total “ghost repelling power”.
We are given several rectangular plots of land, and we want to place two identical rectangular buildings of size $A times B$.
We are given a tree with up to 4000 nodes, and we are allowed to pick a single node and remove it. Removing a node splits the tree into several connected components, each of which is itself a tree. The number of components equals the degree of the removed node.
We are given three groups of students determined by their preferred programming language. The task is to split all students into exactly three practice groups. The only restriction is that a single group is not allowed to contain both Assembler fans and C++ fans at the same time.
We are given a tree where each vertex carries a positive weight. The task is to select a subset of vertices that maximizes the sum of chosen weights, but with a strict geometric restriction: any two selected vertices must be more than $k$ edges apart in the tree.
We are given a building with floors from 1 to n. Moving between adjacent floors can be done in two different ways: stairs or elevator. Stairs have per-floor costs a[i], and elevator has per-floor costs b[i] plus a fixed overhead c every time you start an elevator ride.
We are given a collection of integer intervals on a number line. Each interval represents coverage over all integer points inside its range. A point becomes problematic if it is covered by more than $k$ intervals at the same time.
We are given several independent queries. Each query provides a large integer $n$, and we must output the smallest integer $m ge n$ such that $m$ can be expressed as a sum of distinct powers of 3.
Each child starts with exactly one book, and every day all books are passed simultaneously according to a fixed permutation. If a child i gives their book to p[i], then after one day the book moves one step along this directed edge.
We are working with numbers that can be decomposed using a very specific building system: powers of three, where each power can be used at most once.
We are given a system where each child initially holds a unique book, and every day each book is passed to another fixed child according to a permutation. After one day, every book moves once; after two days, it moves again under the same rule, and so on.
We are given a string made only of opening and closing brackets. Think of it as a circular sequence, where we are allowed to rotate it in any way.
We are given a multiset of stick lengths, and we must arrange all of them into a polyline starting at the origin. Each stick becomes one segment of this polyline, and every segment must be axis-aligned, meaning it is either horizontal or vertical.
The game can be viewed as a directed line of states arranged along a fixed serpentine path on a 10 by 10 grid. Each cell corresponds to a position on this path, starting from the bottom-left cell and ending at the top-left cell.
We are given a set of cities placed on a plane. Each city can be “powered” in one of two ways: either we directly build a power station in it, or we connect it (directly or indirectly through other cities) to a city that already has a power station.
We receive a string that is claimed to be produced by a slightly broken writing machine. The machine normally prints each spoken letter as itself, but two special letters behave differently: if the user says w, the machine writes uu, and if the user says m, it writes nn.
We are given two groups of runners, each group containing the integers from 1 to n. We must arrange each group into a permutation, one for the first track and one for the second track.
We are given a list of integers and a limited budget of unit operations. Each operation lets us pick a single element and move it by exactly one step, either up or down.
We are given a circular arrangement of cells, each cell holding either white or black. The system evolves in discrete steps, and each cell updates its color by looking at a fixed local neighborhood: itself and its two adjacent cells on the circle.
We are given a season summary for a football team, but instead of individual match results, only aggregated information is known. The team played exactly $n$ matches and accumulated a total of $p$ points.
We are given a building with two parallel rows of rooms, one row per floor, and each row has $n$ rooms arranged left to right. From any room, movement is allowed horizontally to adjacent rooms on the same floor.
Polycarp has two types of work tomorrow: writing lectures and drawing during practical classes. For lectures he must use pens, and each pen can be used for a limited number of lectures before it dries out.
We are given two strings of equal length, and we are allowed to perform exactly one swap operation. The swap is constrained in a specific way: we pick one position in the first string and one position in the second string, then exchange those two characters.
We are given two strings of equal length, and we are allowed to repeatedly fix them using a very specific operation: pick one character from the first string and one character from the second string, and swap them.
We are given a complete undirected graph on $n$ vertices. Every pair of vertices is connected, but edges come in only two possible weights: either 0 or 1. Among all $binom{n}{2}$ edges, exactly $m$ of them have weight 1, and every other edge implicitly has weight 0.
We are given multiple connected graphs, each with up to half a million vertices and edges in total across all test cases.
We are given a grid with exactly two rows and n columns. Every cell contains a value, and we are allowed to permute these 2n values arbitrarily between the cells.
We are given a system of $n$ people, each of whom owns exactly one cat, forming a natural pairing between person $i$ and cat $i$.
We are given a bracket string and we are allowed to perform exactly one swap of any two positions, possibly the same position.
We are given a row of seats indexed from left to right, and each seat has exactly one passenger. Every passenger has a planned time when they become ready to go to a water tank located just left of seat 1.
We are given a fixed string that we type repeatedly using a one-finger keyboard. The keyboard is defined by choosing a permutation of the first $m$ lowercase letters, and this permutation places each letter at a unique position on a line.
The system can only run if it never becomes empty, meaning at every minute it must contain at least one liter before consumption happens. It continuously drains one liter per minute for a total of m minutes, and its storage capacity is capped at c.
We are given a binary string consisting only of the characters A and B. Our task is to count how many of its contiguous substrings are “good” under a specific structural condition involving palindromes.
We can think of the cliff as a vertical line of heights from 1 up to h, with a special starting platform at height h. Some of these heights already contain usable platforms, while the rest are empty. You are standing at the top platform and want to reach ground level 0.
The corridor can be seen as a number line where all monsters start strictly on the positive side. Each monster is a point on this line, and Ivan repeatedly performs an operation that chooses a center point and affects every monster depending on whether it lies to the left, at…
We are given two binary strings of equal even length, and we are only allowed to modify the first string. The only operation available is somewhat unusual: we pick a prefix of even length and reverse that prefix in place.
We are given a circular arrangement of $n$ people, each holding some number of stones. The total number of stones is divisible by $n$, so there exists a target value $T = frac{sum ai}{n}$ such that the goal is to end with every position holding exactly $T$ stones.
We are given a circular playlist of tracks, each with a numeric “coolness” value. Starting from any chosen track, we keep listening forward in cyclic order, revisiting tracks as needed. While listening, we maintain the maximum coolness seen so far.
We are given a grid where some dominoes are already placed. Each domino always occupies exactly two adjacent cells. The placement has a special restriction: no row or column is allowed to contain cells from two different dominoes.
We are given a list of integers representing rating changes from a contest. The total sum of all these changes is exactly zero, meaning gains and losses perfectly balance out before any modification. The task is to transform each value independently into a “halved” version.
We are given a set of points in three-dimensional space, and we must repeatedly delete them in pairs until nothing remains. The restriction is not about distance or parity, but about geometry of axis-aligned boxes. At any moment, we pick two remaining points.
We are given an even number of distinct points in 3D space. The task is to repeatedly remove points in pairs until none remain.
We are given a line of $n$ boxes and a single token hidden in one of them. The game proceeds in $m$ rounds. In each round Alice points to a box index $ai$, trying to locate the token.
We are given a connected undirected graph with a special structure: it is a cactus, meaning every edge belongs to at most one simple cycle. On this graph, each vertex independently survives with probability $1/2$, otherwise it is deleted together with all incident edges.
We are given the integers from 1 to $n^2$, each representing a lab positioned by height, where smaller numbers are lower and larger numbers are higher.
We are given a rectangular grid with some blocked cells. Starting from the top-left corner, a token must move through the grid so that every unblocked cell is visited exactly once.
We are given three piles of stones. From these piles, Alice can repeatedly perform two kinds of moves. One move consumes one stone from the first pile and two stones from the second pile. The other move consumes one stone from the second pile and two stones from the third pile.
We are simulating a dynamic list of conversations ordered by “recency of appearance on screen”, with a hard cap on how many conversations can be shown at once. Each incoming message is tied to a single friend ID, and every ID corresponds to exactly one conversation.
We are maintaining a string of lowercase letters under two kinds of operations. One operation modifies a single position in the string, changing its character.
We are given a grid of size (h times w), initially completely empty, and two sets of constraints that describe how far blocks of filled cells must extend from the top and from the left.
We start with a perfect binary tree of height n, meaning every internal node has exactly two children and all leaves sit at the same depth. This tree contains exactly 2^n - 1 nodes and has a very rigid recursive structure: every subtree is itself a perfect binary tree.
We are filling an $n times n$ grid with integers from $1$ to $k$. The restriction is not about individual cells, but about structure: every row must contain at least one occurrence of the value $1$, and every column must also contain at least one occurrence of $1$.
The input describes a finite rectangular snapshot of an otherwise infinite grid of trees. Each cell is either burned or intact, and the grid fully contains all burned cells. Outside the grid, everything is guaranteed to be unburned.
We are given an array where each position stores a pile of blocks. At position i, there are ai identical blocks stacked. One operation consists of choosing some set of positions and removing exactly one block from each chosen position.
We are given a fixed answer key for a multiple-choice test of length n, where each question has a known correct option. We are also considering every possible way to fill in answers for the test, where each position can take any value from 1 to k.
We are given a fixed array of integers and many queries. Each query asks us to imagine picking exactly $k$ elements from the array while preserving their original order. Among all such subsequences of length $k$, we first want the one with the maximum possible sum.
We are given a sequence of parentheses and are allowed to apply an operation that reverses any contiguous segment.
We are given a non-decreasing array q, which is claimed to be produced from some hidden permutation p by taking prefix maxima. At every position i, q[i] equals the largest value among the first i elements of p.
We are given a sequence of numbers and, for each query, we must imagine selecting exactly k elements from this sequence while preserving their original order. Among all such subsequences, we first care about maximizing the sum of chosen values.
We are given a rooted tree where vertex labels already obey a strict ordering constraint: every node except the root has a parent with a smaller label.
We are given a sequence of positive integers and asked to count how many pairs of indices produce a product that is a perfect k-th power. In other words, for two distinct elements $ai$ and $aj$, we want to know whether their product can be written as $x^k$ for some integer $x$.
We are given a positive target number $n$. We also fix an integer $p$, which shifts a family of numbers of the form $2^x + p$, where $x ge 0$. Each such value is a single “building block”, and we are allowed to reuse the same block any number of times.
We are given an array and a peculiar cancellation process that behaves like a stack with annihilation. We scan the array from left to right, maintaining a stack. When we see a value, if the stack top is different, we push it.
We are given a collection of logs, each with an integer length. From these logs we are allowed to cut pieces, but we are not allowed to glue pieces together. The goal is to assemble a rectangular raft structure that requires two kinds of side lengths, call them x and y.
We are given a tree where every edge has a weight. The task is to assign colors to vertices under a very specific rule: each vertex receives exactly $k$ colors, and any particular color can appear at most twice across the entire tree.
Each query gives two strings of the same length. You are allowed to repeatedly apply an operation on either string: pick two neighboring characters and overwrite one with the other.
We are given a number of matches and we want to arrange them into a valid arithmetic equation of the form “a + b = c”, where each number is strictly positive.
Something went wrong. If this issue persists please contact us through our help center at help.openai.com.
We are filling an $n times n$ chessboard where every cell must contain either a white knight or a black knight. The goal is not about placing pieces to avoid attacks, but rather to maximize how many pairs of opposing-colored knights can attack each other under standard knight…
We are given a sequence of fence boards, each with an initial height and a cost per unit increase in height. One operation lets us pick a board and increase its height by exactly one, paying its per-unit cost each time. We can repeat this any number of times for any board.
We are given a binary string made of two types of characters: empty cells denoted by . and blocked cells denoted by X. Two players alternate turns, starting with Alice.
We are given a fixed set of points in the plane, which we can think of as antennas. For each query, there is an unknown integer point in a bounded grid, and we are told the squared distances from that point to all antennas.
We are given a permutation of length $n$. From this permutation, a binary tree is constructed in a deterministic way: the smallest value in a segment becomes the root of that segment, and the remaining elements are split into the left and right subsegments around it.
We are given a finite set of positive integers, but the structure we build from it is infinite. Every integer is a vertex, and each number in the set is interpreted as a “distance type”.
We are given a connected undirected graph where each vertex represents a city and each city has a fixed value. Alex starts from a specific city and walks through the graph by traversing edges, with one restriction: he is not allowed to immediately traverse back along the same…
We are given a multiset of letters that originally came from writing several binary words, where each word is either the string "zero" representing digit 0 or "one" representing digit 1.
We are given three ingredients that define a transformation problem on a binary grid. First is an initial $N times N$ board of lights, each cell either on or off. Second is a target $N times N$ configuration we want to reach.
We are given a network of spaceports connected by undirected shuttle routes. Each spaceport belongs to exactly one of three planets labeled X, Y, or Z. Every shuttle connects two different spaceports, and only connections between different planets exist.
We are given an undirected graph where each edge represents a wormhole between two planets and has a repair cost.
We are given an array of values, and each query asks us to evaluate a very specific symmetric polynomial built from a transformed version of that array. For a fixed number $q$, we first convert every element $ai$ into $bi = q - ai$.
We are given an undirected graph with $N$ vertices and exactly $N$ edges, and no pair of vertices is connected by more than one edge.
We are given a set of non-overlapping convex polygonal regions in the plane. Each polygon represents a warehouse. Bob stands at the origin, and for every point inside any warehouse we want to know whether Bob can “see” it using a special optical device.
We are moving through a grid from the top-left cell to the bottom-right cell, and each second we can only move either one step to the right or one step down. Any valid path is therefore a monotone path with exactly $N + M - 2$ moves.
The graph starts empty, but it is continuously modified by two types of operations. The first operation toggles an edge between two vertices, and the second operation asks whether two vertices are connected in the current graph.
We are given a character with two base attributes: strength and intelligence. We are also given a pool of extra experience points that must all be distributed. Each point can increase either strength or intelligence by exactly one unit.
We are given an array of integers that changes over time, and we are repeatedly asked to inspect a chosen segment of this array.
We are given a directed graph where each edge is fixed in advance, and we must assign a color (an integer label) to every edge. The constraint is not about vertices but about directed cycles: if you look at all edges of a single color, they must not contain any directed cycle.
We are given a collection of sword types, each type having some remaining count after a theft. For each type $i$, the value $ai$ tells us how many swords of that type are still present in the basement. Originally, every type had the same unknown quantity $x$.
We are given a binary string made only of the characters a and b, and its length is guaranteed to be even. The task is to transform this string using the minimum number of single-character flips so that every prefix whose length is even contains exactly the same number of a…
We are given a tree with $n$ vertices, where each vertex represents a square in a pedestrian network. Each vertex must be assigned one of $k$ colors.