brain
tamnd's digital brain — notes, problems, research
43815 notes
We are asked to divide a rectangular field of size $n times m$ between Alice and Bob. The field contains $k$ fountains at distinct cells, and Alice wants to choose a monotone path-moving only right or down-from the top or left side to the bottom or right side such that she…
We are given a tree with n vertices. Each edge in this tree has a weight. There are m queries of two types. The first type changes the effective weights of all edges by XORing them with a given number y.
A monotone path that moves only right and down separates the rectangle into a south-west part owned by Alice and a north-east part owned by Bob. I
We are given an array of positive integers. From it, we can derive a second array by replacing every adjacent pair with their greatest common divisor. This derived array reflects how “compatible” neighboring values are in terms of shared divisors.
Let
We are asked to determine whether a given array b could have been produced from an original array a by applying a sequence of assignment operations where the target indices are lost, but the values assigned in order are known.
We are given two rectangular grids of numbers, both of size $n times m$, and together they contain exactly the numbers from $1$ to $n cdot m$, each appearing once. So each matrix is just a rearrangement of the same set of tiles.
We are given several independent scenarios where a collection of numbered cubes is rearranged based on their values. One cube is special because it is the favorite, identified by its original position.
Each test case describes a small problem set that Vlad already owns and a target number of rounds he wants to organize. Every problem has one of seven possible difficulty labels from A to G.
We need to construct an array of length n such that every adjacent product is unique. More precisely, the values $$a1a2, a2a3, dots, a{n-1}an$$ must all be different.
We are given a rooted tree where every node has a label. The structure is restricted so that each node has at most two children, but otherwise it is still a general rooted tree.
We are given a set of segments on the number line. Each segment also carries a value $ai$. Two segments are considered related if their intervals overlap at least at one point, including touching at endpoints.
We are given a sequence of positive integers where some elements have gone missing and are represented by -1. The original sequence had a special property: for every consecutive pair of numbers, either the first number is the floor of half of the second, or the second is the…
We are given a range of integers $[l, r]$. Turtle chooses a number $x$ from this range. After that, Piggy repeatedly divides $x$ by one of its divisors greater than or equal to $2$, earning one point for each division, until the number becomes $1$.
We start with an infinite array where position $i$ initially contains the value $i$. So the array begins as a simple identity mapping: index equals value. Every second, all positions update simultaneously.
In this problem, we are given an array consisting of consecutive integers starting from zero. A subarray is considered k-good if every element within it has no more than k ones in its binary representation.
We are given an array that changes over time through point updates. After each change, we must answer a structural question about the array: what is the shortest contiguous segment such that, if we sort only that segment, the entire array becomes sorted in non-decreasing order.
We are given a grid of numbers representing mountain heights, together with a second grid that splits each cell into one of two groups. One group is marked as snowy-capped, the other is non-snowy.
We are asked to simulate a process on a number $x$ using another number $y$ and repeating it $k$ times. Each operation consists of two steps performed in order: first, increment $x$ by one, and second, divide $x$ by $y$ as many times as possible while $x$ remains divisible by…
In this problem, we are given a soccer game scenario where Dima remembers two scores: one just before he got distracted and another when he returned. Each score consists of the goals of the two teams. The game progresses one goal at a time for either team.
We are asked to simulate a game with a deck of cards arranged in a specific order. Each card has a positive integer on it.
Consider the equation
We are given a tree of n nodes where each node has an associated integer value. The problem asks us to process multiple queries where each query specifies two nodes, x and y.
There are two kinds of balls. The first k balls are special, the remaining n-k are ordinary. Every ball has a value. The balls are removed one by one in a uniformly random order. The current player takes the chosen ball and adds its value to their score.
We are given two grids, a and b, each of size n by m. Every cell in the grids contains a value from 0 to 2. Our goal is to transform grid a into grid b using a specific operation any number of times.
We are given an array and we look at every possible contiguous subarray of length at least two. For each subarray, we compute a value defined as the smallest XOR among all pairs of indices inside that subarray.
The previous proof contains critical errors in both parts.
We are given two arrays of the same length, and each array is a permutation-like structure in the sense that all values inside each array are distinct.
We are asked to split a linear cake of n pieces among Alice, Bob, and Charlie. Each person values each piece differently, and the total value of all pieces is the same for everyone.
The figure is the regular hexagon of side length $2$ subdivided into $24$ congruent equilateral triangles.
We are asked to construct an array of positive integers for each test case such that a family of divisibility conditions is satisfied simultaneously for every possible value of a parameter $k$ from 1 to $n$.
We are given a tree with n nodes, and we can perform a single “shuffle” operation on it. The shuffle consists of picking any node as the new root, removing it from the tree, recursively shuffling each resulting subtree, and then attaching all the shuffled subtree roots back…
We are given a set of $n$ towers located at distinct points in the plane, with the guarantee that no three towers are collinear and no four towers lie on the same circle. You initially control two of these towers. The goal is to "capture" all towers by a series of operations.
We are given a permutation of numbers from 1 to n. The task is to sort this permutation using a special operation that allows moving a continuous subarray of length k to any position in the array.
We are given a hidden integer array a of length n, where each element must stay within the range [-m, m]. We never see a, but instead we are given a sequence of constraints that describe either prefix sums or suffix sums of this array.
We process the array from left to right while maintaining a value c, initially 0. For every element a[i], we have two choices. We may replace c with c + a[i], or replace it with Among all possible procedures, let k be the largest final value that can be achieved.
We are asked to find the number of nonempty strings $t neq "a"$ such that a given string $s$ can be split into pieces where each piece is either $t$ or the single character "a", with the additional constraint that at least one piece must equal $t$.
Codeforces 1984A: Strange Splitting
We are processing a sequence of numbers while maintaining a running value that starts at zero. At each position, we must decide between two actions: either add the current number directly, or add it and then take the absolute value of the result.
We are given a number $x$, and we want to decide whether it can be expressed as the sum of two positive integers that satisfy a very specific digit restriction. Each of the two addends must have all digits in the range 5 to 9, and both numbers must have the same number of digits.
We are given a grid consisting of n rows and m columns, where each cell is either empty ('.') or filled (''). A connected component of filled cells is a set of '' tiles where you can move between any two tiles by only traveling along adjacent tiles sharing a side.
The quantity $q(n)$ equals the sum, over all partitions $\lambda$ of $n$, of the number of distinct values appearing among the parts of $\lambda$.
We are given a grid of size $n times m$ where each cell is either empty ('.') or filled (''). Connected components of '' are sets of cells that can reach each other by moving up, down, left, or right.
The problem asks us to count numbers $n$ in a given range such that multiplying $n$ by an integer $k$ scales the sum of digits by exactly $k$. Formally, if $D(n)$ is the sum of digits of $n$, we want all $n$ in $[10^l, 10^r)$ satisfying $D(k cdot n) = k cdot D(n)$.
We are asked to simulate a battle with a single boss that has a starting health h. The player has n different attacks. Each attack i deals ai damage and has a cooldown ci, meaning that once used, that attack cannot be reused for ci turns.
We are asked to place a small box with integer side lengths inside a larger box in 3D space. The small box must have a specific volume $k$ and must align with the axes, with all corners at integer coordinates.
The reviewer correctly identified a critical error.
We are given a grid made of dots and hashes. Somewhere in this grid there is a shape formed by all cells whose Manhattan distance to a hidden center is strictly less than a radius. This creates a diamond-shaped region aligned with the grid axes.
The problem asks us to analyze prefixes of an integer array and determine which prefixes are "good" according to a specific rule. A prefix of length $i$ is considered good if there exists an element in the prefix equal to the sum of all other elements.
We are given two strings, each exactly three letters long, and our task is to swap their first characters. For each test case, the input provides two strings, and the output should reflect the two new strings formed after the swap.
We are asked to select a number $x$ between 2 and $n$ inclusive such that the sum of all multiples of $x$ that do not exceed $n$ is maximized. For example, if $n = 15$ and we pick $x = 2$, the multiples are 2, 4, 6, 8, 10, 12, 14, and their sum is 56.
We are given a permutation of integers from 1 to $n$, and we are asked to count how many pairs of indices $(i, j)$ satisfy $i < j$ and $pi cdot pj$ divisible by $i cdot j$.
We are given a permutation of length $n$, meaning every number from $1$ to $n$ appears exactly once, but in some shuffled order.
We are given a connected undirected graph. Between any two vertices, we can ask whether there is a path connecting them. If a path exists, that pair contributes to the final answer.
We are given a string of digits, and our goal is to insert exactly $n-2$ arithmetic symbols, either plus or multiplication, between digits to form a valid arithmetic expression.
We are given an integer array and a fixed increment value $k$. We are allowed to reorder the array arbitrarily before doing anything else, and then repeatedly apply an operation that increases a single chosen element by exactly $k$.
Let
The problem asks us to stabilize a matrix by repeatedly decreasing “peaks,” which are cells strictly larger than all their neighbors. The matrix is given as an $n times m$ grid of integers.
We are given three integer points on a one-dimensional number line, specifically the X axis. The task is to find a single integer coordinate such that the sum of the distances from this chosen point to the three given points is minimized.
We are given a starting string and a multiset of update operations. Each update consists of a position in the string and a lowercase letter.
A square $ABCD$ rotates about its fixed center $O$, while a fixed line $l$ is taken as the $x$-axis.
The coordinate setup in the proposed solution is correct and can be carried through to completion.
We are given a rooted tree with integer values assigned to each node. The tree is rooted at vertex 1. A tree is considered wonderful if, for every non-leaf vertex, its value is at most the sum of the values of its immediate children.
We are asked to simulate a garden of flowers arranged in a line, where each flower has an initial height. The wind blows from the left every second and decreases the height of some flowers according to a strict rule: a flower will shrink if it is the last flower in the line or…
We are asked to sum over all permutations of numbers from 1 to $n$, a cost function that depends on three characteristics of each permutation: the number of prefix maximums, the number of suffix maximums, and the number of ascents.
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.