brain
tamnd's digital brain — notes, problems, research
43815 notes
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 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.
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.
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.
We are given a four-digit year as a string, potentially including leading zeros, and we are asked to determine if this number can be expressed as the square of the sum of two non-negative integers.
Let $f(n)=2^n-1$.
We are asked to maintain an array of n sets under a sequence of q online operations, where each operation modifies some prefix of sets or deletes a specific element from all sets, and then asks for the smallest element in a particular set.
We are asked to navigate a directed acyclic graph (DAG) with vertices numbered from 1 to n. Each vertex contains a trader who sells cards with a given power for a given cost.
We start with a sequence of positive integers. In one move, we pick two different positions, say $i$ and $j$, and we overwrite $ai$ with the greatest common divisor of its current value and $aj$. The second element $aj$ stays unchanged.
Let $A_0A_1,\dots,A_{n-1}A_n$ be consecutive segments on a line with each length at most $1$.
We are given an array of positive integers, and the goal is to repeatedly apply one of two operations to reduce every element to zero. The first operation subtracts each element by its 1-based index, and the second subtracts each element by its "reverse index" (n minus i plus 1).
We are given a sequence of doors arranged in a line. Each door is either open or closed. Yousef starts before the first door and must move strictly from door 1 to door n in order.
We are asked whether one array of integers, a, can be transformed into another array, b, using two types of operations. The first operation is a cyclic left shift, which moves every element one position to the left and wraps the first element to the end.
We have an odd-sized rectangular grid. Cells are colored one at a time. Whenever a new cell is colored, we look only at the cells that were already colored before this step. Among those cells, every cell that is farthest from the newly colored one receives one penalty.
We have a one-dimensional strip of length up to $10^{15}$, along which certain cells contain traffic lights. Each light has a fixed period $k$ and a delay $di < k$, and it turns red at times $l cdot k + di$ for integer $l ge 0$. All other times, the light is green.
We are asked to simulate motion along a one-dimensional strip of length up to $10^{15}$, where certain cells contain traffic lights with periodic red signals. Each traffic light has a fixed period $k$ and a delay $di$, meaning it shows red at times $t$ where $t mod k = di$.
We are given an array of integers. Each integer has a "beauty" defined as the number of 1s in its binary representation. For example, 5 in binary is 101, which has two 1s, so its beauty is 2. The total beauty of the array is the sum of the beauties of all its elements.
We start with an $n times n$ matrix where every row is identical and equal to the sequence $1,2,3,dots,n$. So initially every column is constant, and no column is a permutation at all.
We are asked to construct a binary string of length $n$, containing exactly $k$ ones, with an additional structural constraint involving subsequences of length three.
We are given a rooted tree where every node carries a value of either +1 or −1. A lava wave starts from the root and expands outward one edge per time unit, so at time t every node at distance at most t from the root is already unsafe.
Label the people $1,2,\dots,N$ from left to right.
We are given two sequences, a of length n-1 and b of length n. The goal is to increase elements in b using the fewest increments so that for every adjacent pair (bi, b{i+1}), their bitwise AND equals ai.
We are given sequences where each position i can store a value a[i] between 0 and i inclusive. Think of the index i as a time step and also as the right endpoint of a segment. Now interpret the process that defines the weight.
We are asked to construct an array of length n using integers within a given range [l, r], such that the bitwise AND of all elements equals the bitwise XOR of all elements. We do not need to output the full array; only the k-th element in lexicographical order.
We are given two non-negative integers a and b and two operations that can transform a. The first operation increments a by one at a cost x. The second operation flips the least significant bit of a (using a XOR 1) at a cost y.
We are given two fixed points on a plane: a starting location and a destination. We also receive a sequence of movement lengths. At step i, we must move from our current position to any point whose Euclidean distance from the current position is exactly ai.
We are given a simple, connected graph $G$ with $n$ vertices and $m$ edges, and we are asked to examine the properties of its iterated line graph $L^k(G)$.
Each lane initially contains ai cars. If nobody moves, the cars in a lane leave one per second, so a lane of size x contributes $$1+2+dots+x=frac{x(x+1)}2$$ to the total angriness. Cars may switch lanes.
We are given several graphs on the same vertex set. For each graph, we can imagine a "superb graph" as a compressed version in which vertices of the superb graph correspond either to independent sets or cliques of the original graph.
We are asked to determine the smallest size of a matrix Aryan should request from Harshith to guarantee that Aryan can always find a submatrix of size $a times b$ filled with identical numbers.
We are asked to construct a rooted tree of n nodes with a special property: each node has a divineness, which is the smallest node label on the path from the root to that node.
We are given three axis-aligned rectangles. Their dimensions are already ordered so that $$l3 le l2 le l1$$ and $$b3 le b2 le b1.$$ The rectangles cannot be rotated.
We are given a square pool table of side length $s$ with pockets at the four corners. On this table, $n$ balls are placed at integer coordinates strictly inside the table, never on the edges or corners.
We are given an integer array and, for each test case, two target values: a required subarray sum s and a required maximum value x. The task is to count how many contiguous subarrays have total sum exactly equal to s and whose largest element is exactly x.
We are asked to process a binary string and compute, for every contiguous substring, the maximum frequency of either 0 or 1 in that substring, then sum these values across all substrings.
At each vertex of the polyhedron, exactly three edges meet, so the vertex figure is a trihedral angle.
We are given two arrays, a and b, each of length n, containing all integers from 1 to 2n exactly once between them. The task is to rearrange the arrays using three types of swaps so that a is strictly increasing, b is strictly increasing, and at each position i, a[i] < b[i].
We are given two integers of equal length in decimal form, and we are allowed to pick any integer x that lies within the inclusive range between them.
We are given a rectangular grid of integers. In one move, we pick a single row and a single column. Every cell that lies in that chosen row or that chosen column gets decreased by one, with the intersection cell counted only once.