brain
tamnd's digital brain — notes, problems, research
43815 notes
We are asked to construct a tree on $n$ vertices labeled from $1$ to $n$ such that for every edge connecting vertices $u$ and $v$ with $u < v$, the vertex $u$ appears before $v$ in a given permutation $p$.
We are asked to construct permutations of integers from 1 to n such that in every consecutive triplet of elements, at most six indices are "bad." An index i is bad if the three consecutive numbers starting at i are pairwise coprime.
Each test case gives two binary arrays of equal length. On position $i$, there is a pair of bits $(ai, bi)$. During the game, players go through indices from left to right.
We are asked to check whether a tree can be built from a permutation of numbers from 1 to n, subject to a specific ordering constraint.
We are asked to simulate a two-player game on two arrays of integers, a and b, each of length n. Players take turns: Ajisai moves on odd-numbered turns, Mai moves on even-numbered turns. On a player’s turn, they can swap the current element a[i] with b[i] or leave it as is.
We are given an array of nonnegative integers with some entries marked as -1, representing blanks. Our task is to replace each blank with a nonnegative integer to minimize the absolute value of the sum of differences between consecutive elements.
Error in message stream
We are asked to construct an undirected simple connected graph on $n$ labeled vertices. The graph must satisfy three structural constraints at the same time. First, it must be a single connected component without multi-edges or self-loops.
We have a network of cities connected by roads, where each road is exactly one kilometer long. Each city produces one type of agricultural product, and city 1 is a central port.
We have a rope consisting of n units, each colored either red or black. The rope is represented as a string of length n where each character is R or B. We are allowed to perform up to m operations.
We are asked to cut a circular cake, represented as a circle centered at the origin with radius r, into two pieces using a single straight line. On the cake are n strawberries, each strictly within 0.9 times the radius from the center.
Error in message stream
We are given an $n times n$ grid with tiles stacked in columns and vertical bars between adjacent columns. Each column $i$ starts with $ai$ tiles stacked from the bottom.
We are given a deck of $2^k$ cards represented as a string of lowercase letters. The deck can be rotated by moving the first $m$ cards to the end. After this optional rotation, the deck is riffle-shuffled $t$ times.
We are asked to count how many gene sequences of a given length can be obtained from an initial sequence using a specific set of mutations. The sequences only contain A and B, and mutations allow inserting or deleting AA, BBB, or a special substring s.
We are given a very small “number universe” built from the digits of a base number. The base number is always one of three possibilities: a two-digit number, a three-digit number, or a four-digit number.
We are given a sequence of $n$ servers, each with a database protocol type $pi$, which is a positive integer. Initially, the servers are disconnected.
We are asked to model a probabilistic card game where each student starts with a subset of numbered cards and additional cards are revealed one by one.
Every bus moves along the road at the same speed x. Bus i starts at position si at time 0, moves to the right, and disappears once it reaches ti. A person starts at position p. They can walk at speed y, where y < x.
We are given the scores of three AI-powered creative assistants-Gemini, ChatGPT, and Claude-in an ASCII art contest. Each score is an integer between 80 and 100. The organizers want to decide if the judges' scores are consistent enough to announce a final result.
We are asked to place a sequence of circles on a single straight line of centers, while controlling how they may overlap and nest inside each other. Each circle has a fixed radius, and the radii are given in non-increasing order.
We are given a non-increasing array of positive integers, and we repeatedly process subsegments of it under a “capacity reset” rule. For each query, we pick a contiguous slice from index l to r. We then scan it left to right, maintaining a running sum.
We maintain a permutation of 1..n. A query chooses two indices x and y. The judge then flips a coin. Either positions (x,y) are swapped, or their mirrored positions (n-x+1, n-y+1) are swapped.
Taiga is given a positive integer n and can perform exactly k moves. In each move, she chooses a power of two, 2^ℓ, and adds it to n. The score of each move is the number of binary carries that occur during the addition.
We are asked to plan our sleep schedule across a sequence of classes, each of which is either important or not. The day is represented as a binary string where '1' marks an important class and '0' a non-important one.
We process a sequence of turns. The current score starts at 0. At turn i, we are given two possible transformations: If we take the red card, the new score becomes k - k - a[i] If we take the blue card, the new score becomes k - b[i] - k We must choose exactly one…
We are given a multiset of numbers, all lying in the range from 1 to a large limit k. From this array we must construct a set B of distinct integers, also between 1 and k, but under two simultaneous constraints that interact in a non-trivial way.
We are interacting with a hidden integer $x$ that is fixed for each game and always lies in the range $[1, c]$, where $c = 2 cdot 10^9$. Our goal is to determine this number using at most three queries. Each query chooses a base $b ge 2$.
Working
We are asked to guess a hidden number x between 1 and c by making queries about the sum of its digits in a chosen base. Each query specifies a base b (between 2 and c) and returns either the sum of digits of x in that base, or -1 if x is smaller than b.
We are asked to analyze a weighted undirected graph with n vertices and m edges. For each graph, we need to select n - 1 edges whose total weight is minimal, but these edges must not form a tree.
We are asked to compute the expected beauty of a linear mosaic of pebbles, where each pebble is painted in one of $m$ colors chosen independently and uniformly.
We are asked to calculate the expected beauty of a 1×n mosaic, where each cell is painted independently with one of m colors. Beauty is defined as the square of the number of palindromic subsegments. A subsegment is palindromic if it reads the same forwards and backwards.
We are given two strings, s and t, both composed of lowercase English letters. The goal is to rearrange t in such a way that s appears at least once as a subsequence. Among all such valid rearrangements, we need to find the one that is lexicographically smallest.
We are building a sequence of numbers $b1, b2, ldots, bn$ representing how many wishing cards each friend will give, but each friend has an upper limit $ai$, and all $bi$ together cannot exceed a total budget $k$. Each $bi$ must stay within $0 le bi le ai$.
We are given a very long ribbon with $10^{18}$ cells, but only the first $n$ cells are already painted with specific colors. Each color is represented as an integer.
We are given a binary string consisting of 0s and 1s, with at least one 1. The goal is to transform this string into a string of all 1s. To achieve this, we can repeatedly choose a shift d and perform a cyclic right shift of the string by d.
We are given several arrays, and for each array we need to evaluate a sum over all unordered pairs of indices. For each pair of values $ai, aj$, we look at the number of distinct prime factors in their product and then raise that count to a fixed power $k$.
We are given an array of n elements. Each element has a value ai and a removal cost ci. The goal is to remove all elements except one, using a series of adjacent removals, paying the minimum total cost.
We are given a directed graph with $n$ vertices, each labeled with a positive integer $av$, and $m$ edges. Our goal is to count all simple paths that include at least two vertices, where the sequence of numbers along the path forms a generalized Fibonacci sequence.
We are given a multiset of coin values and asked to simulate a process that depends not only on which coins we pick, but also on the parity of the running sum inside a temporary bag.
We are given an array of numbers, and we are allowed to repeatedly remove elements under a very specific condition. Each move chooses two indices $i < j$ such that the value at $i$ is strictly larger than the value at $j$, and then deletes the element at position $j$.
Santa starts with exactly one present of each of three values, $a$, $b$, and $c$. Let the current counts of these present types be $xa$, $xb$, and $xc$. Initially all three counts are equal to $1$. Two operations are available.
We are given a set of cities on a Cartesian grid, each at distinct lattice points, and an integer $k$. The task is to compute a certain "explosiveness" measure over all proper subsets of cities.
We are given a circle with $2n$ points labeled from $1$ to $2n$. Santa draws $n$ chords connecting distinct pairs of points. Chords may intersect. For each prefix of chords $1$ through $ell$, we are asked whether the chords are tight-knit.
We are asked to determine the maximum element of a hidden array that was generated from an initial array containing a single power-of-two number.
We are given a rooted tree with vertices numbered from 1 to $n$. Each vertex is colored based on the size of its subtree: if the subtree size is even, the vertex is white; otherwise, it is black.
We are given a village of n elves, each with an initial health equal to its attack value. The elves engage in a Mass Hysteria event where each elf that has not attacked yet can choose another living elf to attack.
We start with a string consisting only of s and u. We may repeatedly choose any position containing u and change it into s. We are not allowed to change an s back into u. The final string must satisfy two conditions. First, it must contain at least two occurrences of s.
We have a line of children, each with an integer niceness value. Santa wants to assign each child to either a nice list or a naughty list, but he can only remove children from the front of the line.
We are given a string consisting only of two symbols, where one behaves like a neutral value and the other behaves like an absorbing “true” value under an OR-like merge operation.
We are asked to reconstruct the positions of penguins on an $n times n$ grid after a migration, knowing only the Manhattan distances between pairs of penguins.
We are given a line of plants indexed from 1 to n, all initially holding zero water. Each query specifies a segment $[l, r]$, and for every position $i$ in that segment we add a value that depends on how far $i$ is from $l$.
We are asked to determine, for given integers $k$ and $x$, the smallest string length $n$ for which no valid password exists under specific rules. Each password uses only the first $k$ lowercase letters.
We are asked to solve a two-part communication problem on a connected bipartite graph. In the first part, the agent colors vertices using three colors to encode directional information.
We are asked to divide voters into districts according to a binary pattern while respecting minimum district sizes. Specifically, we have two parties, A and B, with a total of x and y voters, respectively.
We are asked to construct a permutation of all integers from $0$ to $2^n - 1$. The quality of a permutation is defined through a running process over prefixes: we maintain the bitwise AND of the prefix seen so far, and at each step we add the number of set bits in that AND…
Working
We are given a sequence of floors that Blackslex needs to visit in order, and moving between floors takes time proportional to the absolute difference between consecutive floors. Blackslex can skip at most one floor in the sequence.
Each game starts from three numbers forming an arithmetic progression, so the state can always be described as $(a, a+d, a+2d)$ with $d 0$. The players repeatedly pick one coordinate and increase it, but the triple must remain an arithmetic progression after every move.
Working
The grid in this problem is best thought of as a lattice of junction points, not cells. Every intersection point on the grid is assigned one of four directions. From each such point, we draw a unit segment in its chosen direction.
We maintain a sequence that starts empty and evolves through three kinds of operations. One operation deletes the middle element of the current sequence, where the middle is defined as the ceiling of half the current length.
We have frogs on every integer position inside a contiguous segment $[l,r]$. After choosing a positive integer $x$, every frog moves from position $i$ to position $i oplus x$. XOR with a fixed value is a permutation of all non-negative integers.
We are asked to count the number of ways to assign directions to the corners of an $n times m$ grid so that a simulated car starting at the top-left cell eventually stops inside the grid.
We are given a set of points on a line, each point representing the center of a disk we must draw. Every disk has a positive radius, and no two disks can overlap, though touching at the edges is allowed.
We are asked to take an integer $n$ and split it into exactly $k$ non-negative integers whose bitwise XOR equals $n$. Among all such splits, we want one that maximizes the sum of the numbers. Each number in the split must be between 0 and $n$ inclusive.
We are given a circular prize wheel with l numbered sections from 0 to l-1. The wheel pointer starts at a section a. Each spin moves the pointer forward by exactly b positions modulo l.
We are given a sequence of strings, and we must insert them one by one into an initially empty string. Each new string can be placed either at the left end or the right end of the current result. After all insertions, we obtain a single final string.
We are given two binary strings, which we can think of as observed measurements from a medical test. The first string represents the recorded presence or absence of reactions to several allergens.
We are given several token sequences, each sequence representing a text where some positions are produced by a language model and others are written directly by a user. Only the positions marked as generated contribute to the training loss.
The canvas is a rectangular grid of cells, but the real structure lives on its grid graph: vertices are grid intersection points and edges connect adjacent intersections horizontally or vertically. Initially, some collection of simple cycles is drawn along these edges.
We have two sets of points on a Cartesian plane: pumps scattered across a valley and reservoirs positioned on surrounding hills.
We are given a casino machine whose behaviour is determined by one hidden probability value. There is an array of probabilities, and the casino owner secretly picks one index uniformly at random at the start and fixes it forever.
We are given a rectangular cake with dimensions $w times h times d$. The goal is to divide this solid into exactly $n$ smaller rectangular pieces, all identical in size. The only allowed operations are cuts that are parallel to the faces of the cake.
Each round produces a choice of an integer at every position on a cycle. After the numbers are chosen, we look at each adjacent pair on the cycle and award one point to both endpoints whenever the left endpoint is strictly larger than the right endpoint.
We have a skyscraper with floors numbered from 1 up to very large numbers, and several people waiting for an elevator on different floors. Each person has a distinct starting floor and a distinct destination floor, and no two floors overlap.
We are asked to analyze a variation of the classical game of Nim. In the original Nim, players take turns picking a pile and removing any number of stones. The player who takes the last stone wins.
Each layer of the doorway is a one-dimensional segment between two fixed walls. Inside that segment, there are several rigid door blocks placed in a line, but each block is allowed to slide left or right as long as it does not overlap other blocks or cross the walls.
We are asked to calculate how many full sets of street signs can be made when one street's order is missing. Each street in Alphabet City has a name made from capital letters, and each street has an order for m identical signs.
We are asked to simulate a turn-based game between Alice and Bob. Each player starts with an array of positive integers. On their turn, a player picks any element from their own array and applies it against the maximal element in the opponent's array.
We are dealing with a hidden connected graph that has a very restricted structure: it is a cactus, meaning every edge participates in at most one simple cycle.
We are given a rooted tree with vertex 1 fixed as the root. A sequence of n “placements” must be assigned, one for each vertex of the tree, but the twist is that the placement order is not arbitrary. The first placement is forced onto the root.
We have a dynamic herd of reindeer, each with strength $2^{ci}$, and we need to answer three types of queries: adding a reindeer, removing a reindeer, or counting how many subsets of the herd meet a certain carrying capacity threshold.
Monocarp wants to make as many friends happy as possible with a limited budget. He has a number of friends and a set of boxes.
We maintain a multiset of reindeer. Each reindeer is identified by a power level, but the real value that matters is a power of two, $2^{ci}$.
We are given several independent scenarios. In each scenario, there are $n$ people and $n+1$ boxes of decorations. Box $0$ is special, and each person $i$ has their own personal box $i$. Each box starts with some number of decorations.
We are given a string composed of the characters 0, 2, 5, and 6. A string is considered a New Year string if it either contains the substring 2026 somewhere or does not contain the substring 2025 at all.
We are asked to help Monocarp bake a layered cake under two constraints: the size of each layer grows exponentially and the chocolate covering each layer must alternate between white and dark. The top layer always has size 1.
We are given three circular sequences of equal length, each representing sizes of snowballs on a conveyor belt. From each conveyor we choose a starting position, and then we simultaneously walk forward step by step around all three cycles.
We are given a binary string where each position contains either a 0 or a 1. We are allowed a fixed number of operations, exactly one for each value from 1 up to half the length of the string.
We are working with a binary string where each position holds either a 0 or a 1, and we are allowed to repeatedly apply a very specific kind of operation. Each operation is indexed from 1 upward, and on operation number x we may choose a starting position l.
The interactive version allows us to ask up to three carefully chosen instructions and observe the surviving snakes. In the hacked version, the speeds are already given in the input, and our job is to reproduce the answer that an optimal interactive solution would output.
We are given an array of integers and asked to divide it into exactly $k$ non-empty subsequences. For any subsequence $b$, its cost is defined as the product of its length and the sum of its elements. Our goal is to minimize the total cost across all $k$ subsequences.
We are given a rooted tree with each node labeled by a lowercase letter. For each node $i$, we are asked to analyze all strings that can be formed by starting at any node in the subtree of $i$ and repeatedly jumping to a proper descendant, concatenating the letters along the…
We are given a sequence of length $n$ where some positions are fixed numbers between $1$ and $m$, and some positions are zero placeholders that must be filled. After filling all zeros with values in $[1, m]$, the resulting sequence must satisfy two conditions at the same time.
We are given a rooted tree, where all nodes are initially white, and we need to color all nodes black in the minimum number of operations.
We are given a rooted tree with n vertices, where the root is vertex 1, and initially all vertices are white. The distance di of a vertex i is the number of edges on the path from the root to i.
We are given an array of non-negative integers and a number $k$. The task is to repeatedly remove elements from the array, always choosing a window of length $k$ whose MEX is maximal, and deleting any element within that window.
We have a linear arrangement of bases numbered from 1 to n. Our home base is at position k, and we start with exactly one soldier there. Every day, we can select a base and move any number of soldiers from it either left or right by exactly one position.