brain
tamnd's digital brain — notes, problems, research
41650 notes
We are given a short string in each test case and we need to decide whether it can be interpreted as a rearrangement of the name “Timur” under a very specific spelling rule. The rule is not just that the letters match.
We are working with a bipartite graph where the left side has $n1$ vertices and the right side has $n2$ vertices. Edges are fixed and each edge connects one left vertex to one right vertex.
We are given a fixed reference string and then asked to process many short query strings. For each query, we temporarily append the query string to the reference, compute the prefix function on the resulting concatenation, and output only the prefix function values…
We are given two arrays of equal length. One array, call it a, is fixed in place. The second array b can be permuted arbitrarily. After choosing a permutation of b, we pair elements by index and form a new array where each position becomes the XOR of the paired values.
We are working on a grid where a robot starts at the top-left corner and wants to reach the bottom-right corner using four-directional moves.
We are given a tiny image made of four pixels arranged in a 2 by 2 grid. Each pixel is labeled with a lowercase letter, representing its current color. The goal is to make all four pixels end up with the same color using a sequence of painting operations.
We are given two non-decreasing arrays, one original array and one final array. The original array can be “shifted” element by element by adding a non-negative value to each position, producing an intermediate array.
We are given an $n times n$ grid of integers. Each cell initially contains some value, and we are allowed to perform an operation that selects any square submatrix and overwrites every cell inside it with a single chosen integer.
We are given an array of integers, and we want to choose a subsequence of indices. The chosen indices must be strictly increasing in position, but the values we compare are not just the array values themselves.
We are given an array of integers where each value is small, but the index range can be large. From this array we want to pick a subsequence of positions, keeping the indices strictly increasing.
We are given a binary grid where each cell is either empty or contains a single unit. The only allowed move is to pick a 2 by 2 block and choose three of its four cells forming an L shape.
We are given an array of integers, and we are allowed to pick a single contiguous segment inside it, but not the whole array. Once we choose this segment, the array is conceptually split into two parts: the chosen segment and everything outside it.
Each test case gives two fractions, $frac{a}{b}$ and $frac{c}{d}$. In one move, you are allowed to pick exactly one of the four numbers $a, b, c, d$ and multiply it by any nonzero integer.
We are given an even number $n$, and we must partition the integers from $1$ to $n$ into disjoint pairs. Each number must appear in exactly one pair, and the order inside each pair matters. For a pair $(a, b)$, we compute the expression $(a + k) cdot b$.
The tournament can be viewed as a queue that evolves over time. At the beginning, all athletes are arranged in increasing order of their indices.
We are given a permutation p of size n, which acts as a reference order. Alongside it, we have an array a of the same size where some positions are already filled with numbers and exactly k positions are missing (marked as zero).
We are given two rectangular grids of the same size, and each grid contains colored cells. The only allowed operations are swapping entire rows or swapping entire columns.
We are given an array where each element is a small positive integer, and we are asked to answer many independent range queries. Each query selects a contiguous subarray and conceptually multiplies all values inside it into a single large number.
We are given a circular array, and we repeatedly simulate a very specific traversal rule. We choose a starting position s and a fixed jump length k. Starting from s, we walk exactly n steps.
We are given several independent test cases. In each one, an array of integers is provided, and the goal is to turn every element into zero using a special operation.
We are given an array of integers, and the goal is to transform every element into zero using a special range operation. Each operation lets us choose a contiguous segment and XOR every element in that segment with the same value.
We are given many queries, and each query describes a contiguous interval of integers from l to r. For each such interval, we want to count how many triples (i, j, k) can be formed with strictly increasing indices inside the interval such that the least common multiple of the…
We are given many independent queries, each query defines a numeric segment from $l$ to $r$. Inside that segment we consider all triples of distinct indices $i < j < k$, and we want to count how many of these triples satisfy a specific inequality: the least common multiple of…
We are given a tree with unit-weight edges. From this tree we identify a special set of vertices, the leaves, meaning the vertices whose degree is exactly one.
We are given an array where each position represents a node in a line. Between any two indices $l$ and $r$, there is an edge whose weight is the minimum value in the subarray $al, dots, ar$.
We are given several independent test cases, each consisting of an array of positive integers. In one move, we are allowed to pick a value x and simultaneously erase all occurrences of x in the array by turning them into zeros.
We are given a single integer $n$, and we must arrange the numbers from $1$ to $n$ into a permutation so that a particular score is as large as possible.
We are given a final array that was produced by taking a consecutive integer segment, permuting it, and then applying a fixed XOR mask to every element. The original segment is known to be all integers from l to r inclusive, but their order is scrambled.
The game is played on an $n times n$ grid where each cell has a fixed value, and all values are distinct so there are no ties in scoring from identical weights.
We are given a hidden construction process that starts with a clean consecutive integer segment from some interval $[l, r]$. Gojou first takes all integers in that interval, then shuffles them arbitrarily.
We are given a connected undirected graph, and we are allowed to choose, independently for every vertex, an ordering of its adjacent vertices.
We are given an array of integers and we are allowed to reorder its indices using a very restricted type of permutation: a single cycle that visits every position exactly once before returning to the start.
We are given two finite collections of very large positive integers, think of them as two bags of numbers. From each bag we are allowed to pick any non-empty subcollection. For each chosen subcollection, we compute the least common multiple of all its elements.
We are given an array of integers, and we build a complete graph where every pair of vertices is connected. The weight of an edge between vertices $i$ and $j$ depends on a parameter $t$ and is defined as a linear function in $t$: it has a fixed quadratic-looking term $ai aj$…
We are given a number $n$, and we want to check whether there exists an integer $k ge 2$ such that we can split $n$ into exactly $k$ positive integers with a special property: when each of those $k$ numbers is divided by $k$, all remainders must be different.
We are given a tree, and we must assign a nonzero integer to every vertex. The constraint is not about the whole tree sum, but about what happens when a vertex is removed. If we delete any vertex $v$, the tree splits into several connected components.
We are given a set of ingredients, each of which must appear in some positive integer quantity in a final mixture. The professor does not provide absolute amounts, but instead gives exactly $n-1$ constraints.
We are asked to count permutations of the numbers from 1 to n that satisfy two independent kinds of restrictions. The first restriction is positional and local. We are given a short comparison string s of length m.
We are given a tree where some vertices are marked as “base lodges”. Every vertex inherits a height equal to its distance from the nearest lodge.
We are repeatedly trimming a string from the front based on a self-referential property of its prefixes. At any moment, we look at the current string and examine all its prefixes starting from the empty one.
We are given a string whose length is a power of two, indexed from 0 to $2^n - 1$. The key operation allowed is a global reindexing of the string using bitwise XOR with a fixed mask $j$.
We are given a circular arrangement of $n$ players, each holding exactly $n$ cards. Every card carries a label from $1$ to $n$, and each label appears exactly $n$ times across the whole system.
We are looking at a grid where each position is completely deterministic: the cell in row $i$ and column $j$ contains the value $i^j$.
We are given a tree, and we must assign a positive integer weight to every vertex. A vertex is called good if its weight equals the sum of the weights of all vertices adjacent to it. The goal is not just to satisfy this condition arbitrarily.
We are given a number written in decimal form, and we are allowed to delete digits one by one from anywhere in the number. After each deletion, the remaining digits close up, and any leading zeros disappear automatically.
We are given a string made of four types of brackets: round (, ) and square [ , ]. Each query gives a substring, and for that substring we want to know the cheapest way to turn it into a valid bracket sequence. We are allowed to perform two kinds of transformations.
We are given a line segment with three types of entities: a cat starting at position 0, a hole at position n, and several mice positioned strictly between them. Time advances in discrete seconds.
We are given a tree of cities. Each city has a fixed value called enjoyment. Each road connects two cities and has two properties: a capacity and a toll. A group query gives a starting city and a number of vehicles.
We are given a connected undirected graph where every edge initially has weight 0. We then receive a sequence of queries, each query specifying two vertices. For each query, we must choose a simple path between its endpoints and add 1 to every edge along that path.
Each task has two special moments: the moment Okabe learns about it, and the earlier time at which it should actually be completed. When he learns about a task, he either confirms it is already done correctly, or he is forced to jump back in time to fix it immediately.
We are given a complete directed acyclic graph on the vertices from 1 to n, where every pair (i, j) with i < j has a directed edge from i to j.
We are asked to construct a tree on $n$ labeled nodes, where a tree means a connected graph with exactly $n-1$ edges and a unique simple path between every pair of nodes. Alongside this, we are given $m$ constraints.
We are trying to recover an unknown permutation of the numbers from 1 to n. We never see this permutation directly. Instead, we can probe it using a query mechanism that mixes our chosen array with the hidden permutation in a very specific way.
We are given several independent test cases. In each test case there is an array of distinct positive integers, and the task is to choose as many elements as possible such that the sum of the chosen elements is not prime.
We are given a sequence of numbers and a sequence of operations placed between them. We start each segment with value 1, then apply the operations from left to right. Each position either multiplies the current value by the given number or divides it by that number.
We are given an array of positive integers and asked to construct a sequence of non-overlapping subarrays. These subarrays must be chosen in order from left to right, and their lengths are fixed to form a decreasing sequence starting from some value $k$ down to $1$.
We are given several test cases. In each one, we start with an array of nonzero integers $a$. Our task is to construct another array $b$ of the same length such that two conditions hold simultaneously. First, no element of $b$ is allowed to be zero.
We are given a string made of lowercase letters. We are allowed to pick exactly one letter of the alphabet, and then delete any occurrences of that chosen letter from the string, possibly none or all of them.
We are given a collection of songs split into three types: some last 1 minute, some last 2 minutes, and some last 3 minutes. For each test case, we must assign every song to one of two concerts.
Each test gives us a hand of five distinct numbers between 1 and 100. Two players independently receive such hands, and each player only sees their own five numbers.
The labyrinth can be seen as a connected weighted graph where rooms are nodes and passages are undirected edges with capacities. Each room also has a one-time “growth value” that increases Lucy’s width if she chooses to eat that room’s candy.
We are given a set of jarls, each belonging to exactly one island. The default rule of conflict is simple: jarls from different islands are in conflict, while jarls from the same island are peaceful.
We are given a rooted hierarchy with a single root, the king, and up to $n$ lords forming a tree where each lord has exactly one parent. Each lord $i$ has a required amount of money $mi$.
We are given a convex polygon in the plane, and this polygon represents the silhouette of an object. We imagine rotating the viewing direction uniformly at random, and for each orientation we project the polygon onto axes aligned with that view.
We are given a line of participants, each assigned a positive “luckiness” value. These participants enter a knockout tournament with a very rigid pairing structure.
We are given a circular arrangement of villages, labeled from 1 to n in clockwise order. Initially there are no connections between any pair of villages.
We are given a final board configuration of a grid-based stacking process where multiple small polyomino-like pieces were dropped one after another. Each piece is connected in four directions, has at most seven cells, and is identified by a letter.
We are given a permutation, meaning an array containing every integer from 1 to n exactly once. The process repeatedly applies a deterministic “strange bubble pass” operation, but with a twist: odd-numbered rounds compare adjacent pairs starting from index 1, 3, 5, and…
We are given a starting number and a restriction on how many distinct digits we are allowed to use. For each query, we must find the smallest integer that is not smaller than the given number and whose decimal representation uses at most k different digits.
We are given a number written as a string of digits. In one operation, we are allowed to either remove any single digit from anywhere in the current string, or append a single digit to the right end of the string. These operations can be repeated in any order.
We are counting how many arrays of length n can be formed when each element is an integer in the range [0, 2^k - 1], with the additional constraint that a certain bitwise inequality holds.
We are given a complete weighted undirected graph on $n$ vertices, so every pair of vertices is connected and every edge has a known cost.
We are working on a graph whose vertices are all integers from $0$ to $2^n - 1$. Each vertex represents an $n$-bit binary string, and there is an undirected edge between two vertices if their binary representations differ in exactly one bit.
We are given a hidden array of integers, and we cannot access its elements directly. The only way to learn anything about the array is by asking queries on pairs of indices. Each query returns either the bitwise AND or bitwise OR of two elements.
We are given two arrays of the same length and a set of queries, each query picking a contiguous segment. Inside a segment, we are allowed to perform a special operation multiple times. Each operation selects an even number of distinct positions inside the segment.
We are given a complete tournament where every pair of teams plays exactly one match. The result of each match is random, but biased: team $i$ beats team $j$ with probability proportional to its strength, specifically $frac{ai}{ai + aj}$. Each match outcome is independent.
We are given a bracket string, but it is not written explicitly character by character. Instead, it is compressed into blocks.
We start with two integers, both initialized to zero. We are allowed to repeatedly apply operations that modify them using a freely chosen positive step size each time.
We are given an array of integers, and we are allowed to swap adjacent elements. The goal is to rearrange the array so that no two neighboring elements share the same parity, meaning we want an alternating pattern of even and odd numbers.
We are given a rectangular room and inside it a fixed axis-aligned rectangular table. The table currently occupies a block inside the room, but we are allowed to slide this table anywhere inside the room as long as it stays fully inside the boundary.
We are given a set of weighted intervals on a number line from 1 to m. Each interval allows free movement between any two integer points inside it, which effectively means that once we pick a set of intervals, all points covered by overlapping intervals become connected…
We are asked to build an order of pizzas where each pizza contributes both a fixed number of slices and a fixed baking time.
We are given a string made only of three possible letters. For any substring, we are allowed to change characters, and each change replaces a character with any of the three letters.
We are given an array of values indexed from one, and we want to choose two different positions in this array. For any chosen pair of indices, we compute a score made of two competing parts: a positive term that grows with the product of the indices, and a penalty term that…
We are given an array a of length n. It is not a permutation itself but a derived “stability profile” of an unknown permutation of 1..n. For each position i in that hidden permutation, we look at all subarrays that contain i.
We are given several independent queries. Each query provides a positive integer $n$, and we must count how many integers $x$ in the range from 1 to $n$ have a special property. For a number $x$, we compare the sum of its digits before and after adding one.
We are simulating a point moving on a number line. The point starts at position 0 and moves strictly to the right at unit speed, so without any interruptions it would simply take $t$ seconds to reach position $t$.
We are given a string made of lowercase letters. In one move, we are allowed to pick exactly one subset of positions, take the characters at those positions, and rearrange only those chosen characters arbitrarily while keeping all other characters fixed in their original places.
The task is about selecting a subset of vertices in a tree such that every pair of chosen vertices is equally far apart.
We are given a rectangular grid with $n$ rows and $m$ columns, and we must tile it completely using dominoes, each covering exactly two adjacent cells. Every cell must belong to exactly one domino, so the grid is fully partitioned into pairs of neighbors.
We are given several test cases. In each case there is a sequence of integers and a number of colors. We want to “paint” some occurrences of these integers using up to $k$ colors, with the option to leave elements unpainted. The constraints inside the coloring are subtle.
We are given several independent test cases. In each test case, we receive a list of words, and we want to select as many of these words as possible so that the selected subset satisfies a specific imbalance condition.
We are given an array where each element represents a point on a vertical line at its index. More precisely, the i-th element forms a point $(ai, i)$ in a 2D plane. The distance between two points is measured using Manhattan distance.
We are given a string made of lowercase letters from a small alphabet of size $k$, plus wildcard characters that can be replaced freely.
We are given a sorted set of points on a number line, which we can think of as rocks placed at distinct integer coordinates. A frog starts on one designated rock and can repeatedly jump to other rocks.
We are given an array of length $n$, and each position $i$ must store an integer $ai$ within a fixed interval $[l, r]$. Two constraints define what makes a valid configuration interesting.
We are asked to construct an array of positive integers whose elements sum to a fixed value, while keeping the array as small as possible in length.
We are given a square board of size $n times n$, but only the first and last rows matter. The bottom row contains Gregor’s pawns, and the top row contains enemy pawns. Every column is either empty or occupied independently in those two rows.
We are given a prime number $P$, and for each test case we must output two integers $a$ and $b$ such that both lie between 2 and $P$, with $a < b$, and the remainders when dividing $P$ by $a$ and by $b$ are equal.
The ceiling is split into a grid where each row contributes a fixed amount of paint and each column contributes another fixed amount. This makes every cell’s paint level completely determined by two arrays: one attached to rows and one attached to columns.