brain
tamnd's digital brain — notes, problems, research
43815 notes
The body is a long homogeneous cylinder of outer radius $R$.
We are given a target digit string s and a collection of known digit strings, all of the same length. The goal is to reconstruct s as a sequence of contiguous segments, where each segment must exactly match a substring taken from one of the known strings.
We are given a string of lowercase letters and an integer $k$, representing the number of colors available. The task is to color the letters so that, when we group the letters by color, each group forms a palindrome after any number of swaps within the same color.
We are given three fixed positions in a sequence: first value a, second value b, and third value c. We are allowed exactly one modification operation: choose one of these three positions and multiply it by some positive integer m of our choice.
We are given an array of positive integers of size $n$, and we want to know if we can turn it into a permutation of numbers from $1$ to $n$ by repeatedly dividing elements by two. Each division operation replaces an element $ai$ with $lfloor ai / 2 rfloor$.
Ah, now I understand completely. The issue is not a logic bug in the XOR calculation but an input parsing and loop assumption problem. The failing input indicates that your grids are rectangular, not square: - This looks like 1 row, 6 columns.
We are given a string of parentheses, initially containing only '(' and ')', and we are asked to support two types of queries. The first type changes specific matched parentheses into dots.
Two identical DC motors have their armature shafts rigidly connected, so both armatures rotate with the same angular velocity $\omega$.
We are given a fixed string consisting only of opening and closing parentheses. For each query, we are handed a segment of this string that is guaranteed to behave nicely in a structural sense, and we must count how many substrings inside that segment are also “nice”…
We are given a collection of spiders, each labeled with a number that represents its “leg configuration”, and a threshold value $k$.
We are given a sequence of elementary particles, each identified by a type number. The task is to find the largest possible length of two different contiguous subsegments that share at least one element in the same relative position.
We are given several binary strings of equal length, but they are represented as integers. Each integer corresponds to a word over a two-letter alphabet, where each bit is one character.
A parallel-plate capacitor has plate separation $d$.
- First line: t - number of test cases - For each test case: - First line: n - size of the grid (n x n) - Next n lines: n integers per line - the neighbor XOR sums There is no m in the problem, only n. The earlier input with 8 4 seems like an incorrect test input format.
Two transparent combs are superimposed and viewed against a uniform source of light.
We are working with a long array generated by a linear recurrence, and then a randomized process that repeatedly samples elements from this array and mutates the sampled value. At each of $k$ rounds, we pick a uniformly random index $idx$ from $0$ to $n-1$.
We are given a tree with $n$ vertices, where each vertex is either black or white. A "chip" can be placed on any vertex, and in each operation, you pick a black vertex $y$ different from the last chosen black vertex and move the chip one step along the shortest path from its…
The physical system is a car moving along a horizontal road.
We are given a multiset of weights, and we must split these values into three groups using two cut points on the number line.
We are given a short string where each character appears either once or twice. The task is to permute the characters so that whenever a letter appears twice, the gap between its two occurrences is identical for all such letters.
We are given a large integer, represented as a string of digits without leading zeros, and we are allowed to perform exactly one operation: pick two consecutive digits and replace them with their sum.
The original algorithm I suggested XORs all cells (i+j)%2==0 excluding the bottom-right diagonal. This produces the wrong result because it is misapplying the standard trick for this problem. The correct approach comes from observing the XOR-sum properties: 1.
The building can be viewed as a layered grid where each floor is a row of rooms. Moving horizontally inside a floor has a cost proportional to how far you walk and a floor-specific penalty factor, while moving vertically is only possible through directed ladders that may also…
We are given an array of distinct integers, and we can repeatedly add new elements to it. Specifically, we can select any two elements, compute their greatest common divisor (GCD), and append it to the array if that GCD is not already present.
We are given a multiset of values that form a cyclic array. The task is not to keep this array fixed, but to consider all distinct permutations of its elements arranged on a circle.
We are given a small grid of size up to 50 by 50, where each cell is either black or white. From any black cell, we are allowed to perform an operation that spreads blackness in a very specific way: we pick one black cell and either paint its entire row black or paint its…
We are given a classroom represented as a grid with $n$ rows and $m$ columns. Each cell is a seat. Tina can paint exactly $k$ seats pink, where $k$ ranges from 0 to $n cdot m - 1$. Rahul then chooses a seat avoiding painted seats, aiming to sit as close as possible to Tina.
The physical system is a refrigerator operating between the refrigerated compartment and the surrounding room.
We are given an even-sized $n times n$ grid of integers that was stolen, and instead of the original numbers, we only know the XOR of the neighbors of each cell. Our task is to compute the XOR of all the original numbers in the grid.
Two identical vertical cylinders are connected by a horizontal tube and filled with water.
We are asked to determine, for multiple starting positions in space, whether there exists a straight-line trajectory to the target position at the origin, potentially interacting with stationary obstacles represented as line segments.
We are given a tree where each edge carries a weight that represents how dangerous it is to traverse during a meteor storm. Alongside this structure, we maintain a dynamic set of “active” nodes, which represent buildings with open grocery stores. Initially, no store is open.
We are asked to analyze a two-player game between Alice and Bob. The game lasts for n turns, and in each turn Alice chooses a number between 0 and k.
Alice and Bob play a game of alternating choices over n turns. On each turn, Alice picks a number between 0 and k. Bob then decides whether to add or subtract that number from the total score, with the constraint that he must add at least m times over the entire game.
We are given a sequence of short strings, each representing a scene in a movie. From these scenes we are allowed to pick a subsequence, meaning we keep the original order but may skip some scenes. If we concatenate the chosen scenes, we obtain a single string.
We are given an array of non-negative integers and we are allowed to repeatedly cut off a prefix of the current array. For each cut, we compute the MEX of that prefix and append it to a new array.
We are given a continuous integer segment from $l$ to $r$, and we treat every number in this segment as an element of an array. The array is not arbitrary, it is fully determined by the interval, so its structure is very rigid.
We are asked to model a system where we can temporarily spend RAM to permanently increase RAM. Each software has two numbers: the amount of RAM it requires to run, and the amount of RAM it gives once used. Our PC starts with a certain initial RAM.
This problem is rated 3500 and its solution relies on a fairly deep structural characterization of graphs whose cycle space admits a consistent cyclic orientation.
We are given a set of distinct integers, each representing a vertex. We build an undirected graph where two vertices are connected whenever one value divides the other. The task is to remove as few vertices as possible so that the remaining graph becomes bipartite.
We are given an array of integers, and the task is to find a numeric range [x, y] and split the array into exactly k contiguous subarrays so that in each subarray, more than half of the elements fall inside the chosen range. The goal is to minimize the width of the range, y - x.
We are given an array of integers, and a set of allowed segment lengths. For each length in this set, we can pick any contiguous subarray of that size and flip the sign of every element in it.
This problem is rated 3500 and its solution relies on a fairly deep structural characterization of graphs whose cycle space admits a consistent cyclic orientation.
We are given a sequence of numbers, each initially unpainted. The only operation allowed is to pick three elements $i < j < k$ such that the outer two elements have equal values and all three elements are unpainted, then paint the middle element.
We are given an array of integers and allowed to perform a specific operation any number of times: pick a subarray of even length and overwrite the first half of it with the values from the second half.
We are given two arrays of equal length, and at each position we are allowed to decide which of the two values stays in the first array and which goes to the second array. Concretely, for every index independently, we may swap the pair or leave it as is.
We start with a tree of unit edges, rooted at vertex 1. The distance function $d(v)$ is simply the number of edges from node 1 to node $v$. So the quantity we care about initially is the height of the tree when rooted at 1.
We are given a sequence of class performance lengths, where each length represents the duration of a scene prepared by a class.
Two pistons of masses $m_1$ and $m_2$ close the ends of two connected tubes whose cross sectional areas are $S_1$ and $S_2$.
We are given a tree where every edge has weight 1, and we treat vertex 1 as the root. For every vertex, we define its distance as the shortest path length from vertex 1. The tree is initially fixed, but we are allowed to temporarily add one extra edge between any two vertices.
We are given two integers, initially called $a$ and $b$, with $a < b$. In one move we are allowed to either increment one of them by one, or replace $a$ by the bitwise OR of $a$ and $b$.
This problem is rated 3500 and its solution relies on a fairly deep structural characterization of graphs whose cycle space admits a consistent cyclic orientation.
We are asked to arrange the heights of $n$ consecutive pillars such that the heights form a permutation of integers from $0$ to $n-1$. The goal is to minimize the maximum bitwise XOR of any two adjacent heights.
The circuit consists of ideal voltage sources and resistors connected as depicted in Figure 4.
A small mass moves on a horizontal table attached to a fixed point by a spring.
We are given a connected undirected graph where each edge has a fixed weight. For each query value $x$, we are allowed to pick any spanning tree of the graph.
Working
This problem is rated 3500 and its solution relies on a fairly deep structural characterization of graphs whose cycle space admits a consistent cyclic orientation.
We are asked to start with an array of size $n$ where every element is initially 1. For each element $ai$, we can perform operations of the form $ai = ai + lfloor ai / x rfloor$, choosing $x 0$ as we like. Each element has a target value $bi$ and a reward $ci$.
The system consists of three open barrels containing water.
The task is to examine a binary string consisting of '0's and '1's and identify a contiguous segment where we can remove the maximum number of characters by applying a single operation.
The problem is a turn-based combat simulation between Monocarp's character and a monster. Each has an initial health and attack.
This problem is rated 3500 and its solution relies on a fairly deep structural characterization of graphs whose cycle space admits a consistent cyclic orientation.
We are given an array of hidden non-negative integers, and exactly one position in it contains a zero. Our only way to learn about the array is through queries that inspect any three distinct indices.
The system consists of a long rigid rod of length $L$ and mass $m$.
We are asked to maintain two integer arrays, A and B, under a sequence of operations called Fibonacci additions. Each operation specifies a segment [l, r] and an array to update.
We are given a string s of length n and a number k. We can perform exactly k operations on s, where each operation is either appending the reverse of the string to itself (s + rev(s)) or prepending the reverse (rev(s) + s).
We are asked to arrange $n cdot k$ items, priced from $1$ to $n cdot k$, into a grid with $n$ shelves and $k$ items per shelf. The key restriction is that the mean price of any contiguous segment of items on a shelf must be an integer. Each number must appear exactly once.
We are given an array of integers, and a process that runs left to right over this array. A person starts with some initial value and, at each position, must choose one of two actions: add the current array value to their running number, or XOR the current array value with it.
We consider a horizontal rod of length $l$ that rotates about a vertical axis passing through the point $O_1$.
This problem is rated 3500 and its solution relies on a fairly deep structural characterization of graphs whose cycle space admits a consistent cyclic orientation.
We are asked to reconstruct a hidden configuration of points on a line, one for each car, and assign each car a direction, left or right. After reconstruction, the configuration must explain two kinds of pairwise constraints.
We are given a sequence of points lying on a horizontal line, each with a coordinate and a positive weight. The task is to answer multiple queries about contiguous subarrays of these points.
Three communicating vessels contain water and are covered by pistons made of the same material and having the same thickness.
We have to modify an array so that no position is strictly greater than both of its neighbors. Such positions are called local maximums. The first and last elements are never local maximums because they only have one neighbor.
We are given an integer array and we are allowed to perform a very specific transformation: pick three indices in increasing order and overwrite the leftmost position with the difference of the two later values.
We are given several arrays, each containing small non-negative integers. For each array, we are allowed to repeatedly pick two different positions and replace both values with new numbers, as long as the bitwise OR of the chosen pair stays unchanged after the replacement.
We are given a permutation, meaning every number from 1 to n appears exactly once in some order. We are allowed to pick some subsequence of this array, remove those chosen elements, and then reinsert them as a block at the very front, preserving their relative order.
We are given the numbers from $1$ to $n$ for each test case, and we can repeatedly pick any two numbers $x$ and $y$, remove them, and add two numbers: $x+y$ and $ The input size allows $n$ up to $5 cdot 10^4$ per test case, with a total sum of $n$ over all test cases also…
This problem is rated 3500 and its solution relies on a fairly deep structural characterization of graphs whose cycle space admits a consistent cyclic orientation.
A conducting sphere of radius $r$ is connected to ground.
We are working on a tree where each vertex has a height value. The task is to place a set of “towers” on vertices, and assign each tower a positive integer efficiency.
We have two arrays of equal length. For every position, we may either keep the pair as it is or swap the two numbers inside that position. After deciding this independently for all indices, both arrays acquire new values.
We are given a line of piles, each pile containing some number of stones. The only allowed operation removes two stones from some middle pile and redistributes them as one stone to a pile on its left and one stone to a pile on its right.
We are given an array of integers and asked to compute a sum of “values” over all its subsegments. A subsegment is any contiguous slice of the array. The value of a subsegment is defined as the maximum cost of any partition of that subsegment.
We have an array and we are forced to perform exactly one operation. We choose a position that splits the array into two non-empty parts. Then we sort the left part and the right part independently.
Two balls of masses $m_1$ and $m_2$ are placed on a smooth horizontal plane and connected by a spring of stiffness $c$.
We are given a sequence of vertical panels, each panel having width one and a fixed height. Visually, each panel is attached to a horizontal bar at the top, and can be shifted upward or downward, but it must always remain connected to that bar, meaning every panel remains a…
We are maintaining a length-n array that starts completely uniform: every position holds value 0 and belongs to color 1. Over time, the array evolves through two kinds of updates. One type recolors a whole interval, replacing whatever colors were there with a new one.
We are given a painted canvas represented as a grid with n rows and m columns. Each cell in this grid contains a color, and the painting process was performed using only a 2 × 2 brush.
This problem is rated 3500 and its solution relies on a fairly deep structural characterization of graphs whose cycle space admits a consistent cyclic orientation.
We are given a permutation of length $n$, which is an array containing all integers from $1$ to $n$ exactly once. We are allowed to choose exactly one contiguous subsegment of the permutation and reverse it.
We are given a permutation of size $n$, which is an array containing all integers from 1 to $n$ exactly once in some order. From this permutation, we construct an undirected graph on $n$ vertices, where each vertex corresponds to a position in the permutation.
This problem is rated 3500 and its solution relies on a fairly deep structural characterization of graphs whose cycle space admits a consistent cyclic orientation.
Two helical springs are made from identical pieces of steel wire.
A sample of an unknown purified gas is contained in a cylinder.
We are exploring an unknown connected graph, but we never see global labels of vertices or edges. Instead, we start at a known vertex and repeatedly move along incident edges chosen locally.
The problem presents an interactive treasure hunt on a hidden undirected graph. Each vertex corresponds to a junction with a treasure. You begin at a specified start vertex, and every time you visit a new vertex, you collect the treasure there.
This problem is rated 3500 and its solution relies on a fairly deep structural characterization of graphs whose cycle space admits a consistent cyclic orientation.
We are exploring an unknown connected graph. We know the complete graph beforehand, including every edge, but once the interaction starts we lose the vertex labels.