brain
tamnd's digital brain — notes, problems, research
43815 notes
We are given a sorted line of unit-sized sliders placed on integer positions along a very long track. Each slider keeps a fixed identity, and the initial configuration is strictly increasing, meaning no two sliders start at the same position.
We are given a rooted tree with n vertices. Each vertex must be labeled either 0 or 1, with exactly k zeros and n - k ones. The "name" of a vertex is the string formed by concatenating the labels along the path from the root to that vertex.
We are given a permutation of integers from 1 to $n$, and we must answer multiple queries about whether certain subarrays are "perfect" according to a special sorting rule.
We have two people, Chocola and Vanilla, who start with exactly the same number of cakes, which is $2^k$ each. The total number of cakes is $2^{k+1}$. The goal is to redistribute the cakes so that Chocola ends up with exactly $x$ cakes and Vanilla gets the rest.
We are given a rooted tree with n vertices, where the root is vertex 1. Each vertex is labeled either 0 or 1, but we do not know the exact labeling. All we know is that exactly k vertices have label 0, and the remaining n - k have label 1.
We are asked to make two positive integers equal using a series of multiplication operations. Maple can choose either number and multiply it by any positive integer of her choice. The goal is to do this in the minimum number of operations.
We are given an array of integers and a special operation that can decrease some of its elements. For any chosen set of $k$ distinct indices, we sum the selected elements, take the remainder of this sum modulo $k$, and then decrease the smallest $y$ elements by 1, where $y$ is…
We have a sequence of n piles. The number of stones in each pile can be any integer from 1 to m. The game itself does not depend on the stone values while moves are being made. Players only choose positions to delete.
We have a row of n piles. Each pile contains either 1 or 2 stones because this is the easy version and m ≤ 2. The game does not modify pile values. Players only remove piles.
We are given several intervals on a number line. Each interval represents a “resource” with a left and right boundary. Initially none of these intervals are used. We repeatedly pick two unused intervals, and from each chosen interval we pick one point inside it.
We are given a game played on an array of integers where two players take turns performing a single action: either end the game immediately or swap two elements at positions $l$ and $r$, which adds $r-l$ to a running cost.
We are given a number $x$, and we must construct another positive integer $y$ such that a specific divisibility condition holds. The construction depends on forming a new number by concatenating the decimal representation of $x$ followed immediately by $y$.
We are given a binary string, which is a sequence of 0s and 1s, and the goal is to sort it into non-decreasing order using a specific operation.
We are working with a tree where every vertex starts uncolored. In one move, we pick any two vertices, possibly the same vertex twice, and we “recolor” every vertex on the unique path between them.
We start with an undirected simple graph on $n$ vertices. The graph evolves through an operation that removes two existing vertices and replaces them with a new vertex whose neighborhood is exactly the intersection of the neighborhoods of the removed vertices.
The problem asks us to simulate a special structure that supports adding and removing elements from both ends, along with a min operation that accumulates the minimum of all current elements into a running sum.
We are given a list of sofa models, each positioned on a website in a fixed order. Every model has a price, and every customer scans the list from left to right, picking the first sofa whose price does not exceed their budget.
We are given an array of small integers, and we are allowed to repeatedly pick two positions inside a chosen segment and XOR the value at the later index with the value at the earlier index.
We are given a sequence of integers and asked to count how many of its subsequences can be colored in red and blue such that, for every inversion (a pair of indices $i < j$ with $ai aj$), the two elements have different colors.
We start with a string made only of opening and closing brackets. The string is not fixed: we are allowed to repeatedly pick two adjacent identical brackets and flip them as a pair.
We are given a sequence of integers, each between 1 and n, and we want to count subsequences that can be “colored” red or blue in such a way that every inversion in the subsequence has endpoints of different colors.
We are given a permutation of length $n$, which is an array containing all integers from 1 to $n$ in some order, with no duplicates. We must perform a series of exactly $n$ operations, one for each $k$ from 1 to $n$.
We are asked to buy a set of products with individual prices while minimizing the total cost using discount vouchers. Each voucher allows you to pick a fixed number of products and get the cheapest among them for free.
We are given a tree with n vertices and n-1 edges, each edge carrying two non-negative integers x and y. The problem asks us to assign distinct integers from 1 to n to the vertices so that the sum of edge contributions is maximized.
We are given an array of tower heights, and we consider subsequences formed by deleting some elements while preserving order. For any chosen subsequence, we “scan” it from the left and record every element that is strictly larger than all previously seen elements.
We are given several bracket strings, each of length at most $k$, and we must assign every string to exactly one group. For each group we also construct a single “reference” regular bracket sequence of length exactly $k$.
We are given a sequence of tower heights and need to count subsequences that preserve the "visibility from left" and "visibility from right" sets.
We are running a clearance sale for a store with multiple items, each with a fixed original price. The store allows a uniform discount via division by an integer factor $x 1$, where the new price of an item is the ceiling of its original price divided by $x$.
We are given an array p of length n where some positions contain integers from 1 to n and others are zeros. No positive integer appears more than once.
We are given an array of non-negative integers and are asked to split it into three contiguous non-empty subarrays: a prefix, a middle part, and a suffix. For each subarray, we calculate the sum modulo 3.
We are given two integer arrays of the same length, a and b. At each index, we can either leave the elements as they are or swap a[i] with b[i]. After performing any subset of these swaps, both arrays must be non-descending for the subset to be considered "good.
We are tasked with predicting how many users on a streaming platform will watch a movie, given each user's preference for action and drama, and the movie's action and drama levels. Each user has thresholds for action and drama.
We are given a rectangular sheet with $n$ rows and $m$ columns, initially uncolored. Our task is to determine how many ways we can color it “beautifully” with exactly $k$ colors, using the fewest operations possible for each number of operations from $min(n, m)$ to $n+m-1$.
We are given a very long one-dimensional strip of cells, numbered from 0 up to m. A chip starts at cell 0 and wants to reach cell m in as few turns as possible. Each turn, the chip either stays where it is or moves one step to the right.
We are asked to construct a permutation of length $n$, meaning we must arrange the numbers from $1$ to $n$ exactly once in some order. For any fixed permutation, we can look at its inversions, which are pairs of positions where a larger number appears before a smaller one.
We are given a binary string consisting only of a and b. From this string, we are allowed to remove exactly one contiguous block of characters, possibly empty. After this deletion, we look at the remaining characters and count how many a and b are left.
We are given a deck of cards numbered from 1 to n, initially sorted with 1 on top and n on the bottom. Monocarp performs a sequence of k operations that remove cards from either the top, the bottom, or ambiguously from either end.
Monocarp wants to divide a certain number of candies evenly among his three nephews. He starts with n candies and needs to figure out how many more, if any, he must buy to make the total divisible by three.
The task is to count permutations of length $n$ that satisfy a specific condition derived from bubble sort. For a permutation $p$, define $bi$ as the number of bubble sort rounds required to sort the prefix $[p1, dots, pi]$.
We are given an array that grows one element at a time from left to right. After each new element is appended, we look at all subarrays that end exactly at this new position. Among those subarrays, we want the one that maximizes a particular score.
We are given an integer interval $[l, r]$. From this interval we form a list containing every integer exactly once. One copy of this list is fixed as array $b$. The other copy, array $a$, is initially identical but we are allowed to permute it arbitrarily.
We are given two integers, l and r, where l is always zero in this easy version and r is less than 200,000. From these, we define an array b that contains every integer from l to r, inclusive. We are allowed to permute a copy of this array, which we call a.
We are given several collections of integers, where each collection can be thought of as a “bundle of labels” from the range $1$ to $m$.
We are asked to construct a permutation of integers from 1 to n based on a binary string that marks which numbers are “stable” under a randomized variant of binary search.
We are given a non-decreasing array of integers, and we want to find a subsequence whose elements all appear the same number of times. A subsequence can skip elements but cannot change their order.
We are asked to construct a long sequence of integers, where the sequence behaves like a walk on the number line. Each consecutive pair defines a jump distance, and these jump distances must strictly increase as we move along the sequence.
We are asked to analyze sequences generated by repeated exponentiation modulo a given number. Specifically, for a positive integer $a$, we define a sequence $bn$ by $b0 = 1$ and $bn = a^{b{n-1}}$ for $n ge 1$.
We are asked to construct a sequence of integers of length $n$ placed on the number line. The only structural constraint is about consecutive jumps: if we define the jump sizes as $ So the sequence of distances is strictly increasing, while the actual points $ai$ can move left…
The graph defines a family of pairwise connectivity strengths. For every ordered pair of distinct vertices, we look at the maximum flow value between them when treating edges as undirected capacitated connections.
We are given a set of items, and each item is ranked in two independent ways. One ranking comes from permutation p, the other from permutation s.
We are given a sequence of positive integers, representing a set of “tiles” with values. Two players, Alice and Bob, take turns picking a number that currently exists in the array.
We are given an array of non-negative integers, and for each query we are allowed to increment any elements of the array a certain number of times.
We are on a two-dimensional grid starting at the origin $(0, 0)$ and want to reach a target $(x, y)$. Movement is constrained in two ways. First, we alternate axes: the first step moves right along $x$, the second up along $y$, the third along $x$ again, and so on.
We are given a row of flower pots, some with flowers and some empty. Each empty pot must host a rabbit, and we have to decide which way each rabbit will face: left or right. Rabbits are fidgety and may jump to the adjacent pot in the direction they face.
We are asked to construct a permutation-like array of length $2n$, but with repetition allowed: every number from $1$ to $n$ must appear exactly twice. The real constraint is not placement, but spacing.
We are given several arrays of integers, each of potentially different lengths. We can think of these arrays as rows in a grid that we are allowed to stack in any order, left-aligned.
We are given an array of integers representing objects lying on the floor. Farmer John is concerned with the greatest common divisor (GCD) of prefixes of this array.
We are given an array of positive integers and a parameter $k$. For any chosen segment $[l, r]$, we imagine splitting the array into two parts: inside the segment and outside the segment. Every element inside the segment is forced into a distinguished multiset, call it bucket 1.
We are given a sequence of fields, each containing some number of dandelions. We are allowed to choose the order in which we visit these fields, and each field is visited exactly once.
We are simulating a very simple movement process along a line of time, where each minute Farmer John either stays on his current side of a gym or runs to the opposite side. Each time he chooses to run, he earns one point.
We are working on a grid-like plane from the origin to a target point, but instead of being blocked by walls, the plane contains infinitely thin obstacles.
The problem gives us a number x and a length n and asks us to construct a sequence by alternating x and -x, starting with x. We are then asked to compute the sum of all elements in that sequence.
We are given an array of integers and many independent range queries. For each query segment, we must identify all values whose frequency inside that segment is strictly greater than one third of the segment length.
Nezuko starts at position 0 on a number line with a certain number of health points, and she wants to reach position d. In each turn, she can either rest to gain one health point or move forward by one.
We are given a binary string made only of two symbols, a and b. We are allowed to swap adjacent characters, so any operation is essentially a single step of bubble-sorting two neighbors.
We are given a sequence of integers representing symbols on an ancient tablet. Each test case asks us to count the number of continuous segments (subarrays) of this sequence that satisfy two conditions: the segment contains exactly k distinct numbers, and its length is at…
We are given an array of length $n$ where each element is either $-1$, $0$, or $1$. We are allowed to increment any element by one any number of times. The goal is to make the product of all elements strictly positive while performing the fewest possible operations.
We are given an even-length array of integers representing participants in a show. The task is to form pairs of participants such that each participant is in exactly one pair, and the difference between the two numbers in a pair is minimized in a global sense.
We are given an array of integers, each between 0 and n, and a target number k. We can replace any element with any integer from 0 to n in a single operation. Our goal is to make the MEX of the array equal to k using the minimum number of replacements.
We are asked to count how many binary strings of fixed length and fixed composition can be formed such that two conditions hold simultaneously: the string must dominate a given reference string in lexicographic order, and it must admit at least one split point where both…
We are given a connected simple undirected graph. The graph is already partially filled with edges, and our goal is to make it a complete graph, meaning every pair of distinct vertices must end up connected by an edge. We are not allowed to directly add edges.
We are given a hidden array of length $2n-1$ that contains each number from 1 to $n$ exactly twice, except for a single number which appears only once. Our goal is to determine which number appears only once. We do not need to know its position, only its identity.
We are given a hidden array of length 2n-1, containing integers from 1 to n such that every number appears exactly twice except for one number that appears only once. Our goal is to identify the number that occurs exactly once. We do not need its position, only its value.
We start with n people placed on positions 1 through n on a line. The initial configuration is completely rigid: person i starts at position i.
We are asked to count the number of ways to color cells black in an $n times n$ grid given a list $a$ of length $n$. The entry $ak$ specifies how many black cells must appear in row $k$.
We are asked to analyze a situation where two players, Alice and Bob, pick objects from a shop in turn. Each object has a value from our perspective, and each player has their own preference order.
We are given a line of $10^9$ cells, each either black or white. Initially, a certain set of cells are black, and all others are white.
We are given a tree with n vertices, each edge has a positive weight. The task is to assign nonnegative integer weights to the vertices themselves so that when we compute the minimum cost of a “victorious coloring” (coloring vertices red or yellow with at least one red)…
We are given a tree with weighted edges, and we are asked to assign nonnegative weights to vertices so that a certain “victorious coloring” has a minimum cost at least some value l, while keeping the sum of vertex weights as small as possible.
We are given a sorted sequence of attack timestamps. Each query gives a contiguous segment of this sequence, and inside that segment we are allowed to delete some elements. The goal is to keep as many timestamps as possible while avoiding a specific failure condition.
We are given a rooted tree with root fixed at vertex 1. Some vertices are marked as “active” (contain a monster), others are not.
We are given an array of zeros of length $n$, and a target array of positive integers. We want to reach the target array with as few operations as possible. There are two operations available. The first, Increase, adds the same positive integer to every element of the array.
We are given a hidden permutation of length $n^2 + 1$ and we need to find a monotone subsequence of length exactly $n+1$. The subsequence can either be increasing or decreasing.
We are given an array where every element starts at least 2, and two players repeatedly modify it until every value becomes 1.
We are asked to compute the maximum number of turns the Krug can survive against Doran on a square grid. The grid has coordinates from 0 to n in both rows and columns. The Krug moves first, either staying in place or moving to a vertically or horizontally adjacent cell.
We are given a binary array, meaning each element is either 0 or 1, and we need to repeatedly remove triples of identical elements. Each removal has a cost defined as the minimum distance between consecutive elements in the triple.
We are given an array a of length n that satisfies a special property called "cute," which prevents certain repeating patterns of four indices.
We are given a circular sequence of integers, and we are allowed to change each value by paying unit cost per increment or decrement.
We are asked to work with trailing zeros of factorials in arbitrary bases. Specifically, for any integer $xge 1$ and base $kge 2$, $vk(x!)$ counts how many times $k$ divides $x!$. For prime bases, this is straightforward: sum the integer divisions of $x$ by powers of $p$.
We are given several collections of stick lengths, and for each collection we want to pick some of these sticks to form the sides of a polygon. Each chosen stick becomes exactly one side, so we are not allowed to split or merge sticks.
We are given a circle of apple trees, each bearing a single apple with an associated beauty value. You start at tree one and walk around the circle repeatedly. At each tree, you have the choice to eat the apple or skip it.
We are asked to determine whether it is possible to construct three non-negative integers, $a$, $b$, and $c$, such that their pairwise bitwise ANDs equal three given integers $x$, $y$, and $z$. Specifically, the constraints are that $a & b = x$, $b & c = y$, and $a & c = z$.
We are asked to count the number of ways to fill in missing values in a partially specified permutation such that the resulting permutation can be split into two consecutive subsequences whose combined order gives the sorted permutation from $1$ to $n$.
We are given an array of length $n$ that is supposed to be a permutation of $1 dots n$, but some positions are unknown and marked as $-1$.
The tree represents a world where a cat starts at node 1 and tries to reach node n. You cannot directly control the cat’s path when it moves.
We are given an array of positive integers. We are allowed to choose one odd length $x$, and then repeatedly perform an operation up to $k$ times. Each operation picks any subsequence of length $x$, computes its median, and overwrites all chosen elements with that median value.
We are given an array of integers a, where each element behaves like a “value sitting on a position”, and a second array b which describes how expensive it is to increase each corresponding a[i] by 1.
We are given an array of integers and want to transform it into a zigzag sequence. A zigzag array is one where each element alternates between being smaller and larger than its neighbor: the first element is smaller than the second, the second is larger than the third, and so on.
We are given a binary string consisting of 0s and 1s and a positive integer k. Each 1 in the string can be “turned off” by Teto according to a simple local rule: if a 1 is not protected and there are no other 1s in the previous k-1 positions, it can be changed to 0.
We are given an array of positive integers a of length n. For each element ai, we can increment it by 1 any number of times at a cost of 1 per increment.