brain
tamnd's digital brain — notes, problems, research
41650 notes
We are asked to simulate a dungeon scenario where you have a set of swords, each with a damage value, and a set of monsters, each with a life value. You can kill a monster if your sword’s damage is at least equal to the monster’s life.
We are given several test cases. In each one, we receive a strictly increasing list of positive integers. The task is to choose two different elements from this list, call them $x$ and $y$, with the restriction that $x < y$, such that when we divide $y$ by $x$, the remainder…
We are given a sequence of numbers, and we repeatedly compress it until only one value remains. Each operation takes two adjacent elements, removes them, and replaces them with any integer lying between the two original values, inclusive.
We are given a permutation of length $n$, which is an array of distinct integers from 1 to $n$ arranged in some order. The task is to count the number of contiguous subarrays (intervals) that contain a specific pattern, called a 21435-subsequence.
We are given an array of integers, and each element acts like a cap: for each position $i$, we are allowed to choose a value $bi$ anywhere between $0$ and $ai$, inclusive. From this chosen vector $b$, we look at the XOR of all its elements.
We are given a tree and we need to assign colors to its edges. The restriction is that we must use exactly $k$ distinct colors, each appearing at least once. Once the coloring is fixed, consider any two vertices and look at the simple path between them.
We are given a sequence of integers. Our goal is to split this sequence into the smallest number of subsequences where each subsequence is “consecutive in value.” That is, within a subsequence, every adjacent pair differs by exactly one.
We are given a multiset of integers, which we can think of as a bag of marbles where each marble has a color represented by a number.
We are asked to merge elements arranged in a circle. Each element is a non-negative integer, and two elements are considered adjacent if they are next to each other in the array or if one is at the start and the other at the end.
We are given an integer array and a corresponding cost array. For each position in the array, we can replace its value at a certain cost, and positions we do not change keep their original values.
We are given an unrooted tree and a parameter $k$. For every possible choice of a root $r$, we conceptually “re-root” the tree at $r$ and then look at all ways of selecting exactly $k$ distinct nodes.
We are given a one-dimensional segment from 0 to x, and a set of n friends sitting at fixed integer positions on this segment. We are allowed to place k teleport points anywhere on the segment, all at distinct integer positions.
Each test case gives a collection of large integers, and the task is to find the smallest integer $x ge 2$ such that at least one element in the array is coprime with $x$.
We are given several independent test cases. Each test case consists of a sequence of integers representing toys arranged in a line. The only operation allowed is swapping two elements if one is even and the other is odd. Swaps between two evens or two odds are forbidden.
We are given two strings, s and t, each of length n. The first string represents a row of lettered cubes, and the second string is a target name. The task is to determine if it is possible to rearrange the letters of s to exactly match t.
We are given four stick lengths per test case, and we want to know whether these four sticks can be arranged to form the boundary of a square.
Alice has a secret integer x between 1 and 2^15 that she wants to communicate to Bob using a set S drawn from the integers 1 through 20. The twist is that when Bob receives S, one element may have been added, one may have been removed, or S may be unchanged.
Something went wrong. If this issue persists please contact us through our help center at help.openai.com.
We are asked to design a two-phase program that communicates an array of integers through a single string. On the first run, the program receives an array of length n, where each element is at most 26.
We are asked to implement a two-phase encoding and decoding process for an array of integers. In the first phase, the program receives an array a of size n with values up to one billion and must output a string s composed of lowercase letters.
We are asked to count arrays of length $n$ over the integers from 1 to $m$ that are “perfect” with respect to $k$ given sets of numbers. Each set defines the allowable value for a position in a hypothetical “beautiful” array of length $k$.
We are given an infinite sequence of natural numbers starting from 1. Polycarp performs a special removal operation exactly $x$ times. Each operation removes all numbers in positions that are multiples of $y$ in the current sequence.
We are asked to model a two-player game on a set of points in the plane, where each point has a cost. Alice removes some points with the goal of maximizing a total score, and Bob then draws the smallest axis-aligned rectangle containing all remaining points to minimize the score.
We start with an infinite sequence of natural numbers, effectively thinking of it as the array 1, 2, 3, 4, .... The process repeatedly removes elements based on a fixed step size y: every time we apply an operation, we delete the elements sitting at positions y, 2y, 3y, ...
We are given a one-dimensional river represented as a string of cells. Each cell has one of three behaviors: it can push Monocarp left, push him right, or do nothing. Monocarp chooses a starting cell and then moves step by step in discrete time.
Each test case gives a sorted list of marble values and a fixed integer chosen by Alice. Bob must pick his own integer, and then every marble independently awards its point to whoever is closer to that marble’s value, with Alice winning ties.
We are given an array of integers and allowed to perform a single operation at most once: choose a contiguous subarray and replace all its elements with the sum of its 1-based endpoints.
We are asked to process multiple queries on an array of integers, where each query specifies a segment of the array and a target number. For each query, we need to find the smallest subset of elements within that segment whose XOR equals the target.
We are asked to count binary strings of length n that satisfy multiple “beauty” constraints on certain substrings. A block is a maximal contiguous sequence of identical characters.
We are given a string consisting of the characters 'X', 'V', 'I', and '?'. Each letter has a numeric value: 'X' is worth 10, 'V' is worth 5, and 'I' is usually worth 1, but if it is immediately followed by an 'X' or 'V', it counts as -1.
We are given an array of length $n$, initially all zeros. We perform exactly $n$ operations, and each operation adds $1$ to every element of some chosen contiguous segment.
We are asked to consider an $n times n$ grid of integers filled sequentially row by row. The first row contains numbers from $1$ to $n$, the second from $n+1$ to $2n$, and so on until the $n$-th row, which contains numbers from $n^2-n+1$ to $n^2$.
We are given two multisets of integers, one called $q$ and one called $r$, along with an upper bound $k$. The only way to remove elements is by pairing one value from $q$ with one value from $r$ through a hidden construction involving two integers $x$ and $y$, where $1 le y <…
We are given two arrays of the same length, a and b, where each element of a is at most the corresponding element in b. The task is to transform a into b using two allowed operations: incrementing a single element of a by 1, or doubling all elements in a.
The task asks us to construct an array of length n with strictly increasing integers, all bounded by m, such that a particular score is maximized. The score is the sum of v(i, ai) from i=2 to n, where v(b, x) is the largest power k such that b^k divides x.
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.