brain
tamnd's digital brain — notes, problems, research
41641 notes
We are given an array of integers, and for each element we are allowed to repeatedly turn off any single set bit, but only up to once per bit per element, which is equivalent to saying each number can be reduced to any value obtainable by subtracting a sum of distinct powers…
We start with a row of $n$ positions, each containing a distinct element. A pointer $p$ is also given, initially somewhere between $0$ and $n$, inclusive. We repeatedly remove elements from the current row until nothing remains.
We are given a binary string and a threshold value $K$. The string is considered “bad” if it contains a run of $K$ or more identical consecutive characters, meaning a block like $0000$ when $K = 4$, or $111$ when $K = 3$.
We are given a row of $N$ identical toilets, all initially empty. People arrive one after another, and each person must choose a toilet that is currently empty and also has no occupied neighbor on either side.
We are given a single uppercase string that was produced by a two-step process. First, someone had an original string t. Then they created a second string by taking all distinct letters of t, sorting them alphabetically, and writing each letter once.
We are asked to pay an exact amount using only two coin types, one worth 2 units and the other worth 5 units. The goal is not just to determine whether the sum can be formed, but to construct a combination of coins whose total value is exactly the required amount and uses as…
We are working with numbers formed from decimal strings, but only two digits actually matter: 6 and 9. A number is considered “nice” if it can be interpreted under a very specific ordering rule that effectively treats these two digits as comparable states, and all other…
We are given a permutation of size $n$, meaning each number from $1$ to $n$ appears exactly once but in arbitrary order across positions $1$ to $n$. The task is to transform this permutation into the sorted order where value $i$ sits at position $i$.
We are given a multiset of positive integers written on cards. From these cards, we may select any subset, and the value of that subset is defined as the product of all selected numbers.
We are asked to construct a simple polygon with exactly n vertices placed on integer grid points within a large bounding box.
The task simulates a fixed registration dialogue for a contest team, where the only variable part is the team name.
We are given a sequence of fixed points $C1, C2, dots, Cn$ on a plane and a special point $D$. For each $Ci$, we must choose a circle centered at $Ci$, with radius $ri$.
We are given a connected undirected graph that forms a tree, rooted at room 1. Each room contains a number of exhibits, and the total number of exhibits across all rooms is at most 2 · 10^5. Petya starts at room 1 and must end at room 1.
We are given a fixed 32-bit unsigned integer $a$. For each test case, we must find all 32-bit unsigned integers $b$ such that two quantities become identical when viewed modulo $2^{32}$: the first quantity is the power $a^b$, computed in the usual mathematical sense, and the…
We are given a sequence of bytes, each value initially in the range from 0 to 255. The process repeatedly compresses adjacent pairs by repeatedly selecting a specific ordered pair of values and collapsing all its occurrences in one batch operation.
We are given a sequence of tasks laid out in a line, where each task has an integer difficulty. A character named Vanya has a skill level that starts at a low value and can increase as he completes tasks.
We are given a collection of independent encounters indexed by $i$. For each encounter there are two time costs, $ai$ and $bi$, corresponding to how much work is required if it is handled by two different fighters.
The problem asks us to evaluate a real number that is given in a mixed decimal form, where part of the decimal expansion does not repeat and another part repeats forever.
Each test case describes a very small scheduling system that receives a list of tasks. Every task has an identifier and a priority value, and the system must decide the order in which tasks are executed.
We are asked to split a given number of soldiers into several nonempty groups whose sizes are positive integers summing to $N$.
We are given a tree describing a network of storage rooms. Each room is a node, and each connection is a railroad. The structure is not arbitrary: it has a strong restriction that every node lies within distance at most two from a single central path.
We are given a production system that can be modeled as a directed acyclic graph of jobs. Each job takes a fixed amount of time to process, and moving from one job to another incurs an additional transfer time.
We are given several test cases. Each test case describes an undirected simple graph, but not in the usual edge-list form. Instead, the graph is specified indirectly as a collection of triangles.
We are given a fixed amount of cash and a list of bank deposit opportunities. Each opportunity requires spending a specific amount of money to participate, and in return it yields a fixed amount of interest.
We are given a set of items and a set of boxes. Each box has a fixed capacity $T$. Each item has one of two possible sizes, and these sizes are very “polarized”: every item is either very small (at most $T/4$) or very large (at least $3T/4$).
We are given a set of axis-aligned rectangular slabs placed inside a larger rectangular garden. Each slab has a fixed vertical position, meaning its bottom and top y-coordinates are immutable, but we are allowed to shift slabs horizontally left or right.
We are given a grid representing the seating layout of an airplane. Each cell is either empty or contains a virus source.
We are given very large decimal numbers, each representing a banknote serial number. A number is considered valid if it is divisible by 13.
We are given a deterministic way of building a binary tree-like structure by inserting values from 1 up to n into a skew heap.
We are given a permutation of numbers from 1 to n, and we define its “cost” as the total displacement of elements from their natural positions, specifically the sum over all positions i of The task is not only to count or optimize this value, but to enumerate permutations…
We are given a complete k-ary tree of fixed depth, meaning every internal node has exactly k children and all leaves lie at the same depth. Each edge in this tree is independently removed with a given probability p (modulo a prime), so each edge either survives or disappears.
We are given a tree, and some subset of its edges is marked as critical. The process is defined on edges rather than vertices: we start from one chosen edge, treat it as “current”, and repeatedly move to an unvisited edge that shares a vertex with the current one.
We are given two expressions that describe how a labeled tree is constructed. Each expression is a binary structure written using a single leaf symbol 1 and a binary concatenation written as parentheses containing two subexpressions written side by side.
We are given three positive integers $pA, pB, pC$. Each integer defines the period of an infinite binary string. That means the string is completely determined by its first $p$ bits, and then those bits repeat forever.
We are given a graph that represents a prison-like maze. There is a special starting node where K begins, a set of nodes called hoppers, and another set of nodes called doors. The remaining structure is an undirected graph connecting all nodes.
We are given a string of digits and we need to reason about segments of it through the lens of arithmetic modulo 4.
We are given a permutation and a two-player game played on it. The goal of the game is to transform the permutation into a fully sorted sequence in increasing order.
We are given a sequence of values over time, each value being either minus one, zero, or plus one. Each value represents the intrinsic “effect” of a bottle bought on that day.
We are given a mine shaped like a rooted tree of shafts, where shaft 1 sits at the very top and every other shaft has exactly one connection upward that leads to a unique parent. Because of this structure, between any two shafts there is exactly one simple path.
We are given a set of at most 20 cows, each identified by a bit position. Initially all cows are on the left bank of a river, and the goal is to move them all to the right bank.
We are given a long bracket string s that uses eight bracket symbols, four opening types and their matching closing counterparts. From this string we extract m substrings. Each substring is treated as an independent sequence, and we are allowed to pair some of these substrings.
We are given a sequence of days, and on each day we want to compute how many “extra hours of effort” accumulate from a set of scheduled contributions. Each contribution starts at some day $x$ and then affects all days from $x$ to the end $n$.
We are given a single string of length $N$ that is currently in state $A$, and we want to transform it into a target state $B$. Each position holds either a lowercase letter or a dot. A dot represents an empty cell.
We are given a hidden arithmetic expression built from the numbers 1 through N, each used exactly once and arranged in some unknown order. Between consecutive numbers there are operators chosen from plus, minus, and multiplication.
We are given a directed complete graph of planets where each ordered pair of planets may or may not have a hyperjump available.
The task is an interactive exploration problem on a hidden rectangular grid of size at most 30 by 30. Each cell in the grid has four potential neighbors in the cardinal directions, so the underlying structure is the full grid graph.
We are given a sequence of milk batches, each batch has two attributes. The first is a coefficient $bi$ which represents how much flavor Vova gains per unit of heating temperature.
We are given a fixed eight-team single-elimination bracket, already arranged in quarterfinal order from top to bottom. Each team has a unique name and a unique integer strength.
The task is interactive and is not about computing an answer from a fixed input. Instead, we are gradually building a pool of symbols by repeatedly choosing one of six dice types, rolling it, and observing a randomly returned symbol.
We are given a set of points in 3D that form a convex polyhedron. The task is not to reconstruct the polyhedron itself in a combinatorial sense, but to output a planar “net” of it, meaning we must unfold its surface into the plane so that every face becomes a flat polygon in…
We are working on a grid where each cell has a value computed deterministically from its coordinates. That value is taken modulo 4, and it decides how a chess piece behaves when it is currently standing on that cell.
We are given a rooted tree of courtiers where node 1 is the king. Every other node has exactly one parent, so the structure is a rooted tree with edges directed away from the king. We must choose a subset of nodes to be “knights”.
We are given a small system of boys and girls where each boy has a fixed list of girls he is willing to dance with. The process is conceptual rather than simulated: boys go in increasing order, and each boy tries to pick a girl he likes who is still available.
We are given positions of several kings placed on a 100 by 100 grid. In one action, we choose a single king and start moving it step by step in any of the eight directions, so every move changes its cell to one of the adjacent squares including diagonals.
A perfect binary tree is being built level by level. After $n$ days, the tree has height $n$, root is node $1$, and every internal node $u$ has two children $2u$ and $2u+1$.
We are given an infinite line of rooms indexed by all integers. These rooms are partitioned into $n$ groups according to their value modulo $n$.
We are given a schedule planning problem. There are several people, and each person provides one or more time intervals during which they are available. The goal is to determine a single moment in time when the maximum number of people are simultaneously available.
We are given a left-to-right sequence of peaks, but their exact heights are not fixed. Instead, each peak has a range of possible heights derived from a noisy vertical photograph.
We are given five special intersections on an infinite grid of city blocks. Each block is connected by roads that run strictly horizontally or vertically, and every adjacent pair of intersections along a row or column corresponds to one road segment of equal length.
We are working with integers represented in binary, and a simple transformation based on bit counts. For every integer $k$ in a range starting from 1 up to $2^n - 1$, we perform a process that repeatedly replaces the number by the number of set bits in its binary representation.
We are given a number written in decimal form, and we need to construct another number that is strictly larger than it while satisfying a digit-wise restriction.
We are given a grid with 3 rows and N columns. Each cell contains either 0 or 1, representing votes for two candidates. We can think of each cell as a unit city with a binary label.
We are given a line of books, each with a value, and a process that removes books from the ends over time. At every second, two things happen in sequence: first, Keys may take exactly one remaining book from anywhere in the current segment, and then the fire burns the current…
We are given a long sequence $S$ that is constructed in a very specific way. Each operation takes the numbers from $1$ to $m$, randomly permutes them, and appends that permutation to the end of $S$.
We are given a graph whose vertices represent islands and whose edges represent direct travel routes between pairs of islands. The key structural constraint is that this graph contains no cycles, which means every connected component of the graph is a tree.
We are working with an array that changes over time through point updates. After each update, we need to evaluate a global quantity defined over all values that appear in the array. For any value x, we look at all subarrays that do not contain x at all.
We are given an undirected graph with a weight on each vertex and a cost function defined on step lengths of a walk.
We are given two arrays of equal length that represent two competing progress tracks over time. One array describes Jim’s daily gains and the other describes the pirates’ daily gains. What matters is not the raw values themselves but the cumulative difference between them.
We are given a sequence of operations that repeatedly transform an interval of integers. Initially, every integer in a fixed range is considered valid. Each operation shifts the entire current valid range either left or right by a given amount.
We are given a list of integers. The operation we are allowed to perform is to pick exactly two of these numbers, replace them with their sum, and then consider the greatest common divisor of the resulting multiset.
We are given an array of integers where we are allowed to select a contiguous segment and flip the sign of every element inside it. After performing this operation, we evaluate the resulting array by its minimum value.
We are given an undirected graph that represents locations connected by passages. The task is to determine which parts of this graph remain usable if we repeatedly enter regions where we can explore fully and return to the entry point, but we cannot afford to get stuck in a…
We are given a process that repeatedly produces fractions and then combines them. At some point, we end up with a collection of fractions of the form $frac{a1}{b1}, frac{a2}{b2}, dots, frac{ak}{bk}$.
We are given a square board of size $n times n$. We are interested in ordered pairs $(a, b)$, where both $a$ and $b$ are integers between $1$ and $n$, and we want to count how many such pairs satisfy a divisibility condition: at least one of the numbers $a$ or $b$ is divisible…
Each test case describes a fixed battle scenario with N independent attacks. Attack i targets goblin i and either deals full damage Ci or nothing, depending on whether its penetration Ai reaches the goblin’s defense Bi.
We are given several independent dice, where each die has its own list of face values. A single operation consists of rolling some of the dice, observing their outcomes, and deciding which dice to keep active for future rolls and which to lock permanently.
We are given a fixed dictionary of distinct words. Between any two words, we define a connection rule that depends only on their letters: two words are considered directly compatible if they share at least one common character.
We are given a rooted tree with node 1 fixed as the root. Two players start on two different nodes, Alice on node A and Bob on node B. They move alternately, with Alice starting first.
We are given a connected undirected graph with n nodes, where node i represents both a friend and their home. Each node has exactly one decision to make: it selects a “club” label from 1 to n, and multiple nodes are allowed to pick the same label.
We are given a complete graph with $n$ vertices. Each vertex initially has a color, and colors are given as integers. The graph structure itself is not really something we need to manipulate explicitly because every pair of vertices is connected.
We are given several independent test cases. Each test case describes a collection of music genres, where the i-th genre contains ci distinct songs.
The city is a rectangular grid of intersections, where each cell may contain a customer parcel that must be picked up. Movement is constrained by one-way streets: from any intersection you can only move either south or east.
We are building a very large multiset of monster HP values, each value chosen from the range from zero up to some maximum $N$. There are $R$ monsters, and the order of these values matters, so we are effectively dealing with sequences of length $R$.
We are given a rooted tree, and every node carries two values, one from array a and one from array b. Some entries in both arrays may be zero, and zero acts as a wildcard that can match anything.
We are given a string and a single allowed operation that modifies it by deleting characters. One operation works by selecting a contiguous segment of the string and also selecting a character, then removing every occurrence of that character inside that segment only.
We are asked to process multiple independent queries. Each query gives an interval $[a, b]$ and a target number $k$. For every integer $x$ in that interval, we convert $x$ into binary without leading zeros and count how many bits are equal to 1.
We are given a rectangular grid of size $h times w$. A token starts at the top-left cell $(1,1)$ and wants to reach the bottom-right cell $(h,w)$. Movement is constrained to only go right or down, so every valid path is a monotone path in the grid.
We start with a tree on n vertices. Then one extra edge is added between two previously non-adjacent vertices, turning the structure into a single cycle graph with exactly one cycle. We are not directly told which edge was added.
Each test case describes a vertical cave system with several shafts. You start at the top of one chosen shaft and move strictly downward. While descending, you may encounter horizontal tunnels placed at distinct depths.
I can’t write a correct editorial yet because the actual problem statement is missing. Right now all we have is the title “Maximum Satisfaction”, but no description of: what is given in the input, what choices are allowed, what “satisfaction” depends on, or what must…
We are given a sequence of points in the plane, representing stars visited in a fixed order. Consecutive stars are always aligned either horizontally or vertically, so each move between star $i$ and star $i+1$ is a straight segment parallel to an axis.
We are given the full structure of a directed acyclic graph, but the weights of the edges are unknown. The only way to learn anything about the weights is through an interactive oracle: we choose a pair of vertices $s, t$ and a scalar $c$, and the oracle returns the sum over…
We are given a string $S$ of length at most 40. Think of its characters arranged in a line. We also have an empty string $T$. We repeatedly remove characters from either the left end or the right end of the remaining $S$, and append each removed character to the end of $T$.
We are given a connected bipartite graph with up to 100 vertices, where each vertex has a positive weight. The task is not just to assign directions arbitrarily to edges, but to orient every edge so that a particular cost function becomes as small as possible.
The problem is essentially asking us to process a row of lanterns along a riverbank, where each lantern is either on or off. The input gives us a sequence of length n, and each position contains either a 0 meaning the lantern is unlit or a 1 meaning it is glowing.
We are counting a very specific family of rooted trees on labeled vertices from 1 to n. The tree is rooted at node 1, and labels behave in a monotone way along any root-to-node path: whenever we move away from the root, labels must strictly increase.
The task revolves around applying a very specific transformation to a single string using Python’s built-in list conversion semantics.
We are given a rooted tree with a value written on every vertex. The root is fixed at vertex r. Alongside this tree, we are allowed to repeatedly perform a structural modification that targets a vertex v (different from the root).
We are given a line of robots labeled from left to right. Robot $i$ starts at position $x = i$, and all robots begin moving left at time zero.
We are given an array and a segment tree that was built over it for range minimum queries. The tree is standard: every node represents a segment of the array, and stores the minimum value on that segment.