brain
tamnd's digital brain — notes, problems, research
43815 notes
We are given a hidden array of length $n$, already sorted in nondecreasing order, and containing at most $k le 25000$ distinct values. Our only way to inspect it is by querying a segment $[l,r]$.
We are given a line of positions, each containing a direction symbol that behaves like a deterministic local rule. From every starting position, a ball moves left or right according to its own symbol and the symbol of the neighbor it is interacting with.
We are given two types of cookies and two types of guests. The cookies are split into vanilla and chocolate counts, and guests also come in two behavioral types.
We are given a tree and two hidden distinct nodes inside it. We do not know which nodes they are, but we can interactively probe the tree by choosing any subset of nodes.
We are given an array of length $2n$. We are allowed to remove exactly two elements permanently. After that, the remaining $2n-2$ elements must be partitioned into pairs. Each pair is replaced by the sum of its two elements, producing an array $b$ of length $n-1$.
We are given a sequence of numbers and asked to choose a subsequence of fixed length $k$. Once we pick this subsequence, we alternate its elements into odd and even positions based on their order inside the subsequence, not their original positions in the array.
Each round is a two-player deterministic game played on a single integer. A round starts with a value $si$ on a board and a limit $ei$. Players alternate turns, and on each turn the current value $a$ must be replaced by either $a+1$ or $2a$.
The structure in this problem is a very specific rooted tree that grows level by level. Starting from a single node, each level expands every vertex depending on how many children it already has.
The structure we are working with is a rectangular grid where every cell is a junction and every boundary cell has a port attached to one of the two external systems. Each port is either red or blue.
We are asked to construct a set of grid cells on an infinite checkerboard, where each chosen cell is considered “gray”. The shape we build must behave like a graph: cells are vertices, and edges connect cells that share a side. The construction must satisfy three conditions.
We are playing an interactive game on a circular array of n positions. All positions start empty. On each turn, the player is allowed to pick a number k and activate any k positions.
We are given a sequence of numbers and a very specific way to reorder it. In one operation, we pick any element and either push it all the way to the front or all the way to the back of the array.
We are given a multiset of lowercase letters, initially written as a string $s$. From this multiset, some letters are discarded and the remaining letters are rearranged arbitrarily to form a new string $t$.
We are given an array where each position has a fixed “required parity”: even indices must contain even numbers, and odd indices must contain odd numbers.
Each input value can be viewed as a box labeled with an integer, and for every box we must choose two non-trivial divisors of that number.
We are given two arrays of equal length and a very specific transformation rule. Starting from the first array, we are allowed to repeatedly pick a split size and swap two equal-length blocks: the prefix of that size and the suffix of the same size.
We are given an unknown array of non-negative integers, each up to 64-bit range. We cannot see the array directly. Instead, we can query any subset of indices, and the judge returns the bitwise OR of the elements at those positions.
We are given a permutation, which means every number from 1 to n appears exactly once, just in some order. From this array we are allowed to delete elements and keep the remaining ones in the same relative order, forming a subsequence.
We are given a hidden arrangement of the numbers from 0 to n−1 placed at indices 1 through n. The only way to gain information is to choose two different positions and receive the bitwise OR of the values stored at those positions.
We are given an array $A$ of length $n$, but we cannot see it directly. Instead, we can ask queries: pick any subset of indices and the judge returns the maximum value of $A$ over those indices. Along with this hidden array, we are given $k$ special index sets $S1, S2, dots, Sk$.
We are given a rooted tree where each node carries two bits of information: an initial binary digit and a desired final binary digit.
We are given a sequence that always contains consecutive integers starting from 0 up to some number n. Each number is viewed in binary, and all numbers are conceptually padded with leading zeros so they share the same bit length.
We are given a starting number and a target number, and we are allowed to transform the starting value using a very specific set of operations.
Each input item is a small “edge gadget” consisting of two pearls, and each pearl has an integer color in the range $[0, 2^{20})$. The goal is to take all these $n$ gadgets and connect their endpoints into one single cycle that uses every pearl exactly once.
We are given a set of points on the plane, one of which is guaranteed to be the origin. From these points, we must keep exactly k points and delete the rest.
We are asked to construct a binary grid of size $n times m$, where each cell is either 0 or 1, under two simultaneous constraints that tightly couple rows and columns. Every row must contain exactly $a$ ones, and every column must contain exactly $b$ ones.
We are given several independent arrays, each with an even number of elements. For each array, we must decide whether it is possible to split all elements into disjoint pairs such that every number belongs to exactly one pair and each pair satisfies a compatibility rule.
We are asked to count how many strictly increasing sequences of length $k$, chosen from the integers $1$ to $n$, have a very strong invariance property under repeated modulo operations.
We are given a collection of moving objects on an infinite plane. Each object starts from a fixed point, has a fixed direction, and moves in a straight line with a fixed speed.
We are given a sequence of months laid out in order, where each month has a fixed length in days. If we flatten the calendar, each day becomes a single linear timeline, but each position still knows its position inside its month, from day 1 up to day $di$.
We are effectively given a partially known array of length $n$. The first half (rounded up) is explicitly provided, while the second half is completely uniform and equal to a constant value $x$. So after reading the input, the entire sequence is actually determined.
We are given a hidden integer $X$ in each game, but we are never allowed to see it directly. Instead, we can query any integer $Q$, and the judge returns $gcd(X, Q)$.
We are asked to construct a positive integer array of length $N$ whose total sum is exactly $S$. After building this array, we also choose an integer $K$ between $0$ and $S$.
We are given a row of boxes, each box hiding either a valuable gift or a stone. Exactly k boxes contain gifts, and every other box contains stones. The key structural property is about weights.
We are given a regular polygon with $2n$ vertices, all edges equal to 1. The polygon is convex, and we are allowed to rotate it freely. We must place it inside a square, also freely rotatable, such that every point of the polygon lies inside or on the square boundary.
We are working with a fixed geometric object: a regular polygon with $2n$ sides, each side having length 1. This polygon is convex and highly symmetric, so its shape is completely determined once we fix how it is oriented and scaled in the plane.
We are asked to split a given integer $n$ into exactly $k$ positive parts such that all parts share the same parity. This means we must choose either all odd numbers or all even numbers, and these $k$ numbers must sum exactly to $n$.
The task is about breaking a given integer into simpler building blocks, where each building block is a number that looks like a single non-zero digit followed only by zeros. These are numbers such as 7, 40, 900, or 3000.
We start with a number and repeatedly apply a very specific transformation: find its smallest divisor greater than 1, and add that value to the number. This operation changes the number itself, so the divisor we use may change at every step.
We are given several shrubs, each containing two independent piles of berries: red and blue. From these sources we want to form as many baskets as possible, where every basket must contain exactly $k$ berries.
We are given an array and allowed to insert additional values anywhere inside it, where every inserted value must stay within the same value range as the original array elements.
We are given a string made of lowercase letters and we are allowed to split all of its characters into exactly k non-empty groups. Inside each group, we can reorder characters arbitrarily, so each group is effectively just a multiset of letters that we later sort into a string.
The game world is a directed graph with up to 15 locations, each location containing a fixed number of pellets. From any location you can reach any other, so the graph is strongly connected.
We are given a row of shelves, each holding some number of books. The goal is to reach a state where every shelf has at most k books. We are allowed to modify the configuration using two operations.
We are given an undirected connected graph where vertices represent rooms and edges represent tunnels. Each tunnel already has a fixed value, and we must assign a value to every room.
We are given a supply of identical cards and we repeatedly build structures called pyramids. A pyramid of height 1 is the smallest possible structure, and every higher pyramid is built in layers: a taller pyramid consists of a smaller pyramid placed on top of a wider base made…
The system is a rooted tree of stations, where every node with children behaves like a router that forwards all incoming trains to exactly one of its children.
We are given a hidden initial configuration of a length-n array. Each position contains either one of three primary colors or is empty. We never observe this initial array directly. Instead, we observe a sequence of operations applied to it over time.
We are given several categories of projects, and for each category we know how many projects exist. From each category we choose some number of projects to place on a résumé, with the constraint that the total number of chosen projects is exactly $k$, and we cannot pick more…
We are given a directed graph on variables $x1, x2, dots, xn$. Each constraint $xj < xk$ behaves like an edge $j to k$, and a full assignment of real values satisfies the formula only if every edge points from a smaller value to a larger value.
We are given an unknown permutation of numbers from 1 to n. Instead of seeing it directly, we receive n−1 pieces of information, each piece being a multiset segment taken from the permutation.
We are given a connected undirected graph where each edge represents a road, but the roads do not yet have fixed costs. Instead, we are also given a list of prices, and we must assign exactly one price to each edge.
We are working with integers and modular arithmetic, but the structure becomes clearer if we think of the infinite number line as being colored by a periodic rule. For any integer $x$, we compute two values: first we take $x bmod a$, then reduce that result modulo $b$.
We are given a binary string and asked to embed it into a larger binary string while preserving order as a subsequence.
The process builds a permutation from left to right, but the choice at each step is not based on already placed numbers.
We are given a straight road modeled as integer points from 0 to n. Some of these points are special positions called safety islands, including both endpoints. Denis starts at 0 at time zero and wants to reach n as fast as possible.
We are given several independent arrays, and for each one we must reorder its elements into a sequence where the absolute differences between neighboring elements never decrease as we move from left to right.
We are building an infinite sequence by repeatedly selecting groups of three unused positive integers. Each group must satisfy a strict bitwise condition: the XOR of the three numbers is zero.
We are given a tree, and the problem asks us to think about a geometric construction that can be performed on it. Each vertex becomes a closed non-self-intersecting curve on a plane.
We are given four integers in non-decreasing order, and we need to choose three lengths from three separate intervals. The first length must come from the first interval, the second from the second interval, and the third from the third interval.
We are dealing with a hidden multiset of tiles where each tile carries a value from 1 to n. The hidden configuration can be thought of as an array of frequencies a₁, a₂, …, aₙ, where aᵢ is the number of tiles with value i.
We are given two strings. The first string represents a queue of characters that we will consume from the left. The second string is a target pattern.
Codeforces 1335E2: Three Blocks Palindrome (hard version)
Each cell in the grid behaves like a deterministic state in a directed graph. From every cell, there is exactly one outgoing edge pointing to one of its four neighbors, as dictated by the arrow in that cell.
We are given a multiset of student skills for each test case. From this pool we must form two disjoint groups of students, both of the same size, say $x$.
We start with a fully valid Sudoku grid. Every row, every column, and every 3 by 3 subgrid contains the digits 1 through 9 exactly once.
We are asked to construct a walk in a complete directed graph on vertices labeled from 1 to n, where every ordered pair of distinct vertices forms a directed edge. This means between any two different vertices u and v, both directions u → v and v → u exist.
We are given a ring of monsters. Each monster has an initial health value, and also a fixed explosion damage value that is applied to its next neighbor when it dies.
We are given two integer arrays of the same length. The first array starts with very restricted values, each position being either negative one, zero, or positive one. The second array can contain arbitrary integers, potentially very large in magnitude.
We are given a sequence of integers and asked to count how many contiguous segments of this sequence are “robust” in a very specific sense. A segment is considered valid if every one of its nonempty contiguous subsegments has a sum that is not zero.
We are given an array of numbers and many queries over subsegments. For each query interval $[L, R]$, we must pick a subsequence of indices inside this interval, in increasing order, with length at least 3, such that the chosen values contain no triple of indices $i < j < k$…
We are given a rectangular grid with $n times m$ cells, and each cell starts with some integer height $a{i,j}$. The game allows two types of moves that increase heights: either we add one cube to two adjacent cells at the same time, or we add two cubes to a single cell.
We are given a short program written in a heavily stylized “Roman-like” pseudocode language. The program reads a sequence of integers from standard input, and for each integer it computes a numeric function and prints either a formatted value or a special overflow message.
We are given a single 7-character number written in a mixed numeral system. The first character is always the letter A, which should be interpreted as the value 10. The remaining six characters are digits from 0 to 9. Together, they form a base-11 number of fixed length 7.
We are given a very long binary string consisting only of the characters A and B, with the guarantee that the first and last characters are always A. In addition to these fixed endpoints, we are given the positions of some other A characters inside the string.
We are given a string that evolves under a deletion game. In one move, we are allowed to pick a contiguous substring, but only if that substring is “locally alternating”, meaning no two adjacent characters inside it are equal.
We are asked to count how many strictly increasing sequences of integers we can choose from the range $[1, d]$, with an extra constraint that depends on cumulative XORs of the chosen values.
Codeforces 1329C: Drazil Likes Heap
We are given a row of cells initially all unpainted. We will perform a sequence of painting operations, where each operation paints a contiguous segment of fixed length, but we are free to choose the starting position of that segment.
Codeforces 1328F: Make k Equal
We are given a circular arrangement of positions, each holding an animal type. The positions are connected in a cycle, so after the last position comes the first again. We must assign a color to each position.
We are given a ternary string x, meaning each position is a digit among 0, 1, or 2. The task is to split this single number into two ternary numbers a and b, both of the same length as x, such that if we add them digit by digit modulo 3, we recover x.
We are given a grid of size $n times m$ with several chips placed on cells. Each chip can be moved simultaneously with all others by applying a single global move in one of four directions: up, down, left, or right.
We are building an array of length $n$, where each position stores an integer with at most $k$ bits. On top of that, we are given several constraints, each describing a segment $[l, r]$ and a required value for the bitwise AND of all elements in that segment.
We are given a permutation p, which we can think of as values arriving in a fixed order from position 1 to n. While processing this order, we maintain a multiset A. Each time we process position i, we insert p[i] into A.
We are given a string and we want to build the longest possible palindrome that can be formed by taking a prefix of the string, a suffix of the string, or both, and concatenating them in that order.
We are given a geometric tree: each vertex is a point in the plane and edges form a non-crossing tree. This already means the embedding is fixed, so geometric notions like convex hull are meaningful relative to the given drawing.
We are given a sequence of integers, and we want to select a subsequence whose product becomes a perfect square. Among all such subsequences, we need the minimum possible length.
We are given an array and we construct a much larger array by repeating it end-to-end many times. The repetition count is equal to the original length of the array, so the final sequence has size $n cdot n$.
We are given a sequence of column heights representing a vertical terrain. Each column has some initial number of blocks stacked on it. The only operation available is to repeatedly choose a column and place a fixed vertical piece that increases that column’s height by 2.
We are given a list of topics, each topic carrying two different scores. One score measures how interesting the topic is for the teacher, and the other measures how interesting it is for students.
We are given several independent arrays of positive integers. For each array, we must select a non-empty group of positions such that the sum of the chosen values is even. If no such group exists, we report failure.
We are given a tree with $n$ stations and $n-1$ tunnels, so between any two stations there is exactly one simple path. On this tree, we are also given $m$ special routes.
We are given a string consisting only of parentheses, and we are allowed to modify it using an operation that picks any contiguous segment and permutes its characters arbitrarily. The cost of such an operation equals the length of the chosen segment.
We are given a string of lowercase letters. We repeatedly remove characters under a local rule: a character can be deleted only if at least one of its current neighbors is exactly one letter earlier in the alphabet than itself.
We are given a fixed binary string, and we repeatedly consider two kinds of local transformations on any contiguous segment of length three: swapping 011 into 110, or the reverse swap 110 into 011.
We are given a directed graph where intersections are nodes and roads are one-way edges. We also know a fixed simple route Polycarp actually drives from his home to his work.
We are given a list of officers, each with a numerical power. From these officers, a battalion is formed by choosing any subset uniformly at random, including the empty set.
We are given a sequence of values that are meant to represent the smaller element in each of several disjoint pairs. In the final construction, we must build an array of length 2n using every number from 1 to 2n exactly once, and then split it into n consecutive pairs.
We are given a one-dimensional town represented as a line of crossroads indexed from 1 to n. Each position has exactly one type of transport station: either type A (bus-compatible segment marker) or type B (tram-compatible segment marker). The string s encodes this layout.