brain
tamnd's digital brain — notes, problems, research
43815 notes
We are given an $n times m$ grid that represents a map. Each cell is either blocked or free. We start at the top-left cell $(1,1)$ and want to reach the bottom-right cell $(n,m)$.
We are asked to build a graph on $2n$ labeled vertices using exactly $2n-1$ edges. Since a connected graph with $2n$ vertices and $2n-1$ edges is necessarily a tree, the construction is really about designing a tree on these labeled nodes.
We are given two permutations of the indices of a string, and both permutations describe an ordering in which the hidden string must appear sorted.
We are asked to build a string of length $3n$ over the alphabet ${a,b,c}$, where each character appears exactly $n$ times. In addition to this balancing constraint, two forbidden patterns are given, each being a length-2 string.
We are given several chips placed on integer positions on a line. Our goal is to move all chips so that they end up on a single shared coordinate, using the cheapest possible sequence of moves. Each chip can move in two different ways.
We are given a tree where each node initially holds a color. There is also a target color for every node. The King performs a single walk on the tree. During this walk, whenever he traverses an edge, the endpoints of that edge swap their current flags.
We are given a complete bipartite structure with $n$ vertices on the left and $n$ vertices on the right. For every possible pair $(i, j)$, the edge between left vertex $i$ and right vertex $j$ exists independently with probability $p{ij}/100$.
We are given a collection of students, each described by two values. The first value encodes which of up to 60 possible algorithms a student knows, and can be thought of as a bitmask. The second value is a skill score.
We are given a grid with a small number of rows and a potentially large number of columns. The only operation allowed is to take any single column and rotate it cyclically any number of times.
We are given an undirected connected graph with up to 100,000 cities and roads, where each road has a unique identifier from 1 to m. Koala starts at city 1 and travels through the graph.
We are given an array that evolves over time through point updates. After each modification, we must compute a value called the difficulty of the array, which measures how far the array is from being representable as a sequence of contiguous uniform blocks.
We are given a sequence of digits and we must assign each position one of two labels, 1 or 2. After labeling, we form a new sequence by taking all digits labeled 1 in their original order, followed by all digits labeled 2 in their original order.
We are given a collection of snack types and a group of guests. Each snack type appears exactly once, so there are $n$ distinct items labeled $1$ to $n$. Each guest has two preferred snack types.
We are asked to build several regular polygons that all lie on the same circle, and we want to reuse the circle’s boundary points as much as possible. Each polygon is determined only by how many vertices it has.
We are given a sequence of integers and asked to choose three indices $i < j < k$. For each such triple, we take the value of the first element OR the bitwise AND of the other two elements. The goal is to maximize this expression over all valid triples.
We are asked to fill an $n times n$ table with all integers from $0$ to $n^2 - 1$ exactly once, so every number is used in a permutation of the grid cells.
We are given a hidden permutation of numbers from 1 to n. Instead of seeing the permutation directly, we are given a derived value for each position. For position i, the value s[i] is the sum of all elements that appear before i and are smaller than the element placed at i.
We are given a sequence of numbers and we are allowed to remove one continuous block from it, or remove nothing at all. After this single deletion, the remaining elements must all be different from each other.
We are given a growing collection of strings, where each new string is either a single character or an old string extended by exactly one character at the end.
We are playing an interactive guessing game where a hidden number $x$ is fixed in advance, and it lies in the range from $0$ to $2^{14}-1$. We are allowed to ask up to two questions.
We are given a collection of $n$ labeled tiles, where each tile carries a pair of integers $(ai, bi)$. Our task is to count how many ways we can reorder these tiles such that the resulting sequence avoids two very specific failure patterns.
We are building a linear structure along a road that is represented as a binary string. Each position corresponds to a unit segment of road. A 0 means normal road, while a 1 means a crossroad where the pipeline must be lifted. The pipeline normally runs at height 1.
We are placed on an even-by-even grid, and two knights start on different squares. One is white, one is black. Each player controls exactly one knight and alternates moves, starting with the white side if we choose it. A move is standard knight movement.
We are given a list of numbers, and we repeatedly perform an operation that picks two different positions and reduces both values by one. The goal is to decide whether we can eventually bring every value down exactly to zero using some sequence of such operations.
We are given a sequence of integers, and we want to count how many contiguous segments behave like a perfect permutation of consecutive integers starting from 1.
We are given a number $n$ and a parameter $k$. Starting from $n$, we want to reach zero using two allowed operations: subtract one, or if the current value is divisible by $k$, replace it with the quotient after dividing by $k$.
We are given a static array of integers and a parameter $p$. There is a peculiar addition routine used inside a hidden implementation: it adds numbers left to right, but after each addition it performs a conditional correction.
The input describes a tree where each node carries a color label. What we are asked to compute is not about a single path, but about all simple paths between ordered pairs of distinct nodes.
We are given an $n times n$ grid where movement is deterministic. From any cell, a traveller moves in a fixed direction until something changes that flow.
We are given a system split into two parts: a hand of cards and a pile of cards. Together they contain every integer card from 1 to n exactly once, while zeros represent empty placeholders that behave like dummy cards with no value.
We are given a collection of pictures, each with a positive weight. These weights determine how likely each picture is shown when Nauuo visits the website: a picture is selected with probability proportional to its current weight, so picture $i$ is chosen with probability $wi…
We are given a rooted binary tree where each edge carries either a fixed lowercase letter or a wildcard character. Every leaf defines a string obtained by walking from the root to that leaf and concatenating edge labels.
We are given a sequence of integers arranged on a line, and we want to answer connectivity queries between pairs of positions, but connectivity is not based on adjacency.
We are given a set of integers that represent allowed XOR “moves”. We are asked to build a permutation of all integers from 0 up to some power of two minus one, such that every adjacent pair in the permutation differs by a value that belongs to the given set.
We start with a register of qubits initialized in the all-zero computational basis state. Alongside this, we are given four classical bitstrings of length $N$, each describing one computational basis state on these qubits.
We are given a timeline from 1 to n and a collection of intervals, each representing a “red envelope” that becomes usable only during a certain time window.
We are given a list of stick lengths, and we are allowed to replace each length with any other positive integer. Changing a stick from its original length to a new length costs exactly the absolute difference between the two values.
We are given a connected undirected simple graph where every vertex has degree at least three. Along with the graph, we are also given an integer $k$. The task is not to compute a single structure, but to decide between two fundamentally different constructions.
We are given a directed graph representing a city map, where each road has a direction and a cost associated with reversing it.
We are given a stream of problems, each tagged with a difficulty from 1 to n. Arkady keeps a pool of created problems, and at any moment he is allowed to form a contest if he can pick exactly one unused problem of every difficulty from 1 to n.
We are simulating an interaction on a 999 by 999 grid with a single white king and many black rooks. The king moves first and can step to any of the eight neighboring cells.
We are given a string that mixes plain lowercase letters with two special symbols that always appear immediately after a letter. One symbol behaves like a weak modifier that allows the preceding letter to be either kept or deleted.
The process describes a snowball sliding downward from a starting height until it reaches the ground. At every integer height level, the snowball repeatedly changes its weight in three ordered phases: it first gains additional weight equal to its current height, then possibly…
We are given a rooted tree where each vertex contains a pile of cookies. Every vertex also has a cost for eating one cookie at that vertex, and every edge from a node to its parent has a cost for moving upward along it. A chip starts at the root.
We are given a fixed string and many substring queries. For each query, we take the substring and compute a specific aggregate over all its suffixes. For a string, the Z-function at position i measures how long the prefix of the string matches the substring starting at i.
We maintain a dynamic multiset of positive integers, where each number represents the weight of an eel. After every update, we are asked to compute a value called “danger”, which depends on an optimal process of repeatedly merging all eels into a single one.
We are given an array and asked to repeatedly build new structures on top of derived information from its subarrays. The first transformation takes every contiguous segment and replaces it with the greatest integer that divides all elements inside that segment.
We are given a rooted tree where vertex 1 is the root. Every vertex originally had a non-negative integer value written on it, but those values are now lost. What remains is partial information about prefix sums along root paths.
We are asked to build a rooted tree on vertices labeled from 1 to n, where vertex 1 is fixed as the root. Each node except the root has exactly one parent, so the structure is fully determined by the parent array.
We are given a grid of size $n times m$, where each cell contains one of four characters: A, G, C, or T. We need to construct a new grid of the same dimensions that satisfies a strict local rule: every 2 by 2 subgrid must contain all four different characters exactly once.
We are working with an infinite sequence that is not written explicitly, but generated recursively. The construction starts from a single value zero.
We are working with a tree where every subset of vertices defines a natural “cost” based on how large a minimal connected subgraph is when we are forced to include all vertices in that subset.
We are given a collection of bracket strings, each string being some mixture of opening and closing parentheses. From these strings, we are allowed to form disjoint pairs.
We are given a permutation and we must break it into several subsequences taken in order from the original array. Each element must belong to exactly one subsequence. Every subsequence must be strictly monotone, either strictly increasing or strictly decreasing.
We are given multiple independent queries, each describing a numeric interval from $l$ to $r$. For each interval, we must pick two different integers inside it such that one of them is a divisor of the other.
We are given a sequence of length $n$ that is supposed to be a permutation, except some positions are unknown and marked with $-1$.
We are given a string made of lowercase letters, and we are allowed to remove one contiguous segment from it. After removing that segment, the remaining characters must all be identical, meaning either nothing remains or every remaining character is the same letter.
We are working with two permutations of the same set of values from 1 to n. One permutation, call it a, gives a position-based arrangement, and the other permutation b also gives a different ordering of the same values.
We are working with a collection of points in a very low-dimensional space, where each point has up to five coordinates. The distance between two points is defined as the sum of absolute differences across each coordinate, which is the Manhattan metric.
We are given a hidden non-decreasing array a of even length n. We never see a directly. Instead, we are told half of its structure: for every symmetric pair of positions, the sum of elements at the ends is known.
We are given several independent strings made only of lowercase English letters. For each string, we are allowed to rearrange its characters in any order we want.
We are given a standard six-faced dice, but instead of the usual values 1 to 6, its faces contain the integers 2, 3, 4, 5, 6, and 7, all distinct. Each roll produces one of these numbers, and the score for a sequence of rolls is the sum of the visible faces.
We are given a line of players, each permanently assigned one of three Rock-Paper-Scissors moves. A tournament proceeds by repeatedly picking two adjacent players, playing a match, and removing the loser.
We are given a string that is the final result of repeatedly building another hidden string by alternately appending characters to the right and inserting characters to the left.
We are given a tree and a fixed total amount of “weight budget” $s$. Every edge must be assigned a non-negative real weight, and the sum over all edges must equal exactly $s$.
We are given a one-dimensional board where each cell contains a positive number of tokens. A chip starts on the left boundary of a chosen segment, and players alternate moves.
We are given a number $d$, and we want to decide whether we can split it into two non-negative real numbers $a$ and $b$ such that two conditions hold at the same time: their sum equals $d$, and their product also equals $d$.
We are given a weighted undirected graph and we first imagine running a shortest path computation from vertex 1. This produces a distance value for every vertex, which we can think of as the true optimal cost of reaching that vertex in the original graph.
We are given a sequence of pages, and each page contains a fixed number of two types of items: tables and formulas.
We are given a tree, meaning a connected graph with no cycles. On this tree we must pick two simple paths, each defined by choosing two endpoints. The endpoints of the two paths must all be distinct, and neither path is allowed to contain either endpoint of the other path.
We are given a fixed string, and each query asks us to compare two groups of suffixes of this string. Every element in the query is a starting position in the string, so each position represents the suffix beginning there.
We are given a single string consisting of lowercase letters, and we are asked to find any contiguous segment of this string such that no single character dominates that segment by appearing more than half of its length. If such a segment exists, we may output any one of them.
We are given a stack of books where each book has a unique label. The stack order matters: the first array describes which book is at the top, and the last element is at the bottom.
We are simulating a cyclic walk over an array of booth prices. Polycarp starts at position 1 and keeps moving clockwise in a fixed cycle. At each booth, he checks whether his remaining money is at least the price of one candy at that booth.
We are given an undirected graph of cities and roads. The task is to partition all vertices into some number of groups, and we are allowed to choose how many groups we want.
We are given two sets of points in the plane, one set belonging to Algoland and the other to Berland. The task is to construct exactly $a + b - 1$ straight line segments, each connecting one Berland city to one Algoland city. Every segment becomes a bidirectional road.
We are given a grid-like city structure formed by two independent labelings. There are horizontal streets and vertical avenues, and every street intersects every avenue, so each intersection corresponds to a pair consisting of one street and one avenue.
We are given a fixed collection of short file names and a stream of queries. Each query is a short string, and we must determine how many file names contain that string as a contiguous substring.
We are given a one-dimensional board of length $n$. Each cell can contain a monster with some HP, a potion that increases HP, or be empty. In addition, there are $m$ heroes initially placed on distinct empty cells, each hero starting with its own HP.
Each day produces some number of garbage units, and every unit must be thrown away either on the day it appears or on the following day.
We are given a collection of constraints over IPv4 addresses, where each constraint describes a contiguous interval of 32-bit integers. Some intervals are marked as forbidden and some are marked as required to remain accessible.
We are given a timeline of n days. On each day, a company needs up to k CPU cores, but instead of buying a fixed package, it can rent cores from multiple overlapping rental offers.
We are looking for a positive integer that satisfies two simultaneous constraints. First, it must be divisible by a given integer $d$. Second, when written in decimal form, the sum of its digits must equal a given value $s$.
We are asked to construct a geometric configuration of colored rooks on a huge grid so that connectivity properties encode a given graph on colors. Each color corresponds to a set of points on a $10^9 times 10^9$ grid. Each point is a rook.
We are dealing with a fixed universe of distinct coin types, where there are N possible different coins in total. Ivan already owns K distinct coins from this universe. Now M friends will each give him gifts, and each friend must contribute the same number of coins.
We are given a tree with $n$ vertices. Each edge is independently kept with probability $1/2$, so after the process we obtain a random forest. For every such resulting forest, we can build its adjacency matrix over real numbers and take its linear algebraic rank.
We are given a collection of quests, each with two reward values and a success probability. Every second, Ivan chooses one quest and attempts it.
We are given a tree with $n$ vertices and asked whether it can be generated by a very specific recursive construction parameterized by $k$.
We are asked to choose positions for $n$ knights on an infinite chessboard. After placing them, the board evolves deterministically: whenever an empty cell has at least four knights that can attack it in one knight move, a new knight is added there.
We are given an array of length ( n ), where each position must eventually contain an integer between 1 and 200. Some positions are already fixed, while others are unknown and marked as (-1).
We are given two very large binary numbers, not as integers but as strings. The first number is fixed throughout the process, while the second number keeps shrinking. The process is mechanical: start with the full value of b.
We are simulating a growing sequence of books placed on a shelf. Each book has a unique identifier, and we only ever add books either to the far left end or the far right end of the current arrangement. Over time, this produces a fixed linear ordering of all inserted books.
We are given a sequence of objects laid out from left to right, each with a positive size, and a fixed number of identical boxes, each having the same capacity.
We are given a timeline split into seconds. For each second, we know how many requests hit a server. This gives us an array where each position represents request volume in that second.
We are given a row of candy boxes, each positioned at an integer coordinate. Every box contains a fixed number of candies, all sharing the same color, and each box is either red, green, or blue. We start at a specific box.
Two players are building two equally sized teams by alternately taking heroes from a common pool of $2n$ candidates. Each hero has a fixed strength, and once taken it disappears from the game.
We are given a fixed convex shape representing Bob, which can only move by translation inside a vertical swimming lane bounded by two vertical lines. Bob starts far below the plane and must reach far above it.
We are given several pairs of strings, where each pair describes how a variable name currently looks and how it should look after a single global refactoring operation.
Two people have periodic patterns of “good intervals” on the number line of days. Each pattern consists of a fixed segment of consecutive days inside a repeating cycle.
The metro system can be seen as a line of stations from 1 to n, with two directed ways of movement. One track allows movement from smaller indices to larger ones, while the other allows movement in the opposite direction. Bob starts at station 1 and wants to reach station s.