brain
tamnd's digital brain — notes, problems, research
43815 notes
We are given three independent supplies: dumplings, juice, and pancakes. Each visitor receives a subset of these three items, with two constraints. First, a visitor cannot receive more than one of each item type. Second, no two visitors may receive the exact same subset.
We are given an array of integers and are allowed to permute it arbitrarily. After rearranging, we assign each value to a position starting from 1. The array is considered valid if no two positions share the same value of the expression i - a[i].
We are asked to build a rooted tree on vertices labeled from 1 to n, where vertex 1 is the root. Every vertex except the root has exactly one parent, and each vertex is allowed to have at most two children, so the structure must be a binary tree in the rooted sense.
We are given a complete directed graph of cities where every ordered pair of distinct cities has a travel cost. Starting from city 1, we must perform exactly $k$ moves, and end again at city 1. Each move is just choosing a directed edge and paying its cost.
We are given a full double elimination tournament with $2^n$ teams, where the bracket structure is completely fixed.
We are given a directed weighted graph with up to 50 vertices, representing fields connected by roads. A cow starts at node 1 and wants to reach node n, and the time it takes is determined by the shortest path in this graph. Now the twist: we are allowed to “slow down” edges.
A rabbit starts at the origin in the plane and wants to land exactly at the point $(x, 0)$. He moves by making a sequence of jumps, and each jump can have any direction, but its length must match one of the allowed values given in the input.
We are given an undirected, connected graph representing fields connected by roads. A traveler starts at node 1 and wants to reach node n using the shortest possible route.
We are asked to construct a strictly increasing sequence of integers $a1 < a2 < dots < an$, all between 1 and $10^9$, such that a specific combinatorial condition on triples is satisfied.
We are given an exam with a fixed number of questions, where each question contributes either 0 or 1 point to each student.
We are given a fixed tree with up to 1000 vertices. Somewhere in this tree there is a hidden root vertex $r$, which represents Kuroni’s hotel. The structure of the tree is known, but the root is not.
We are given a grid of values over time. Each row represents a day, and each column represents a spatial segment of a forest. The value in a cell tells how many animals can be observed in that segment on that day.
We are given a collection of distinct strings, all of the same length, and we are allowed to pick any subset of them and arrange the chosen strings in some order. After concatenation, the goal is to obtain a palindrome with maximum possible total length.
We are given a grid that evolves over time. Each day produces a full array of animal counts across a line of forest sections. We want to place two cameras repeatedly over a sequence of days, where each camera always covers a contiguous segment of exactly $k$ forest sections.
We are given a pattern of strict comparisons between consecutive positions in a permutation of size n. Each position tells whether the next value must be larger or smaller than the current one. From this constraint, many permutations are possible.
We are given a target amount of space, and a collection of available blocks whose sizes are powers of two. The task is to decide whether we can exactly compose the target size using these blocks, and if not, report impossibility.
We are given a tree where each node stores a positive integer. For any simple path between two vertices, we read the values along that path in order and then compute a special score: we first form all prefix sums of that sequence and then sum those prefix sums together.
We are working on a grid that starts completely empty in the sense that every cell contains the same value, zero. Over time, we perform a sequence of updates.
We are building a road of length $n$, where each unit of road must eventually be asphalted exactly once. The construction proceeds day by day, and on each day we may either work on exactly one unit or do nothing. The weather is periodic.
We are given a string consisting of lowercase letters, and we want to decide whether it is possible to arrange all 26 letters of the alphabet in a single line such that every consecutive pair of characters appearing in the string are also adjacent in this line layout.
We are given a lock described by a sequence of exactly 100 decimal digits. Think of it as a row of 100 small wheels, each showing a digit from 0 to 9.
We are given a fixed 5-digit lock state. Each digit can be incremented cyclically, so 9 wraps back to 0. Starting from an initial 5-digit configuration, we must apply a long, fixed sequence of conditional rules.
We are given a binary string of length $n$, but instead of being fixed, each position is generated independently as a random bit: it becomes $1$ with probability $p = frac{a}{b}$ and $0$ with probability $1 - p$.
We are given a 5-digit lock state. Each digit behaves like a circular counter from 0 to 9, so increasing a digit by 1 means moving to the next digit and wrapping 9 back to 0. The process consists of a fixed sequence of 20 deterministic instructions.
We are working with a rectangular grid of numbers. Each cell behaves like a player in a two-dimensional game: it is compared vertically against its column and horizontally against its row.
We are given a colored grid where each cell is one of four colors. Inside this grid, we are asked many independent queries.
The grid in this problem can be viewed as a directed version of the standard rectangular lattice where every pair of horizontally or vertically adjacent cells is connected by two opposite directed edges.
We are given an array of length $n$ where some positions contain fixed integers and some positions are marked as missing. All missing positions will be filled with a single chosen value $k$.
We are given three strings of equal length. Think of them as three rows of characters aligned in columns. At each column position, we are allowed to perform exactly one operation: we pick either the character in the third string and swap it with the character in the first…
We are given a hidden permutation of numbers from $1$ to $n$, where $n$ is even. We cannot directly see it, but we can query any subset of indices. For a chosen subset, the judge tells us only whether the average value of the selected positions is an integer.
We are given a sequence of water volumes arranged in a line. One operation allows us to pick any contiguous segment and replace every value in that segment with their average. This operation can be repeated any number of times on any segments.
We are given a sequence of horizontal segments that arrive one after another on a 1D board of length $d$. Each segment represents a block that falls vertically until it either touches the ground or touches the top of some previously placed block.
We are given a string and must assign each character to one of two groups, which we can think of as placing each character into either a red bucket or a blue bucket while preserving their original order inside each bucket.
We are given a target value $m$ and asked to consider all positive integers whose digits multiply exactly to $m$. These integers form an infinite set in general, and we are asked to sort this set in increasing numerical order and return the $k$-th element.
We are given several movies, each movie has a time window during which it can be watched in the cinema. If a movie is watched inside its window, it is considered “on time”.
Each employee has a fixed base salary, and we are allowed to distribute an additional integer bonus so that the total bonus across all employees is exactly k. After adding bonuses, each employee’s final salary becomes their original salary plus their assigned bonus.
We are given a tree of cities. From this tree we must choose a subset of cities $S$ such that two conditions hold simultaneously.
We are given an array of integers for each test case, where each value represents the contribution of a developer. We want to pick a subset of indices to form a team, and the value of the team is simply the sum of the chosen elements.
We are given a connected network of $n$ stations connected by $n-1$ railway segments, which means the structure is a tree. Each edge in this tree has an unknown integer weight in the range from 1 to $10^6$. We are also given several observations from passengers.
We are given a sequence of monsters standing in a fixed order. Each monster has a certain amount of health, and they must be defeated one after another from left to right.
We are given a string and we are allowed to assign a color label to each character position. After coloring, we gain a very specific operation: we may swap two adjacent characters only if their colors are different. Swaps can be repeated arbitrarily many times.
We are given an initial amount of money, and we repeatedly perform a very specific type of purchase operation. In each operation, we choose some amount $x$ that we can afford at that moment, spend it, and immediately receive back $lfloor x/10 rfloor$.
We are given a permutation where every value from 1 to n appears exactly once, but the order is arbitrary. Each position also has a cost associated with its element, and that cost is what we pay whenever we move that element between two groups.
We are working with a fixed number $a$ and a modulus-like bound $m$. For every integer shift $x$ in the range $[0, m-1]$, we look at the number $a + x$ and compare its greatest common divisor with $m$ against the original value $gcd(a, m)$.
We are working with a tree, which means there is exactly one simple path between any two vertices. From this tree we must choose three distinct vertices, call them $a$, $b$, and $c$.
The game can be seen as a process where we start with n opponents and repeatedly trigger rounds that remove some of them.
The graph in this problem is not given explicitly, but fully determined by the structure of integers. Every positive integer is a node, and each number $x 1$ has a directed edge to $x / f(x)$, where $f(x)$ is the smallest prime factor of $x$.
We are trying to reconstruct a hidden string of length up to 50. The string is guaranteed to use only three symbols: C, H, and O.
We are given a tree with $n$ nodes and $n-1$ edges. Each edge is assigned a distinct label from $0$ to $n-2$, so every label appears exactly once. For any pair of nodes $u, v$, we look at the unique path between them and collect all edge labels on that path.
We are given an array of non-negative integers. We are allowed to repeatedly decrease any element by 1 as long as it stays non-negative.
We are given a digit string and we are allowed to delete some of its digits while keeping the remaining digits in the same relative order.
We are given a hidden sequence of café types, where each café produces exactly one integer “coffee variety”. We do not know the sequence itself, but we can probe cafés one by one. The interaction tool behaves like a sliding-window memory system.
We are given a small set of integer vectors in the plane. Each vector can be used repeatedly as a step, and we form a closed polygonal walk by starting at the origin, repeatedly adding chosen vectors head-to-tail, and eventually returning to the origin.
We are given an array of numbers and a line of people who will remove elements from the array one by one. Each person, when it becomes their turn, sees the current array and takes either the leftmost or rightmost element.
We are building a sequence one element at a time, where after inserting the first i values, we take the current array and construct its Cartesian tree.
We are given a hidden array of length $n$, where each position represents a café and each café produces exactly one type of coffee. The value at position $i$ is the coffee variety label $ai$, but we never see it directly.
We are maintaining a dynamic “recent chat list” of friends, represented as a permutation of the numbers from 1 to n. The list is ordered from most recent to least recent interaction.
We are given a bipartite graph where every edge can optionally be assigned one of two colors, red or blue, or left unused. Coloring an edge is not free: red costs r, blue costs b, and leaving it unused costs nothing.
A hidden string of length $n$ is fixed before the game starts. The player’s goal is to recover this exact string. Instead of being given it directly, the only way to gain information is by querying substrings of ranges.
We are given a rooted tree where every node has a hidden integer value. What we do know is the tree structure and, for each node, a number ci.
We are dealing with a hidden string of length $n$, made of lowercase English letters. We cannot see the string directly. Instead, we can query any segment $s[l..
We are given a list of integers, and we are allowed to choose a single integer $X$. Once $X$ is fixed, every array value is transformed by XOR with $X$, and we care about the largest transformed value. The goal is to pick $X$ so that this maximum value is as small as possible.
We are given several intervals on a number line. Each interval represents a continuous segment of covered points. If multiple intervals overlap or touch, their combined covered region merges into a single continuous piece when we take the union.
We are given a list of positive integers and we want to choose two different positions in the list such that the least common multiple of the chosen values is as large as possible.
The task is to take a small grid with blocked and open cells and construct a special “maze representation” on a refined grid. Each input cell becomes a node in a graph, and adjacency exists between orthogonally neighboring open cells.
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.