brain
tamnd's digital brain — notes, problems, research
41650 notes
We are given a final configuration of lit cells on an infinite integer grid. Initially, all cells are off except one hidden “origin” cell that was on at the beginning.
We are given a game with n viewers, each of whom may either be a crewmate or an impostor. The viewers make statements about themselves and others in contiguous ranges.
We are given a row of teddy bears, each colored either black or pink. A sequence of teddy bears is considered beautiful if all black bears appear to the left of all pink bears. Our goal is to transform any given arrangement into a beautiful one using the fewest possible moves.
We are given an $n times n$ grid where each cell contains an initial building height. We are allowed to modify the grid using two kinds of operations.
We are given a collection of gloves in a drawer, where each glove has a color and a type: left or right. For each of the $n$ colors, we know exactly how many left gloves $li$ and right gloves $ri$ exist.
We are given a permutation task over the numbers from 1 to n. Each number represents a stick length, and every length must be used exactly once. The goal is to arrange these sticks in a sequence so that the relative constraints between consecutive positions are satisfied.
Let $x_{n,m}$ be the entry in row $n$ and position $m$, where $0\le m\le n$.
The examples suggest that divisions should be used together with repeated squaring.
Let $a=BC$, $b=CA$, $c=AB$.
We are dealing with a network of airports where lost luggage moves around according to daily flights and is partially recovered through inspections. Each airport has an initial number of lost luggage pieces.
Let
Consider the problem on a $2\times 2$ chessboard first.
Let $d=\gcd(a,b)$ and write $a=dx$, $b=dy$ with $\gcd(x,y)=1$.
We are given a line of houses indexed by large integers, and a multiset of bar positions along this line. Multiple bars can occupy the same house, but each bar is treated as a separate point.
We are given a permutation and asked to examine every contiguous segment of it. For each segment we compute two classical sequence measures: the length of its longest strictly increasing subsequence and the length of its longest strictly decreasing subsequence.
Alice moves on the integer lattice starting at $(0,0)$, and her motion is periodic, determined by a string of $n$ moves repeated indefinitely.
We are given a tree with n vertices. Each vertex can be colored red, blue, or white. The "coolness" of a coloring is the largest distance between a red and a blue vertex. If there are no red or no blue vertices, the coolness is zero.
We are given a tree on $n$ vertices and a binary marker on each vertex that tells us whether that vertex is “active”. Only active vertices participate in the construction of a second structure: a complete weighted graph formed from these active nodes.
We are asked to maximize the "beauty" of an array derived from a given array a. For each position in a, the new array b must satisfy 1 ≤ bi ≤ ai. The beauty of b is the sum of the largest gaps between repeated occurrences of each value in b.
We are given a permutation, which we can think of as a row of distinct numbered tiles. The only allowed move takes any block of four consecutive positions and swaps the first with the third and the second with the fourth, effectively turning a segment [ai, a{i+1}, a{i+2}…
We are asked to fill an $n times n$ grid with the integers from $0$ to $n^2 - 1$, each used exactly once. Every rectangular subgrid contributes a value equal to the MEX of the numbers inside it, and the objective is to maximize the sum of these MEX values over all possible…
We are given an array where each element has a fixed absolute value that is unique across the array. We are allowed to flip the sign of any elements independently any number of times.
We are trying to construct an integer sequence of length $n$, where we are allowed to use negative values, such that two different constraints hold at the same time. First, the total sum of the entire sequence must equal a given value $m$.
Each pair of points is connected by a directed edge, so the structure is a tournament.
We are asked to process an array of integers where each integer fits in k bits. For each position in the array, we must find the maximum value of a "bitwise nor" over all subarrays that include that position.
We are given an array of integers a where every element lies between 0 and k. The allowed operation is to pick two distinct indices i and j such that a[i] + a[j] = k, and then redistribute a value x from a[i] to a[j] (or vice versa) while ensuring both elements remain in the…
We are given, for each position in an unknown permutation, the iteration at which the element at that position disappears under a deterministic pruning process.
We are given an array and asked whether we can cut it into three contiguous parts such that a particular condition involving medians holds across the cuts. If we pick two split points, the array is divided into three non-empty segments.
We are given a binary string that we want to type using a very simple typewriter with only two keys, 0 and 1. At any moment, a finger rests on one of these two keys. Pressing the key under the finger outputs that character, while switching keys costs a separate operation.
We are given an array of positive integers and we want to select as many elements as possible while keeping their original order irrelevant since we are forming a subsequence.
We are given a functional graph, meaning each vertex has exactly one outgoing edge. This forms a combination of cycles and trees pointing into those cycles.
We are asked to count the number of distinct strings generated by a simple, but slightly tricky rule. For each integer $x$ from 1 up to $n$, we form a string by concatenating $x$ and $x+1$, then sorting the digits of this concatenation.
We are given a fixed reference string s, and we are allowed to use only the first k lowercase letters. From this string s, we consider any string t to be “valid” if it can be formed by deleting characters from s without changing order, meaning t is a subsequence of s.
We are given an array of integers and we are allowed to modify it using a very specific resource system. Each increment of any element costs one coin, and each decrement of any element gives one coin.
We are given three stacks of cards arranged in a row, with the first stack containing a cards, the second b cards, and the third c cards. The numbers satisfy a < b < c.
We are given an array of integers, and for every possible length $k$ from 1 to $n$, we want to maximize the sum of the last $k$ elements after moving one element of our choice to the end of the array. After we choose and move that element, we restore the array for the next query.
We are given a small card game where each card is uniquely labeled from 1 to n, and each card initially belongs to either Alice or Bob. The ownership is fixed at the start, but during the game cards can move between players depending on outcomes.
We are given a tree with up to 1000 nodes, and each node hides a value of either 1 or −1. The tree is rooted somewhere, but the root is unknown to us.
We are given a tree of size $n$, where each node carries a value of either $1$ or $-1$. The tree is connected in such a way that every node is adjacent to node $1$.
We are asked to find the largest connected set of zeros in an $n times n$ grid that is built from a single binary string $s$. Each row of the grid is generated by flipping one character of $s$ at the row's index.
We are given a permutation of numbers from 1 to n, and we need to answer many independent queries. Each query picks a subarray range $[l, r]$ and a target value $k$. We imagine performing the standard binary search process on that fixed range, even though the array is not sorted.
We are given a sequence of flowers in a row, each with a numeric beauty value. Igor wants to collect a fixed number of flowers, exactly $m$, moving strictly left to right.
We are given a list that must be a permutation of numbers from 0 to n−1. As we reveal this permutation from left to right, we compute a running value: after each prefix, we take the smallest non-negative integer that is missing from that prefix.
We are given a binary string s of length n, and we imagine creating n new strings by flipping exactly one bit of s in each position. The resulting strings are arranged as rows of an n × n board. Our goal is to count the total number of 1s on this board.
We are given two arrays of length $n$, $a$ and $b$. Array $a$ is fully known, and $b$ has some missing elements marked as $-1$. The goal is to fill in the missing elements in $b$ such that the sum $ai + bi$ is constant for all $i$. Each element in $b$ must remain within $[0, k]$.
The problem presents a sequence of cyclists, each with an agility value. Leo is positioned at the back and wants to overtake all cyclists to reach the front.
For consecutive pairs $a_{i-1}<a_i$, the expression
We are given a line of cyclists with different “agility costs” associated to each position. Leo starts behind the last cyclist and wants to move all the way to the front, passing every cyclist one by one until he is ahead of the first.
We are asked to construct a rooted tree on nodes labeled from 1 to n, where node 1 is fixed as the root. The contribution of a pair of nodes i and j is determined by how deep their lowest common ancestor is in this rooted tree.
We are given a tree with n nodes, each node initially containing one apple. Our goal is to traverse this tree and repeatedly select paths consisting only of nodes that still have apples, remove the apples along that path, and write down three numbers: the length of the path…
We are given an array where some positions are already fixed and some positions are “unknown”. Unknown positions are initially set to zero, but we are allowed to overwrite them with arbitrary integers up to $10^{18}$.
We are given several independent games. In each game, there are multiple boxes of apples. On every move, a player removes exactly one apple from a single non-empty box.
We are given several independent arrays, and for each one we need to split its elements into two non-empty groups. Each number must go into exactly one group, so we are really choosing a binary labeling of indices.
We are given an array of towers, each tower starting with some non-negative height. We must process every tower exactly once, in any order we choose.
We are given a tree with an odd number of vertices. Almost all vertices carry ornaments, and every ornament belongs to exactly one color, with each color appearing on exactly two vertices. One vertex is special and initially uncolored, acting as a “topper”.
We are given a hidden array C formed by concatenating two unknown arrays A and B. The split point is unknown. Both arrays are over the alphabet {1, 2, ...
We are asked to construct an array of n positive integers whose bitwise XOR is exactly x and to minimize the sum of the array. Instead of outputting the array itself, we are asked to return the sum of the elements.
Neo is faced with a row of buttons, each labeled with a positive integer weight. He wants to press all the buttons such that the sequence of weights of the pressed buttons never increases.
We are given a permutation of the numbers from 1 to n, and we measure how far each element moves away from its original position. For each position i, we take the absolute difference between the value sitting there and i itself, and sum this over the entire array.
We are working on an $n times n$ grid where each cell has two attributes: a weight $a{i,j}$ and a color that is either black or white. Two players start from different positions on the left side of the grid and both aim to reach the same exit cell on the rightmost column.
We are given a binary string s of length n and an integer k. Our task is to perform exactly k operations, each of which selects a zero in the current string and flips all bits from the beginning up to that zero.
In this problem, we are asked to manipulate an unknown integer $x$ to become equal to a given target $n$ using a very limited number of operations.
We start with an unknown integer x, hidden from us, guaranteed to lie in the range from 1 to 10^9. Our goal is to transform this hidden value into a given target value n.
We are given a connected, undirected graph with n vertices and m edges. There are no self-loops or multiple edges, so each edge connects two distinct vertices exactly once. Along with the graph, we are given a multiset A of positive integers, each representing a "move length.
In this problem, we face an unknown integer x that is initially hidden from us, and our goal is to transform it into a target integer n by issuing at most seven interactive commands.
We are given a rectangular grid of size $n times m$, and a single token (a monster) initially placed at cell $(a, b)$.
We are given a line of players, each participating in duels with their immediate neighbor, so player 1 duels player 2, player 2 duels player 3, and so on until player $n-1$ duels player $n$. After all $n-1$ duels, each player reports whether they won at least one duel.
Let the first quadratic be $x^2 + p_1 x + q_1 = 0$ with two distinct real roots $r_1 \le s_1$.
We are given an array of positive integers, and for each prefix of the array we are asked to compute its "beauty." The beauty of an array is defined as the maximum value of the function $f(x, y) = (x bmod y) + (y bmod x)$ over all pairs of elements $x, y$ in the prefix.
We are asked to guide a robot through a series of checkpoints. Each checkpoint has a certain number of batteries that the robot can collect, and there are one-way passages connecting some checkpoints.
We are asked to arrange a set of sounds, each defined by a volume and pitch, into a sequence that is simultaneously beautiful and non-boring.
We are asked to plan a drone flight through a sequence of obstacles, where each obstacle defines an allowable height range.
We are given an array of integers, and we define it as fashionable if the sum of its minimum and maximum elements is even. Our task is to determine the minimum number of elements that must be removed so that the array becomes fashionable.
We are given a string representing a balanced sequence of parentheses, and we need to decide whether it is possible to remove exactly one opening bracket and exactly one closing bracket such that the resulting string is no longer balanced.
We are given a permutation of the numbers from 1 to n. For every query, we take a contiguous segment of this permutation and must decide whether that segment has a very specific structural property: whether there exists a way to split the segment into two parts using a…
We are asked to construct a shape made from unit square tiles placed on the integer grid. Each tile occupies one cell, and all chosen cells must form a single 4-connected component, meaning you can walk between any two tiles by stepping across shared edges.
We are given a string consisting only of the characters a, b, and c. Alongside it is a sequence of operations. Each operation suggests a possible replacement: choose any occurrence of a letter x and turn it into another letter y, or skip the operation entirely.
We are tasked with creating a class schedule for a faculty where each group has exactly six classes on the first day. There are $n$ student groups and $m$ classrooms.
We have a collection of cubes, where the side length of the $i$-th cube corresponds to the $i$-th Fibonacci number under a modified definition: $f1 = 1$, $f2 = 2$, and $fi = f{i-1} + f{i-2}$ for $i 2$.
We are working with three identical storage units that start at zero energy. The goal is to bring all three to exactly the same target level $x$. The only operation allowed is to pick one unit and increase its value by any positive integer.
We are given an array of integers and allowed to repeatedly “broadcast” a chosen element’s value either to everything on its left or everything on its right.
We are given a directed system of value propagation rules over $n$ variables. Each rule says that one variable $x$ can potentially be reduced using the value of another variable $y$, shifted by a constant $z$, through an operation of the form $ax leftarrow min(ax, ay + z)$.
We are given a rooted tree, and every vertex must be assigned one of three colors: green, blue, or yellow. The root is fixed to be green. A coloring is considered valid when two connectivity constraints hold.
We are asked to take an undirected tree and assign a direction to each edge so that the number of ordered vertex pairs $(u, v)$ where there is a directed path from $u$ to $v$ equals exactly $n$, the number of vertices.
Let $AB=c$, $AC=b$, and let $\angle A = \alpha$.
We are given a sorted array of integers, and we need to count how many ways Alice can pick exactly three distinct indices such that no matter what Bob does afterward, Alice’s chosen triple is “safe”. The sequence of events matters. Alice first selects three elements.
In this problem, Alice and Bob are racing to a prize that will appear at one of two distinct points on a one-dimensional line. Alice has already chosen her starting point a.
We are given an array of integers, and we want to make it "beautiful." A beautiful array has at least two elements and contains at least one pair of adjacent elements whose difference is at most one.
We are given a tree representing a city. Marat starts at vertex x at time 1 and wants to reach vertex y. Each day progresses in discrete time steps, and at each step he can either stay in place or move along one edge of the tree. At the same time, there are up to 200 enemies.
We are given two arrays, a and b, each containing n integers. We can swap elements between the arrays at the same index as many times as we like. The goal is to maximize the sum of the number of distinct elements in each array.
We are given two ordered stacks of cards, one belonging to the player and one belonging to the dealer. Both stacks contain distinct values, and each stack is played from top to bottom. In every round, both sides reveal their current top card.
We are given a grid where each cell is either empty, stone, or gold. Smilo can only place dynamite in empty cells. When he detonates at an empty cell, it affects a square region centered there with fixed radius k, so the square has side length 2k + 1.
We are given a rectangular roof aligned with the coordinate axes, with width $w$ and height $h$. The roof lies in the plane starting from $(0,0)$. We also have identical rectangular tiles of fixed size $a times b$.
We are given a grill that starts at some temperature and two types of shashlik that can be cooked repeatedly without limit. Each time we cook a portion, we must first check whether the current temperature is high enough, and then the grill’s temperature drops afterward.
We start from an empty array and repeatedly append integers either to its left end or right end. After each insertion, the array may simplify itself: whenever two identical neighbors appear, they merge into a single element equal to their sum.
We are given two integers, x and y, and an upper bound k. Our goal is to transform x into y using the fewest possible operations.
We are given a rooted tree where vertex 1 is the root, and each vertex has a numeric value. For every vertex $v$, we consider the path going upward from $v$ to the root.
We are asked to destroy all monsters on a very large $10^9 times 10^9$ grid. Each monster occupies a distinct cell, and we are allowed to move exactly one monster to any empty cell before selecting a rectangle that covers some contiguous region of the grid.
We are given a non-decreasing array of integers. The task is to remove zero or more elements to maximize the number of arrays formed according to a sequential rule.
We are given a binary string of even length and a target number of good pairs. A good pair consists of two characters symmetrically positioned around the center that are equal.