brain
tamnd's digital brain — notes, problems, research
41650 notes
We are given two different spanning trees over the same set of $n$ vertices. One tree, call it $T1$, represents the main network, and the second tree $T2$ is a backup structure. Each edge in $T1$ is a potential failure point.
We are given a set of points in the plane, with the restriction that no three points lie on a single line. For every point (p), we want to count how many subsets of exactly four other points can form a simple quadrilateral that strictly contains (p).
We are given two circular lists of strings. The first list has size $n$, the second has size $m$. Each year $y$ produces a name by taking the $y$-th string from the first list and the $y$-th string from the second list, both indexed cyclically, and concatenating them.
We are given a collection of integer sequences, and we consider ordered pairs of them. For any pair of sequences $sx$ and $sy$, we concatenate them to form a longer sequence $sx + sy$.
Each lecture in the conference has two possible time schedules, depending on which venue is chosen. If we pick venue A, every lecture follows its A-interval. If we pick venue B, every lecture follows its B-interval.
We are given a set of people placed on integer points on a line. Each person starts at a fixed coordinate and is allowed to move at most one step left, stay where they are, or move one step right.
We are given a tree with $n$ vertices, where each vertex represents a lamp. One of these lamps is directly connected to a power source, and from it power spreads through directed connections formed by the wires of the tree.
We are given a set of fixed points on a number line, each representing a Christmas tree. We are also asked to place another set of points representing people, but with a twist: each person contributes cost equal to the distance to the nearest tree, and we want to choose all…
We are distributing a fixed number of identical candies among a fixed number of children. Each child must receive a non-negative integer number of candies, and we are allowed to leave some candies unused.
We are interacting with a hidden binary string $s$ consisting only of characters a and b. We do not know its length, but it is at most 300. Our task is to discover $s$ using queries.
We are given a collection of triangles that once formed a triangulation of a convex polygon with $n$ vertices. Each triangle corresponds to one cut made during a process where we repeatedly remove a boundary triangle from a convex polygon until nothing remains except the…
We are given several independent test cases. In each one, Vasya has a budget and a list of item prices. He wants to maximize how many items he can take from the store. The store has a special promotion with groups of two items.
We are given a list of item prices and a budget. Vasya wants to maximize the number of items he acquires. He has two ways to buy: he can purchase a single item at its full price, or he can activate a bundle purchase where he chooses a “base” item and simultaneously takes up…
We are given two uppercase strings, one representing Jeff’s current product name and another representing a competitor’s product name. We are allowed to improve Jeff’s name by swapping at most one pair of characters inside his string. We may also choose to do nothing.
The circuit is given as a fully parenthesized expression that builds a tree of components. Leaves are individual resistors, each represented by . Internal nodes are either series connections or parallel connections over two or more subcircuits.
We are given a weighted tree with $2k$ vertices. On these vertices we must place $2k$ people, where the people are grouped into $k$ fixed pairs.
We are given a tree where each node represents a “nesting place” that contains two types of insects: bees and wasps. Every insect votes for its own side, so bees always contribute to the bee count of a region and wasps always contribute to the wasp count.
We are given a grid of size $r times c$, where each cell is either $A$ or $P$. The goal is to convert every $P$ into $A$ using a special operation that behaves like a directional flood from a chosen line segment.
We are given a string consisting of uppercase and lowercase Latin letters. The task is to apply at most a fixed number of operations, where each operation flips the case of every character in a contiguous segment of fixed length.
We are given a permutation of the numbers from 1 to n, and a rather unusual procedure that breaks this permutation into consecutive “blocks” based on reachability through functional edges defined by the permutation itself.
The situation is a stack of uniquely numbered items, where only the top of the stack is directly accessible. A sequence of operations asks us to repeatedly remove specific items in a given order.
We are given a tree with n labeled vertices. The task is not to manipulate the tree directly, but to construct a completely different object: n line segments on the number line, using the integers from 1 to 2n exactly once as endpoints.
We are given several independent test cases. In each test case, we start with a list of positive integers. One operation lets us pick a value $c$, but only if it is even, and then we simultaneously replace every occurrence of $c$ in the array by $c/2$.
We are given a multiset of integers, and we are allowed to select some of them and arrange the selected elements into a rectangular grid. Every chosen element occupies exactly one cell, and the grid is completely filled with chosen values.
We are given a string consisting of lowercase letters. Certain length-3 patterns are considered “bad”: specifically, the substrings "one" and "two". A string becomes unacceptable if any such bad triple appears anywhere inside it.
We are given a directed friendship graph of $n$ users, where each user lists some other users as friends. The important detail is that friendship is not guaranteed to be mutual. If user $u$ lists $v$, it does not imply that $v$ lists $u$.
We are working with a byte array, and a checksum function, CRC32, that compresses the entire array into a single 32-bit value.
We are given a sequence of moves for a robot on an infinite grid starting from the origin. Each character in the string tells the robot to move one step in one of the four cardinal directions.
We are given a line of blocks, each painted either black or white. The only allowed move is to pick two neighboring blocks and flip both of them at the same time, turning white into black and black into white.
We are given a toroidal grid of size $2^k times 2^k$, where each cell contains a 60-bit integer. The grid wraps around both horizontally and vertically, so shifting beyond an edge brings us back to the opposite side.
We are given an array of integers where each position i has a value a[i] constrained in a tight interval that depends on its index. The i-th element is never too negative and never too large: it always lies between i − n and i − 1.
The array defines a complete ordering between positions: for every pair of indices $i < j$, we draw a directed comparison that becomes an undirected edge if the value on the left is smaller than the value on the right.
We are given several test cases, and each test case provides an array of integers. The task is to determine whether there exists a contiguous segment of this array whose spread is large enough compared to its length.
We are given a binary string and asked to count how many of its contiguous substrings satisfy a very specific structural constraint. A substring is considered valid if it contains at least one 1, and if its total length is divisible by the number of 1s inside it.
We are given a collection of points on a plane, each with integer coordinates, and we must split them into two nonempty groups. After splitting, every pair of points produces a distance value, since we consider Euclidean distances between all pairs.
We are given an array of nonnegative integers, and we are allowed to append at most three additional numbers. The goal is to make the final multiset of numbers satisfy a very specific algebraic condition: the sum of all elements must equal twice their bitwise XOR.
We are given an unknown array of distinct integers. We cannot read it directly. Instead, we can query any subset of exactly k positions, and the device returns the position and value of the element that would rank as the m-th smallest among those k values.
We are given a permutation of the numbers from 1 to n. The goal is to understand how expensive it is, in terms of adjacent swaps, to force the numbers 1 through k to appear as a contiguous block in increasing order somewhere inside the array.
We are given a multiset of applications, each belonging to a category. The only thing that matters about a category is how many apps it contains, so the input can be compressed into frequencies of each distinct category. We must place all apps into “screens”.
We are maintaining a text editor that supports three kinds of operations: moving a cursor left or right along a growing line, and overwriting the character at the current cursor position.
We are given a line of positions from 0 to n+1. A group of soldiers starts at position 0 together with the player character. Each soldier has a strength value, and traps placed along the line may kill soldiers whose strength is too low when they enter certain positions.
We are given a complete system of lockers where each locker belongs to one person and has a weight. We are allowed to install exactly $m$ undirected connections between distinct lockers. Each connection between locker $u$ and $v$ costs $au + av$.
We are given a hidden permutation of size $n$, but we never see it directly. Instead, we see every consecutive block of three elements from that permutation. Each block is then scrambled internally, and all blocks are shuffled among themselves.
We are given a tree with $n$ nodes, where each node initially holds a unique label from $1$ to $n$. Someone then performs a process that is equivalent to choosing an ordering of all edges and, for each edge in that order, swapping the labels of its two endpoints.
We are given an undirected graph on vertices labeled from 1 to n, and we are allowed to add edges. The goal is to make the graph satisfy a very specific reachability constraint that depends on the natural ordering of vertices.
We are given a one-dimensional yard of length $N$, where each position is either usable soil or blocked by a rock. We want to place tiles on this line to maximize total “ghost repelling power”.
We are given several rectangular plots of land, and we want to place two identical rectangular buildings of size $A times B$.
We are given a tree with up to 4000 nodes, and we are allowed to pick a single node and remove it. Removing a node splits the tree into several connected components, each of which is itself a tree. The number of components equals the degree of the removed node.
We are given three groups of students determined by their preferred programming language. The task is to split all students into exactly three practice groups. The only restriction is that a single group is not allowed to contain both Assembler fans and C++ fans at the same time.
We are given a tree where each vertex carries a positive weight. The task is to select a subset of vertices that maximizes the sum of chosen weights, but with a strict geometric restriction: any two selected vertices must be more than $k$ edges apart in the tree.
We are given a building with floors from 1 to n. Moving between adjacent floors can be done in two different ways: stairs or elevator. Stairs have per-floor costs a[i], and elevator has per-floor costs b[i] plus a fixed overhead c every time you start an elevator ride.
We are given a collection of integer intervals on a number line. Each interval represents coverage over all integer points inside its range. A point becomes problematic if it is covered by more than $k$ intervals at the same time.
We are given several independent queries. Each query provides a large integer $n$, and we must output the smallest integer $m ge n$ such that $m$ can be expressed as a sum of distinct powers of 3.
Each child starts with exactly one book, and every day all books are passed simultaneously according to a fixed permutation. If a child i gives their book to p[i], then after one day the book moves one step along this directed edge.
We are working with numbers that can be decomposed using a very specific building system: powers of three, where each power can be used at most once.
We are given a system where each child initially holds a unique book, and every day each book is passed to another fixed child according to a permutation. After one day, every book moves once; after two days, it moves again under the same rule, and so on.
We are given a string made only of opening and closing brackets. Think of it as a circular sequence, where we are allowed to rotate it in any way.
We are given a multiset of stick lengths, and we must arrange all of them into a polyline starting at the origin. Each stick becomes one segment of this polyline, and every segment must be axis-aligned, meaning it is either horizontal or vertical.
The game can be viewed as a directed line of states arranged along a fixed serpentine path on a 10 by 10 grid. Each cell corresponds to a position on this path, starting from the bottom-left cell and ending at the top-left cell.
We are given a set of cities placed on a plane. Each city can be “powered” in one of two ways: either we directly build a power station in it, or we connect it (directly or indirectly through other cities) to a city that already has a power station.
We receive a string that is claimed to be produced by a slightly broken writing machine. The machine normally prints each spoken letter as itself, but two special letters behave differently: if the user says w, the machine writes uu, and if the user says m, it writes nn.
We are given two groups of runners, each group containing the integers from 1 to n. We must arrange each group into a permutation, one for the first track and one for the second track.
We are given a list of integers and a limited budget of unit operations. Each operation lets us pick a single element and move it by exactly one step, either up or down.
We are given a circular arrangement of cells, each cell holding either white or black. The system evolves in discrete steps, and each cell updates its color by looking at a fixed local neighborhood: itself and its two adjacent cells on the circle.
We are given a season summary for a football team, but instead of individual match results, only aggregated information is known. The team played exactly $n$ matches and accumulated a total of $p$ points.
We are given a building with two parallel rows of rooms, one row per floor, and each row has $n$ rooms arranged left to right. From any room, movement is allowed horizontally to adjacent rooms on the same floor.
Polycarp has two types of work tomorrow: writing lectures and drawing during practical classes. For lectures he must use pens, and each pen can be used for a limited number of lectures before it dries out.
We are given two strings of equal length, and we are allowed to perform exactly one swap operation. The swap is constrained in a specific way: we pick one position in the first string and one position in the second string, then exchange those two characters.
We are given two strings of equal length, and we are allowed to repeatedly fix them using a very specific operation: pick one character from the first string and one character from the second string, and swap them.
We are given a complete undirected graph on $n$ vertices. Every pair of vertices is connected, but edges come in only two possible weights: either 0 or 1. Among all $binom{n}{2}$ edges, exactly $m$ of them have weight 1, and every other edge implicitly has weight 0.
We are given multiple connected graphs, each with up to half a million vertices and edges in total across all test cases.
We are given a grid with exactly two rows and n columns. Every cell contains a value, and we are allowed to permute these 2n values arbitrarily between the cells.
We are given a system of $n$ people, each of whom owns exactly one cat, forming a natural pairing between person $i$ and cat $i$.
We are given a bracket string and we are allowed to perform exactly one swap of any two positions, possibly the same position.
We are given a row of seats indexed from left to right, and each seat has exactly one passenger. Every passenger has a planned time when they become ready to go to a water tank located just left of seat 1.
We are given a fixed string that we type repeatedly using a one-finger keyboard. The keyboard is defined by choosing a permutation of the first $m$ lowercase letters, and this permutation places each letter at a unique position on a line.
The system can only run if it never becomes empty, meaning at every minute it must contain at least one liter before consumption happens. It continuously drains one liter per minute for a total of m minutes, and its storage capacity is capped at c.
We are given a binary string consisting only of the characters A and B. Our task is to count how many of its contiguous substrings are “good” under a specific structural condition involving palindromes.
We can think of the cliff as a vertical line of heights from 1 up to h, with a special starting platform at height h. Some of these heights already contain usable platforms, while the rest are empty. You are standing at the top platform and want to reach ground level 0.
The corridor can be seen as a number line where all monsters start strictly on the positive side. Each monster is a point on this line, and Ivan repeatedly performs an operation that chooses a center point and affects every monster depending on whether it lies to the left, at…
We are given two binary strings of equal even length, and we are only allowed to modify the first string. The only operation available is somewhat unusual: we pick a prefix of even length and reverse that prefix in place.
We are given a circular arrangement of $n$ people, each holding some number of stones. The total number of stones is divisible by $n$, so there exists a target value $T = frac{sum ai}{n}$ such that the goal is to end with every position holding exactly $T$ stones.
We are given a circular playlist of tracks, each with a numeric “coolness” value. Starting from any chosen track, we keep listening forward in cyclic order, revisiting tracks as needed. While listening, we maintain the maximum coolness seen so far.
We are given a grid where some dominoes are already placed. Each domino always occupies exactly two adjacent cells. The placement has a special restriction: no row or column is allowed to contain cells from two different dominoes.
We are given a list of integers representing rating changes from a contest. The total sum of all these changes is exactly zero, meaning gains and losses perfectly balance out before any modification. The task is to transform each value independently into a “halved” version.
We are given a set of points in three-dimensional space, and we must repeatedly delete them in pairs until nothing remains. The restriction is not about distance or parity, but about geometry of axis-aligned boxes. At any moment, we pick two remaining points.
We are given an even number of distinct points in 3D space. The task is to repeatedly remove points in pairs until none remain.
We are given a line of $n$ boxes and a single token hidden in one of them. The game proceeds in $m$ rounds. In each round Alice points to a box index $ai$, trying to locate the token.
We are given a connected undirected graph with a special structure: it is a cactus, meaning every edge belongs to at most one simple cycle. On this graph, each vertex independently survives with probability $1/2$, otherwise it is deleted together with all incident edges.
We are given the integers from 1 to $n^2$, each representing a lab positioned by height, where smaller numbers are lower and larger numbers are higher.
We are given a rectangular grid with some blocked cells. Starting from the top-left corner, a token must move through the grid so that every unblocked cell is visited exactly once.
We are given three piles of stones. From these piles, Alice can repeatedly perform two kinds of moves. One move consumes one stone from the first pile and two stones from the second pile. The other move consumes one stone from the second pile and two stones from the third pile.
We are simulating a dynamic list of conversations ordered by “recency of appearance on screen”, with a hard cap on how many conversations can be shown at once. Each incoming message is tied to a single friend ID, and every ID corresponds to exactly one conversation.
We are maintaining a string of lowercase letters under two kinds of operations. One operation modifies a single position in the string, changing its character.
We are given a grid of size (h times w), initially completely empty, and two sets of constraints that describe how far blocks of filled cells must extend from the top and from the left.
We start with a perfect binary tree of height n, meaning every internal node has exactly two children and all leaves sit at the same depth. This tree contains exactly 2^n - 1 nodes and has a very rigid recursive structure: every subtree is itself a perfect binary tree.
We are filling an $n times n$ grid with integers from $1$ to $k$. The restriction is not about individual cells, but about structure: every row must contain at least one occurrence of the value $1$, and every column must also contain at least one occurrence of $1$.
The input describes a finite rectangular snapshot of an otherwise infinite grid of trees. Each cell is either burned or intact, and the grid fully contains all burned cells. Outside the grid, everything is guaranteed to be unburned.
We are given an array where each position stores a pile of blocks. At position i, there are ai identical blocks stacked. One operation consists of choosing some set of positions and removing exactly one block from each chosen position.
We are given a fixed answer key for a multiple-choice test of length n, where each question has a known correct option. We are also considering every possible way to fill in answers for the test, where each position can take any value from 1 to k.