brain
tamnd's digital brain — notes, problems, research
41650 notes
We are asked to consider an infinite string formed by writing all positive integers consecutively: 123456789101112... and so on. For each test case, we are given a number k representing the number of digits to take from the start of this infinite string.
We start with a string a. Another string b contains characters that must be inserted one by one, in the order they appear. For every position i in b, the corresponding character c[i] tells us who inserts that character.
We are given a number $n$ that was constructed in a very specific way. Someone secretly chose an integer $x$, then created another number $y$ by appending one or more zeros to the right of $x$. That means $y = x cdot 10^k$ for some $k ge 1$.
The problem gives us a seller who offers watermelons in bundles of sizes that are powers of three. Each bundle of size $3^x$ costs $3^{x+1} + x cdot 3^{x-1}$ coins.
Working
We are working on a tree where an adversary occupies exactly one node, but we never know which one. The adversary is also reactive: after each of our actions, they are allowed to move along one edge or stay in place, except in the special case where we directly queried their…
We are given a line of creepers, each with an explosive power. Detonating a creeper at position $i$ kills all creepers within distance less than its explosive power, specifically positions $j$ such that $ The input consists of multiple test cases, each with $n$ creepers and an…
We are given a network of nether portals represented as a directed acyclic graph. Each portal may have directed connections to other portals, but there are no cycles. The task is to find a longest path in this hidden DAG.
We are given several independent scenarios. In each scenario, there are $n$ villagers, and each villager starts with a non-negative integer value called grumpiness.
We are asked to decide whether a sequence of gears can be arranged in a line such that spinning the leftmost gear at one revolution per second results in the rightmost gear spinning exactly at one revolution per second.
We are given a tree and a very specific local rewiring operation. The operation picks a vertex $b$ with two distinguished neighbors $a$ and $c$. After that, every other neighbor of $b$ is detached from $b$ and reattached to $c$.
We are given a sequence of boxes, each with a hidden power of either 1 or 2. The boxes are placed on a number line at positions 1 through n. We need to discover the power of each box using two interactive queries: swapping adjacent boxes and throwing a ball at a box.
We are given counts for four integers, 0 through 3. Specifically, $c0$ copies of 0, $c1$ copies of 1, $c2$ copies of 2, and $c3$ copies of 3. From this, we can form an array of length $n = c0 + c1 + c2 + c3$.
We are given an array of non-negative integers and we need to make it good by performing the minimum number of operations.
We are given a row of n cells, all initially white. We have two painting operations. The first operation paints a consecutive cells red, starting at any position x such that the red block fits entirely within the row.
We are given an array of positive integers and a positive integer $k$. For each element of the array, we are allowed to either leave it as-is or add $k$ to it in one operation.
We are given a rooted full binary tree where every node represents a function built recursively from its children. Leaves behave simply: their function is just the identity map $fu(x) = x$.
We are asked to count binary strings of a given length that are almost-palindromes under a specific transformation. For a binary string, repeatedly deleting all occurrences of the substring 10 yields a "reduced" string.
The task is to determine the unknown width parameter $W$ of a text editor. The editor displays a sequence of words, each represented by its length, on lines of width $W$.
We are asked to count a specific subset of binary strings of length $n$, which are called almost-palindromes. The key to understanding this problem is the function $f(r)$, which repeatedly deletes all occurrences of the substring 10 from a binary string $r$ until no 10 remains.
We are trying to determine an unknown integer parameter $W$, the width of lines in a text editor. Each article we submit is a sequence of positive integers representing word lengths.
We are given an array of integers, and we want to find the length of the longest subsequence that can be split into "blocks". A block is defined as a contiguous sequence where every element equals the length of that sequence.
We are given a connected undirected graph where each vertex may have a weight, but some weights are missing and represented by -1. The goal is to fill in the missing weights such that the graph becomes balanced.
The original problem is interactive. We know a set of anchor points, and there is a hidden robot position. By moving the robot and observing the minimum Manhattan distance to any anchor, we must recover the initial coordinates.
We know the score at halftime and the score at full time. If the halftime score is a:b, then during the first half the RiOI team scored exactly a goals and the KDOI team scored exactly b goals.
We are given a directed acyclic graph with n nodes and m edges. Each node starts colored blue, and players Cry and River play a two-player token game. The token starts at a node s. Cry moves first, then River, and they alternate.
We are given a sequence of numbers, and we want to interpret each number in that sequence as a frequency requirement for some unknown array we must construct.
For any array $x$, its sequence of prefix maxima is completely determined. At position $i$, the prefix maximum is $$max(x1,x2,dots,xi).$$ We are allowed to build another array $z$ whose prefix maxima are identical to those of $x$.
We are given an array of integers and asked to perform a special transformation multiple times. For each element in the array, we replace it with the minimum non-negative integer that does not appear anywhere else in the array.
We are given the result of running the Collatz operation exactly k times and the final value x. The task is not to find the original value uniquely, because many different starting values may lead to the same result.
We are given two integers, $a$ and $b$, and we can pick a positive integer $k$ such that $b$ is divisible by $k$. Then we replace $a$ with $a cdot k$ and $b$ with $b / k$. The goal is to make the sum $a + b$ as large as possible while ensuring it is even.
We are given a permutation $p$ of size $n$, meaning it contains each integer from $1$ to $n$ exactly once. We must construct another permutation $q$ of the same size, also a rearrangement of $1$ to $n$, with a structural constraint linking adjacent positions.
We start with two fixed points in the plane, one at the origin and one at $(1,0)$, connected by a segment. The only allowed way to create new points is by repeatedly selecting an existing segment, treating its endpoints as two vertices of a triangle, and then placing a third…
We are asked to construct a square matrix with small integer entries, limited non-zero elements per row and column, and a determinant equal to a given target number.
The determinant can be written using the Leibniz formula: $$det(M)=sum{sigma} operatorname{sgn}(sigma)prodi M{i,sigma(i)}.$$ A brute force viewpoint is to think of each permutation as choosing one outgoing edge from every row and one incoming edge into every column.
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 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 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 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.