brain
tamnd's digital brain — notes, problems, research
41650 notes
We are given a binary sequence that can change shape over time. The only allowed move is to take any contiguous segment and compress it into a single value equal to the majority of that segment, where ties are resolved in favor of zero.
We are given a tree with n vertices, where each vertex holds a monster with a certain attack power. You, the monster killer, face the monsters for effectively an infinite number of rounds.
We are working with a permutation of numbers from 1 to n, placed on a line. For any arrangement of numbers, we define a value based on all contiguous subarrays: each subarray contributes its minimum element, and we sum these contributions over every possible subarray.
This is a two-part geometric covering problem.
We are given a number $n$, and we want to build the longest possible strictly increasing sequence of positive integers, where every element is at most $n$. The key constraint is that every adjacent pair must combine under bitwise OR to exactly $n$.
We start with a multiset that contains a single number n. The only way to change this multiset is to repeatedly pick one existing number u, delete it, and replace it with at most k positive integers whose sum is exactly u.
We are given a matrix with n rows and m columns, initially colorless. The allowed operations are painting an entire row red or an entire column blue.
We are given a grid representing the arcade screen with coordinates $(x, y)$, where Monocarp starts at the origin $(0, 0)$. There are $n$ coins scattered on the grid. Each second, Monocarp can move in one of the eight directions (up, down, left, right, and the four diagonals).
We are given a collection of weapon blueprints and several independent piles of raw material. Each blueprint describes how many ingots are needed to build a weapon and how many ingots are recovered if that weapon is later melted.
We are given an integer array, but we are not asked to build or choose the array directly. Instead, every valid array $a$ over values $1$ to $k$ induces a derived array $b$, where each position $i$ stores how far you must walk left or right from $i$ to encounter a different…
We are asked to construct a string that satisfies two overlapping constraints: it must contain one given string, $a$, as a substring, and another string, $b$, as a subsequence. The difference between substring and subsequence is crucial.
Each person has a pair of opinions, one for each of two movies. The opinion is ternary: it contributes either +1, 0, or -1 if that person reviews that movie. We must assign every person to exactly one of the two movies, and this choice determines both movie scores.
We are given a dynamic array of positive values, and we repeatedly modify it while also answering range queries. The interesting object is a subarray that behaves like the side lengths of a polygon.
We are working with a rooted tree where node 1 is fixed as the root. Somewhere in this tree there is a hidden token, called the mole, which occupies a single node. We do not know its position initially, but we can interact with the system by querying any node x.
We are working with a rooted tree where node 1 is the root, and one hidden token, the “mole”, starts at some unknown node. We cannot observe its position directly. Instead, we interact with the tree using queries on nodes.
We are given a one-dimensional array of integers, where each integer represents how many consecutive cells in a row of a grid are initially black.
Place the $4k$ points on a circle in their cyclic order and denote their labels by $a_1,a_2,\ldots,a_{4k}$.
We have a two-player game on an array of integers. Alice and Bob take turns, with Alice starting first. Initially, a variable mx is zero. On their turn, a player can choose an array element a[i] if it is at least mx, set mx to that value, and then set a[i] to zero.
We are given an array of integers, and we need to repeatedly update it while accumulating a running sum. The update rule is based on the concept of $operatorname{MAD}$ - the maximum number that appears at least twice in a prefix of the array.
We need to construct an array of length $n$, where each element is either $+1$ or $-1$. Two special positions are defined based on prefix sums and suffix sums. For prefixes, we look at all partial sums $Si = a1 + dots + ai$.
Let the plane of the triangle be $z=0$.
We are asked to play an interactive game on a rectangular grid of size $n times m$. Each cell must be filled with a unique integer from $1$ to $n cdot m$. Once the grid is filled, the interactor and we take turns picking unchosen cells.
In this problem, Alice and Bob are playing a turn-based game with piles of stones. Each pile contains some number of stones, and a player on their turn must choose a number of piles to remove and an equal number of piles to split, where the split must produce piles with prime…
We are asked to manage a dynamic grid coloring process. The grid has $n$ rows and $m$ columns, all initially white. We are given an integer $k$ and a sequence of operations. Each operation is either horizontal or vertical.
We are given a sequence of sticks, each with a positive integer length. For each query, we are asked whether it is possible to pick exactly six distinct sticks from a given contiguous subarray such that we can form two non-degenerate triangles.
We are asked to play a two-player game on a connected undirected graph where each vertex can be colored with one of three colors. The game proceeds in rounds equal to the number of vertices.
We are given an array of non-negative integers, and in one operation we can pick any number $x$ and replace every element $ai$ with its absolute difference from $x$, $ The key constraint is the array size $n$ up to $2 cdot 10^5$ and the sum of $n$ across all test cases also…
We are given a set of vertices labeled from 1 to n. Two vertices are connected if the XOR of their labels is a prime number. The task is to assign a color to every vertex so that no edge connects two vertices of the same color, while using as few colors as possible.
We are given an array b of length n-1 and need to construct an array a of length n such that each element of b equals the bitwise AND of consecutive elements of a. In other words, for each i from 1 to n-1, b[i] = a[i] & a[i+1].
We are given an array of odd length, and we repeatedly compress it by deleting two neighboring elements in one move until only one value remains. Each deletion removes a contiguous pair, and everything else shifts together.
Let the first circle be $\omega_1$ and the second circle be $\omega_2$.
We are asked to construct a permutation of numbers from 1 to $n$ such that a certain expression is maximized. The expression is the sum of all prefix sums of "large" numbers (greater than or equal to $k$) minus the sum of all prefix sums of "small" numbers (less than or equal…
Let the segments be
We are given an array a of length n containing integers from 1 to n, possibly in any order and possibly repeated.
We are given a sequence of n cards, each with an integer price, and a target integer x. None of the cards are equal to x. A segment of consecutive cards is considered bad if it is impossible to pick a subset of cards within that segment whose product equals x.
The task describes a very small “birthday arithmetic” model, but the twist is that the computation is not performed numerically in the usual way. Instead, the intermediate value is treated as a string, which completely changes how subtraction behaves.
We are asked to compute the minimum number of operations required to merge a pre-cut potato casserole back into a single piece. The casserole has total length n and was cut into k pieces of lengths a1 through ak. Two operations are allowed.
We are given a river that behaves like a linear board of n cells. Each cell is either safe ground in the form of a log, dangerous water, or an instant-failure crocodile tile. The goal is to move from the left bank before the first cell to the right bank after the last cell.
We are given three small integers that represent the initial sizes of three factors contributing to a product. The final quantity we care about is the product of these three numbers, and we are allowed to improve it by performing at most five operations.
The sum is
We are asked to simulate the movement of a robot inside a bounded rectangle, starting at the bottom-left corner. The robot follows a script of movements, each of which is one of the four cardinal directions.
We are given a small matrix of integers, and the operations we can perform are unusual. For any row, we can replace every element with the XOR of the corresponding column. For any column, we can replace every element with the XOR of the corresponding row.
We are given an array of integers and a parameter $k$. We can repeatedly remove any contiguous subarray of length exactly $k$ from the array, shrinking it. Once the array's length is no longer greater than $k$, we stop.
We are simulating a deterministic robot moving on a grid that is bounded by a rectangle. The robot starts at the origin and repeatedly executes a fixed instruction string consisting of unit moves in four directions.
The problem involves an apartment with multiple rooms, each starting with its light turned off. Each room gets a chip installed at a distinct time, and each chip toggles the light in its room on and off periodically, with a period k minutes.
We are given a multiple-choice test with $4n$ questions, where each of the four options 'A', 'B', 'C', 'D' is correct exactly $n$ times. Tim answers the questions but may leave some as '?', representing unknown answers.
We are given an array of positive integers, and we want all elements to share the same parity - either all even or all odd. The only allowed operation is to pick two elements of differing parity and add the larger number to the smaller.
Let
Part (1) concerns the cyclic expression
Let the square have side length $2$ and center $O$.
Let
We have $2n$ knights sitting at $n$ desks arranged in a circle. Each desk has exactly two knights, the first at position $2i-1$ and the second at $2i$. Each knight has an integer intelligence value.
We are given a string of uppercase letters representing a text in an ancient language. The language uses only the first $c$ letters of the Latin alphabet, and each word in the language has a “case” determined solely by its last letter. Words can have lengths up to $k$.
We have 2n knights arranged around a circle. Desk i contains knights (2i-1, 2i), so every desk contributes a sum of two intelligence values. The only operation allowed is swapping opposite positions in the circle.
We are given several independent arrays, and for each one we are allowed to modify elements using a very specific operation: pick an index and replace the value at that position with its square. We may repeat this operation on the same index multiple times.
Each flower has two properties that are actually the same number: its petal count and its price. A flower with k petals costs exactly k coins. We may buy any subset of the flowers available in the store.
We are given several independent scenarios. In each scenario, there are different flower types, each type having a petal value and a limited supply. Every flower costs exactly its petal value in coins, and we have a fixed budget. We want to build a bouquet under two restrictions.
We are working on an $n times n$ grid where each cell belongs to exactly one diagonal if we group cells by the value $i + j$. Every such value defines a diagonal that runs from the top edge toward the right or bottom edge depending on where it sits in the square.
The problem describes a circular town with n houses connected by roads that form a single cycle. Each house i connects to i+1, and the last house n connects back to house 1. Among these residents, there are m friendships, each linking two distinct houses.
We are asked to maximize a score over a series of operations on two arrays. Each array has length $n$. Array $a$ represents the current “value” of each element, and array $b$ represents how much that element decays after it is used.
We are given a binary string, and we look at every possible contiguous segment of it. Each segment itself contains many subsegments, and we are interested only in those subsegments whose number of zeros equals the number of ones.
We need to count ordered triples of positive integers $(a,b,c)$ that satisfy two independent restrictions. The first restriction limits the pairwise products: $$ab + ac + bc le n$$ The second restriction limits the sum: $$a + b + c le x$$ The word "ordered" matters.
The game begins with the first player choosing an initial value $P_0 \in {2,3,4,5,6,7,8,9}$.
We are given two strings, a and b, of equal length n. For each query, defined by a range [l, r], we are allowed to modify individual characters of a within that range. The goal is to transform the substring a[l..
We are given a square grid of size $n times n$ where each cell contains either a zero or a one. The task is to reduce this grid by a factor $k$, which is guaranteed to divide $n$ evenly.
The farm has only chickens and cows, and Farmer John counts a total of n legs. Chickens contribute 2 legs each and cows contribute 4 legs each. The question asks for the smallest possible number of animals consistent with the total leg count.
Let $ABC$ be the given triangle.
We are given a one-dimensional line with positions numbered from 1 to $x$. We must place exactly $n$ chips on these positions, allowing multiple chips at the same position.
In this problem, Monocarp is traversing a linear sequence of monsters, each with a level. He starts at level 1 and can fight monsters whose levels are at least as high as his current level. Whenever he fights k monsters, he levels up by one.
We are given a rooted tree. Every vertex contains a non-negative number. An operation can be applied to any non-leaf vertex. When we choose a vertex $v$, we increase the value at $v$ by one and simultaneously decrease every other vertex in the subtree of $v$ by one.
We have a grid with only two rows. Some cells are free (.), some are blocked (x). Free cells form a graph where adjacent cells sharing a side are connected. A connected region is simply a connected component of this graph.
We are asked to strengthen a password by inserting exactly one lowercase letter anywhere in an existing string. The password's strength is quantified by the time it takes to type it. Typing rules are simple: the first character always takes two seconds.
We are given a bracket sequence of even length, but every character at an odd position has been erased. Only the brackets at positions 2, 4, 6, ... remain.
We have a directed acyclic graph on islands 1...n. The graph always contains the chain 1 - 2 - 3 - ... - n and additionally contains m extra directed edges (u, v) with u < v. Bessie can only move along the chain edges. Elsie can move along both chain and extra edges.
We are given a sequence of balls numbered from 1 to $n$, each labeled with a positive integer. For each prefix of length $i$ ($1 le i le n$), we want to determine how many positions $j$ can survive as the last remaining ball if we repeatedly merge pairs of neighboring balls…
Let the regular $2n$-gon have vertices $A_1,A_2,\dots,A_{2n}$ in cyclic order, and let $P$ be a point inside the polygon.
We are given a row of $n$ balls, each with an integer written on it. The operation we can perform repeatedly involves selecting two adjacent values in the set $S$ and merging them according to their relative sizes.
We are given an array of integers a and a parallel binary array b. The array b indicates which positions in a can be incremented. Each increment operation increases a chosen a[i] by 1, and we can perform at most k operations in total.
We are given a permutation p of length n. We must construct another permutation q of the same length. For every subarray [i, j], we can compare the sum of that segment in p with the sum of the corresponding segment in q.
We are given a target center point $(xc, yc)$ and an integer $k$. The task is not to optimize anything or search for a special configuration. We simply need to construct exactly $k$ distinct integer-coordinate points whose arithmetic mean is exactly $(xc, yc)$.
We are asked to find a missing number on a special ruler, which behaves almost like a normal ruler but skips a single value $x$ between 2 and 999. If you try to measure an object smaller than $x$, the ruler gives the correct length.
We are interacting with a hidden parameter $x$ between 2 and 999 that defines a faulty measuring device. Whenever we measure a length $y$, the device behaves normally for small values, but once the true length reaches $x$ or more, it consistently over-reports by exactly 1 unit.
We are given a consecutive sequence of integers from $l$ to $r$ inclusive, written on a board. Ivy can repeatedly perform an operation on any two numbers $x$ and $y$: she replaces them with $3x$ and $lfloor y/3 rfloor$.
We are given a binary array containing only 0 and 1. For every subsequence of length k, where k is odd, we compute its median and add all these medians together. The array is binary, which changes the nature of the median completely.
The task asks for the sum of the digits of a two-digit number for multiple test cases. Each input number $n$ is guaranteed to be between 10 and 99 inclusive, so the first digit is always nonzero.
The requirement that no term is equal to the sum of several others is ensured by a stronger property: for every $n$, if
We are given a day of length m minutes and a set of non-overlapping tasks, each occupying a continuous interval of time.
We are asked to compute the number of ways Suneet can win a two-round card game against Slavic. Each player has exactly two cards, each numbered between 1 and 10.
The task asks for the sum of the digits of a two-digit number for multiple test cases. Each input number $n$ is guaranteed to be between 10 and 99 inclusive, so the first digit is always nonzero.
Each rectangle is a grid of $ai$ columns and $bi$ rows. We may color individual cells one by one. Whenever a row becomes completely colored, we gain one point. Whenever a column becomes completely colored, we also gain one point. The rectangles are independent.
We are placing weighted objects onto a grid, but the score is not just the sum of values on the grid. Instead, every placement contributes multiple times: each cell participates in several overlapping fixed-size $k times k$ sub-squares, and the total score is the sum over all…
We are given a list of integers written on a board, and one of them might be a corrupted representation of a number of the form $10^x$ where $x ge 2$. The corruption happens because the exponentiation symbol '^' was lost.
The problem asks us to check whether a string matches a numeric template. The template is an array of integers where the same number should correspond to the same letter in a string, and the same letter should correspond to the same number.
Normalize the speeds so that Warnicke moves with speed $1$ and the criminal with speed $\frac12$.
We are given an array of integers arranged cyclically, which means the first and last elements are considered adjacent.
We are asked to process a sequence of integers and find a subsequence that maximizes length while containing no repeated elements.
Working
We are asked to count deterministic max-heaps that can be formed on a perfect binary tree after performing a sequence of increment operations. The tree has height $n$, so it contains $2^n - 1$ nodes. Initially, all node values are zero.
Codeforces 2001E1: Deterministic Heap (Easy Version)
We are asked to reconstruct a hidden tree with n nodes by interacting with a judge that answers specific distance-based queries. Each query "? a b" returns the node x that minimizes the absolute difference in distances from a and b.