brain
tamnd's digital brain — notes, problems, research
41650 notes
We are given a permutation of integers from 1 to n and can perform a specific type of swap: for any index i from 1 to n/2, we can swap the element at position i with the element at position 2i.
We are given a sequence of numbers from 1 to 6, and we are allowed to change any element to any other value from 1 to 6. The goal is to transform the sequence so that every pair of neighboring elements behaves like valid transitions on a standard dice.
We are given several very small collections of integers, each collection containing at most five numbers, and we are asked whether we can pick some non-empty subset whose product is exactly 67. Each test case is independent.
We are asked to construct a graph with a given number of vertices n and edges m such that it cannot be split into two parts where the sums of degrees of each part are equal. The graph must be simple, with no loops or multiple edges.
We are given a source string s and a target string t. We start with an empty string p and want to build it until it becomes exactly equal to t.
We are given a source string s and a target string t. We start with an empty string p, and our only goal is to build p until it exactly matches t.
We are given a string consisting of round brackets "(" and ")", and square brackets "[" and "]". The string has even length.
We are asked to reconstruct a hidden directed acyclic graph (DAG) by interacting with a system that enumerates all paths in lexicographic order. Each query allows us to ask for the $k$-th path.
We are given two integers, $p$ and $q$, representing a fraction $frac{p}{q}$. Alice and Bob play a turn-based game where on each turn a player can decrease $p$ by 1 (if $p 0$) or decrease $q$ by 1 (if $q 1$). Alice goes first.
We are given a directed acyclic graph with up to 15 vertices. The edges are unknown, but we are allowed to probe the graph through an oracle. Each query asks for the k-th path in the lexicographically sorted list of all valid directed paths in the graph.
We are given an array and we want to count pairs of positions where a very specific relationship holds between the values at those positions and their distance in the array.
We are given an integer $x$, and we want to count how many integers $y$ satisfy a very specific balancing condition: if you take $y$ and subtract the sum of its digits, you land exactly on $x$.
We start with a very constrained system: one array begins as all ones, another array is all zeros, and a third array c provides a sequence of target values between 1 and 50.
We are given an array of length $n$ where each element is an integer from $-1$ to $n$. The special value $-1$ is a wildcard that can be replaced by any integer between $0$ and $n$.
We are given an integer array and asked to count subsequences that are "self-produced." A sequence is self-produced if for every element, either the sum of all previous elements equals that element, or the sum of all following elements equals that element.
We are asked to find positions on a rectangular grid where we can place a jammer such that it always intercepts a robot moving from the bottom-left corner $(0,0)$ to the top-right corner $(n,m)$, while remaining invisible at the start and end points.
We are given an initial array $a$, and we want to imagine building a longer array $b$ that contains all elements of $a$ in order (not necessarily consecutively), but between every pair of adjacent elements in $b$, the values must differ by exactly 1.
Alice and Bob play a three-round card game where each round has independent scores between 0 and a maximum k. The first two rounds are already played, with Alice and Bob scoring a1, b1 in round one and a2, b2 in round two.
We are given two arrays, each sorted in non-decreasing order, and each having an odd number of elements. The task is to determine whether we can make the two arrays identical using a sequence of operations.
We are asked to build a grid with exactly two rows and some number of columns. Each cell can either contain a mine or be empty.
We start with two stacks of blocks. The first stack has height a, the second has height b. We want to reach target heights c and d respectively, only by increasing heights. There are two allowed operations. The first operation increases exactly one of the towers by one block.
We are given an array of positive integers, and we define a number as special if the power of 6 that divides it is strictly greater than the power of 7 that divides it.
We are given a starting integer $x$ and a list of $n$ operations, each of which modifies $x$ by either addition, subtraction, multiplication, or division by a positive integer. The twist is that the operations are applied in a random order: all $n!
We are given a collection of particles, each with an energy value and a reactivity limit. A particle's reactivity determines the maximum number of other particles that can coexist with it in the reactor.
We are given a permutation arranged on a line and two special cutting points, called portals. These portals divide the array into segments and define where elements can be extracted from and reinserted.
We are given an array of positive integers and two players who alternate turns, starting with Alice. The game evolves by either ending immediately if the current array is already non-decreasing, or by performing a single allowed operation on a chosen element.
We are given a circular table with n players, each having a certain number of dishes they must eat. Players take turns sequentially around the table, and during a player’s turn, if they have any dishes left, they must eat exactly one.
We are given a string consisting of lowercase letters, and the game involves repeatedly replacing pairs of equal letters with asterisks, provided that all characters between them have already become asterisks.
We are given several independent test cases. In each one, we start with a short array of positive integers and repeatedly remove elements until the remaining array is sorted in non-decreasing order.
We are given a grid of size $n times n$ where each cell can be thought of as a vertex labeled by its row and column $(r,c)$. Two vertices are connected if the squared Euclidean distance between them is exactly 13.
We start with an $n times n$ grid that is completely empty, and we gradually paint some cells black. After each paint operation, we must decide whether the current black-white pattern avoids a very specific forbidden configuration involving two rows and two columns.
We are maintaining an $n times n$ grid that starts completely empty in the sense that every cell is white. Over time, we flip certain cells to black, one at a time, and after each flip we must decide whether the current black-white pattern satisfies a structural restriction…
We are given a string T of even length n, consisting of the characters 'a', 'b', and '?'. The question asks us to count all possible strings S that match T wherever T specifies a character (i.e., S[i] = T[i] when T[i] is not '?
We are given a sequence of integers and a set of queries that modify elements of the sequence. After each modification, we are asked to compute two values derived from the sequence: the maximum length of two subarrays that are permutations of each other, and how many pairs of…
We are given a sequence of integers that has been generated by a very simple algorithm: start with some initial sequence of length m, and repeatedly choose an element and insert its value plus one immediately after it until the sequence reaches length m + k.
We are given a well-formed bracket string, meaning it behaves like a correctly nested sequence of parentheses. From this string, we choose some positions to form a subsequence, and then we perform a cyclic right shift on the characters located at those chosen positions.
The problem gives us a mysterious sequence generated by an ancient algorithm. Starting from a short sequence of length m, the algorithm repeatedly inserts a new number xi + 1 after any chosen element xi until the sequence reaches length m+k.
We are given $2n$ cards where each number from $1$ to $n$ appears exactly twice. The cards are initially face down, and in each turn, the player flips two cards. If the flipped cards show the same number, they are removed; otherwise, they are flipped back.
The problem is about building a sequence of moves on a 2D integer grid starting at the origin (0,0) and ending at a target point (x,y).
We start with an array containing the numbers from 1 to n in increasing order. Then we pick two positions i and j and swap the elements at those positions, creating exactly one disturbance in an otherwise perfectly sorted sequence.
We are asked to compute the expected score for Bob in a turn-based card game where Alice and Bob play optimally. Each round, a new card is added to a deck.
We are given two multisets, one called a and one called b. They define a game where players do not modify a at all, but gradually consume elements from b.
We are asked to transform a given integer into a "beautiful number" with the minimum number of digit changes. A beautiful number is defined such that applying the sum-of-digits function twice yields the same result as applying it once.
The problem asks us to generate an array of non-negative integers that sum up to a given total s, with the additional constraint that each element must only have bits set that are also set in another number m.
Monocarp has n identical boxes, each weighing m units and able to support up to d units on top. He wants to stack all the boxes into towers while respecting durability: no box can support more weight than d.
We are asked to repeatedly increase fractions of the form $1/bi$ either by incrementing the numerator or decreasing the denominator if it is larger than 1.
We are working on a rectangular grid where we start from the top-left cell and are allowed to walk using three moves: left, right, or down. There is no upward movement, which is the key structural restriction.
We are given a multiset of digits for each test case, and we are allowed to reorder them freely. The goal is to decide whether we can arrange these digits to match a very specific structured string generated from some positive integer x.
We are given an undirected graph and asked to assign a direction to each edge such that some vertices become "beautiful".
We are given a line of students arranged from left to right, and a ball that moves deterministically according to fixed rules.
Each test case describes three periodic visitors to a spring. Alice arrives every $a$ days, Bob every $b$ days, and Carol every $c$ days. On any day in the range from day $1$ to day $m$, some subset of them may arrive depending on divisibility of the day number.
We are given an array of integers and asked to simulate a very specific removal process. In each operation, we look at the current array, find the maximum element, and if multiple elements share that maximum, we choose the rightmost one.
We are asked to count the number of ordered triples of integers $(i, j, k)$ in the range $[0, m]$ such that the equation $(i oplus j) cdot x + (j oplus k) cdot y = n$ has an integer solution for $x$ and $y$. Here $oplus$ is the bitwise XOR.
We are given a rectangular grid representing a city, with intersections at coordinates $(i,j)$. Streets only exist between neighboring intersections, either horizontally or vertically. Each street has an integer weight and may or may not be allowed for reconstruction.
We are asked to count how many arrays $S$ exist such that, after a single sequence of independent subarray reversals, the resulting array equals a given array $T$.
We are asked to transform a permutation of integers into a "cool" array. An array is cool if no element in the middle of a triplet is the maximum among its neighbors. In other words, the array must have no peaks, where a peak is a value larger than both its immediate neighbors.
We are given a permutation p of length n. An index i is called ugly if it is the first time the maximum value is reached at that position. More formally, i is ugly if p[i] is equal to the maximum of p[1..i].
We are asked to help Simons divide cakes among his friends. More formally, for a given number of friends $n$, we need to find the smallest positive integer $k$ such that $k^n$ is divisible by $n$. The input consists of multiple test cases, each specifying the number of friends.
We are given several independent scenarios. In each one, there are several “blogs”, and each blog contains an ordered list of user IDs.
We are given a large set of points on a two-dimensional plane, constructed using a simple linear function modulo $n$. Specifically, each point has coordinates $(x, y)$ where $x$ ranges from $0$ to $n-1$, and $y = (a cdot x + b) bmod n$.
We are given a parenthesis string $S$, and we are allowed to add some parentheses in front of it and some at the end.
We are given a collection of digit stickers as a string. Each character represents one sticker of that digit. The goal is to assemble as many valid time displays in the format HH:MM, where HH is a two-digit hour between 00 and 11 inclusive, and MM is a two-digit minute between…
We are given a music playlist of n unique songs arranged in some initial order a. The app plays the songs in a circular fashion: after the last song, it starts over from the first. Separately, we have a desired listening sequence b of the same n songs.
We are given a sequence of n integers A = [a1, a2, ..., an], but we do not know A itself. Instead, we are provided with a sequence of parallel sums of length n - m + 1, where each sum is the sum of m consecutive elements of A. Formally, the sums are si = ai + a{i+1} + ...
We are counting how many ways we can build a sequence of integers when each position has an upper limit, and each element must divide the next one. More concretely, at position i we choose a value bi that cannot exceed ai.
We are given an integer array and a somewhat unusual operation that allows us to “reflect” values around a chosen pivot element.
We are given a connected undirected graph on $n$ vertices, where vertex $1$ is a start and vertex $n$ is a finish.
We are given a rooted tree where vertex 1 is the root, and every node carries a pile of ornaments. The only way we are allowed to remove ornaments is by selecting a vertex $u$, and then subtracting one ornament from every node on the path from the root to $u$, as long as that…
We are given a string of digits, each representing a cell in a conceptual 1D array of length $n$. Each digit either corresponds to some mines if it is non-zero, or an empty cell if it is zero.
We are given a connected undirected graph with $n$ vertices and $m$ edges, where each edge connects two vertices but its weight is unknown.
We are given a rooted tree with nodes numbered from 1 to $n$, rooted at node 1. Each node may either have an integer written on it (leaves) or be empty (internal nodes).
We are tasked with sorting the suffixes of a hidden string $S$ using an interactive judge. The string has length $n$, and we do not know its contents. We can query any two suffixes $S(i)$ and $S(j)$ to learn which is lexicographically smaller.
We are given a black-box function of $n$ variables. The function is not arbitrary: it is built by taking the variables $x1, x2, ldots, xn$ in order and combining them using only min and max, with the restriction that each variable appears exactly once and in that fixed…
We are asked to reverse-engineer a hidden function chosen by Bowser. The function takes n integer inputs and is constructed entirely from nested min and max operations, each input appearing exactly once in order from x1 to xn.
We are given an n × m grid representing sand, initially all white. Some cells are marked as needy () and must be painted black. Other cells are either special (x) or normal (.), and each non-needy cell has a value: special cells are worth b and normal cells are worth a.
We are given an unknown function that takes a list of n values and returns a single number. The function is not arbitrary: it is built by combining the inputs using only min and max, and every input variable appears exactly once, in order.
The problem gives us a Hanabi-like card game where Zuko holds all cards in a single row, one for each combination of rank and color. Iroh can see the cards, but Zuko cannot.
We are asked to count arrays of nonnegative integers that satisfy a sequence of nested MEX conditions. Concretely, we are given an array a of length n. For each position i in the array, we must ensure that the (n-i+1)-th MEX of the prefix [b1, ..., bi] equals a[i].
We are asked to construct an array b from a given array a such that, for each prefix of b, a generalized MEX condition holds. Specifically, the (n-i+1)-th MEX of the first i elements of b must equal a[i].
We are given a tree where a token starts at a fixed non-leaf vertex. The goal is to determine whether this token can be guaranteed to reach any leaf vertex if two players act in turns. One player controls the token.
The grid can be understood more simply if we ignore the 2D picture and focus on each column independently. In column i, there are ai dirt tiles at the bottom, and all tiles above them up to height h are water. So the number of water tiles in column i is h - ai.
We are given a binary string and a single operation that can be applied repeatedly. The operation only affects positions that are strictly inside the string, and only when that position is surrounded by ones on both sides.
We are asked to simulate a night at Freddy Fazbear’s Pizzeria in terms of danger management. Each animatronic accumulates danger every second, and the night lasts for a fixed number of seconds.
We are given a binary reachability matrix for a directed graph on $n$ nodes. The matrix tells us, for every ordered pair $(i, j)$, whether node $i$ can reach node $j$ through directed edges.
We are given an array of length $n$ with integers ranging from $-1$ to $n$. The $-1$ values are placeholders that can take any non-negative integer.
We are given a directed reachability matrix of a tree after all its edges have been assigned directions, and we need to reconstruct a tree and its edge directions that produce exactly the same reachability information.
We are given a deck of n cards, each with an energy cost. Bob wants to play a special "win-condition" card as many times as possible without exceeding a total energy budget m. On each turn, Bob can select a card from only the first k positions in the current deck.
We are given a sequence of tasks, each with a point value and a difficulty percentage. You start with a stamina of 1. For each task, you can either skip it or complete it.
We are given a square grid of size $n times n$ representing a board where each cell contains a candy of a certain color. The color of a candy is denoted by an integer, and different integers represent different colors.
We are given a tree of n vertices, where each vertex has an integer value. We can perform k operations, and in each operation, we choose a vertex to root the tree at. Once a vertex is chosen as the root, its value is added directly to the total and then set to zero.
We are given a string and a set of queries. For each query, we take a substring defined by its endpoints, and for every prefix of this substring, we compute the maximum number of pieces it can be split into such that each piece is itself a prefix of the substring.
The problem asks us to construct a sequence of ghostfires in three colors: red, green, and blue. OtterZ has a limited number of each color, denoted by $r$, $g$, and $b$. The goal is to place as many ghostfires as possible in a row while avoiding two constraints.
We are given a sequence of monsters, each with a strength value. We also start with an initial combat power. At any point, we can either defeat a monster if our current power is at least its strength, or we can spend a limited number of special items to increase a monster’s…
We are asked to find a position of a zero in a hidden array of length $2n$, where each integer from $1$ to $n$ occurs exactly once and all remaining positions are zeros.
We are given an array of integers, and for each element, we need to determine how many elements to its right can be “dominated” by it, in a specific sense.
We are given an array of integers where every element can potentially be changed once. However, each position has a strict constraint: any replacement value must lie in the range from 1 up to the original value at that position, and it must differ from the original value.
We are given a permutation of integers from 1 to n and a series of queries, each asking about a contiguous subarray of this permutation.
We are dealing with an interactive reconstruction problem where the hidden object is a binary string of length $n$. We do not observe the string directly.
We are given two arrays of equal length. Think of the first array as the current values written on a line of positions, and the second array as upper bounds that control how far each position is allowed to be changed.
We are given two balanced bracket strings of equal length. Both strings are guaranteed to be regular bracket sequences, meaning every prefix has at least as many opening brackets as closing ones and the total counts match.