brain
tamnd's digital brain — notes, problems, research
41650 notes
We are given a four-digit year as a string, potentially including leading zeros, and we are asked to determine if this number can be expressed as the square of the sum of two non-negative integers.
Let $f(n)=2^n-1$.
We are asked to maintain an array of n sets under a sequence of q online operations, where each operation modifies some prefix of sets or deletes a specific element from all sets, and then asks for the smallest element in a particular set.
We are asked to navigate a directed acyclic graph (DAG) with vertices numbered from 1 to n. Each vertex contains a trader who sells cards with a given power for a given cost.
We start with a sequence of positive integers. In one move, we pick two different positions, say $i$ and $j$, and we overwrite $ai$ with the greatest common divisor of its current value and $aj$. The second element $aj$ stays unchanged.
Let $A_0A_1,\dots,A_{n-1}A_n$ be consecutive segments on a line with each length at most $1$.
We are given an array of positive integers, and the goal is to repeatedly apply one of two operations to reduce every element to zero. The first operation subtracts each element by its 1-based index, and the second subtracts each element by its "reverse index" (n minus i plus 1).
We are given a sequence of doors arranged in a line. Each door is either open or closed. Yousef starts before the first door and must move strictly from door 1 to door n in order.
We are asked whether one array of integers, a, can be transformed into another array, b, using two types of operations. The first operation is a cyclic left shift, which moves every element one position to the left and wraps the first element to the end.
We have an odd-sized rectangular grid. Cells are colored one at a time. Whenever a new cell is colored, we look only at the cells that were already colored before this step. Among those cells, every cell that is farthest from the newly colored one receives one penalty.
We have a one-dimensional strip of length up to $10^{15}$, along which certain cells contain traffic lights. Each light has a fixed period $k$ and a delay $di < k$, and it turns red at times $l cdot k + di$ for integer $l ge 0$. All other times, the light is green.
We are asked to simulate motion along a one-dimensional strip of length up to $10^{15}$, where certain cells contain traffic lights with periodic red signals. Each traffic light has a fixed period $k$ and a delay $di$, meaning it shows red at times $t$ where $t mod k = di$.
We are given an array of integers. Each integer has a "beauty" defined as the number of 1s in its binary representation. For example, 5 in binary is 101, which has two 1s, so its beauty is 2. The total beauty of the array is the sum of the beauties of all its elements.
We start with an $n times n$ matrix where every row is identical and equal to the sequence $1,2,3,dots,n$. So initially every column is constant, and no column is a permutation at all.
We are asked to construct a binary string of length $n$, containing exactly $k$ ones, with an additional structural constraint involving subsequences of length three.
We are given a rooted tree where every node carries a value of either +1 or −1. A lava wave starts from the root and expands outward one edge per time unit, so at time t every node at distance at most t from the root is already unsafe.
Label the people $1,2,\dots,N$ from left to right.
We are given two sequences, a of length n-1 and b of length n. The goal is to increase elements in b using the fewest increments so that for every adjacent pair (bi, b{i+1}), their bitwise AND equals ai.
We are given sequences where each position i can store a value a[i] between 0 and i inclusive. Think of the index i as a time step and also as the right endpoint of a segment. Now interpret the process that defines the weight.
We are asked to construct an array of length n using integers within a given range [l, r], such that the bitwise AND of all elements equals the bitwise XOR of all elements. We do not need to output the full array; only the k-th element in lexicographical order.
We are given two non-negative integers a and b and two operations that can transform a. The first operation increments a by one at a cost x. The second operation flips the least significant bit of a (using a XOR 1) at a cost y.
We are given two fixed points on a plane: a starting location and a destination. We also receive a sequence of movement lengths. At step i, we must move from our current position to any point whose Euclidean distance from the current position is exactly ai.
We are given a simple, connected graph $G$ with $n$ vertices and $m$ edges, and we are asked to examine the properties of its iterated line graph $L^k(G)$.
Each lane initially contains ai cars. If nobody moves, the cars in a lane leave one per second, so a lane of size x contributes $$1+2+dots+x=frac{x(x+1)}2$$ to the total angriness. Cars may switch lanes.
We are given several graphs on the same vertex set. For each graph, we can imagine a "superb graph" as a compressed version in which vertices of the superb graph correspond either to independent sets or cliques of the original graph.
We are asked to determine the smallest size of a matrix Aryan should request from Harshith to guarantee that Aryan can always find a submatrix of size $a times b$ filled with identical numbers.
We are asked to construct a rooted tree of n nodes with a special property: each node has a divineness, which is the smallest node label on the path from the root to that node.
We are given three axis-aligned rectangles. Their dimensions are already ordered so that $$l3 le l2 le l1$$ and $$b3 le b2 le b1.$$ The rectangles cannot be rotated.
We are given a square pool table of side length $s$ with pockets at the four corners. On this table, $n$ balls are placed at integer coordinates strictly inside the table, never on the edges or corners.
We are given an integer array and, for each test case, two target values: a required subarray sum s and a required maximum value x. The task is to count how many contiguous subarrays have total sum exactly equal to s and whose largest element is exactly x.
We are asked to process a binary string and compute, for every contiguous substring, the maximum frequency of either 0 or 1 in that substring, then sum these values across all substrings.
At each vertex of the polyhedron, exactly three edges meet, so the vertex figure is a trihedral angle.
We are given two arrays, a and b, each of length n, containing all integers from 1 to 2n exactly once between them. The task is to rearrange the arrays using three types of swaps so that a is strictly increasing, b is strictly increasing, and at each position i, a[i] < b[i].
We are given two integers of equal length in decimal form, and we are allowed to pick any integer x that lies within the inclusive range between them.
We are given a rectangular grid of integers. In one move, we pick a single row and a single column. Every cell that lies in that chosen row or that chosen column gets decreased by one, with the intersection cell counted only once.
We are asked to determine, for a given string, whether it is possible to split it into three non-empty parts, $a$, $b$, and $c$, such that $a + b + c = s$ and the middle segment $b$ appears as a substring of the concatenation $a + c$.
We are given a set of distinct integer positions on the number line and a starting position. From the starting position, we can move left or right by one unit at a time.
We are given a small array of integers $a = [a1, a2, dots, an]$, with $n le 8$ and a total sum $S = a1 + dots + an le 100$.
We are asked to count valid parking schedules for cars on a tree. Each vertex of the tree will eventually host one car.
We are given a $2 times n$ grid with some cells already filled with integers between $1$ and $k$, while other cells are empty.
We are given several piles of tiles, each containing some zeros stacked on top of ones. For each pile, we know both the initial configuration and the target configuration, where the target also consists of some zeros on top of some ones.
The problem describes a connected, simple undirected graph with n vertices and m edges. A token starts at vertex 1 at time 0. At each integer second t, if the token is at vertex u, you have two choices: either wait one second at u, or move along a specific edge of u.
We are given a set of points on a 2D plane, and the number of points is always even. Our task is to pair all points into disjoint pairs such that the sum of Manhattan distances between the points in each pair is maximized.
We are working on a grid where each cell contains a nonnegative number, and we are only allowed to move either right or down starting from the top-left corner. Any such path from the top-left to the bottom-right has a total score equal to the sum of all visited cells.
We are asked to construct a permutation of integers from $1$ to $n$ such that for every position $i$ from $2$ to $n$, the greatest common divisor of the position and its value, $gcd(pi, i)$, is strictly greater than $1$.
A direct synthetic approach would require tracking the foot of a perpendicular from $B$ to the line $PC$, which suggests that a coordinate representation or vector projection will likely reduce the co…
We are maintaining an array that changes over time, and we are asked to answer two kinds of queries. One type permanently updates a single position in the array.
We are given a binary string. Two players alternate moves, with Alice moving first. The game evolves by repeatedly rewriting parts of the string.
We are given an array of nonnegative integers, and we are asked to compute the number of distinct possible values of the minimum excluded value (MEX) after removing exactly $k$ elements from the array, for each $k$ from 0 to $n$.
We have a tournament with n players. Player i has strength a[i]. Repeatedly, two surviving players are selected, and the weaker one is eliminated. If both strengths are equal, either one may be eliminated. The process stops when exactly k players remain.
The blackboard initially contains every integer from 0 to n - 1. A round always has two moves. First Alice removes some number a. Then Bob must remove a different number b such that $$a+b equiv 3 pmod 4.$$ If Bob cannot find such a number, the game ends immediately and Bob loses.
We are given an array of distinct integers and a set of operations: you can either replace a prefix with its minimum or a suffix with its maximum.
Codeforces 2124I: Lexicographic Partition
We are given an array a. We want to choose a subsequence and reinterpret it as a new array b. The goal is to maximize the length of b, subject to b being a good array. The definition of goodness is written in terms of a permutation and range minimums.
We are building an array of length $n$, but we are not constructing it element by element. Instead, the array is formed by repeatedly appending whole blocks. Each block is a cyclic rotation of the permutation $[1, 2, ldots, s]$ for some chosen length $s$.
I can't honestly produce a correct "complete solution editorial" for Codeforces 2124G from the information available here.
We start with an array and may repeatedly delete elements. The deletion rule is unusual: choose any subarray of length at least k, find its k-th smallest value, and delete one occurrence of that value inside the chosen subarray.
We are asked to count arrays of length $n$ that can be built by repeatedly appending cyclic shifts of the arrays $[1, 2, dots, s]$ for any $s ge 1$, while respecting a set of restrictions of the form $ai ne x$.
We are given an array of positive integers, and our only allowed action is to repeatedly subtract a carefully chosen auxiliary array from it.
We are given an array and may delete any number of elements while preserving the relative order of the remaining ones. After the deletions, the remaining sequence must be non-empty.
We are given an array and we repeatedly look at prefix minimums: at position 1 we take the minimum of the first element, at position 2 we take the minimum over the first two elements, and so on until the full prefix. The final value is the sum of all these prefix minima.
We are given an array b that was generated from an unknown “beautiful” array a, where each element divides the next. Bob then chose an integer x and multiplied some subset of a’s elements by x to form b. Our task is to recover any valid x.
Timofey has written a text s and wants to present it to a conference audience. Each attendee understands the topic if the number of times the substring "docker" appears consecutively in s falls within their personal interval [li, ri].
The problem asks us to count sets of integers that can be generated as complementary sums from some array of positive integers.
We are working with a line of $m$ cells. Each cell must end up being covered by exactly one chosen interval. There are $n$ candidate segments. Each segment $i$ covers a contiguous range $[li, ri]$, but it is not guaranteed to exist.
We are given several strings consisting of uppercase letters. Each letter represents a contest problem. A contest is considered difficult if the string contains either "FFT" or "NTT" as a contiguous substring. We may rearrange the letters of the string in any order.
A number is called good if none of the primes in its prime factorization are single digit primes. The only single digit primes are 2, 3, 5, and 7, so a number is good exactly when it is not divisible by any of these four primes.
We start with a robot placed at a coordinate $(a,b)$ on an infinite grid, and we want to move it back to the origin $(0,0)$.
We are given an array of integers, each between 1 and $n$, and we need to choose a contiguous subarray that maximizes the difference between its median and its minimum element.
We are asked to find, for each array, a contiguous segment whose median minus its minimum is as large as possible. Formally, for a subarray $a[l, r]$, we calculate the median of its elements after sorting, then subtract the smallest element in that segment.
We are given a tree where every vertex has a color and every edge has a weight. An edge contributes its weight to the total cost only when its endpoints currently have different colors; if the endpoints share the same color, the edge contributes nothing. The process is dynamic.
We are given two arrays of integers, p and s, each of length n. Array p represents the prefix GCDs of some unknown array a, and array s represents the suffix GCDs of the same array. The task is to decide whether such an array a exists.
We are given a sequence of casinos, each defined by a range of coins [li, ri] that we must have to play, and a fixed result reali that becomes our new coin count after playing there. We start with k coins and can visit casinos in any order, but only once each.
We are given a sequence of days, each labeled either as rainy (1) or good (0). Jean wants to complete as many hikes as possible. Each hike takes exactly k consecutive days of good weather, and after finishing a hike, he must rest for at least one day before starting another.
The task asks us to find the smallest non-negative integer that shares at least one decimal digit with a given number. For every test case, we are provided a number x, and we need to produce a number y such that some digit in y also appears in x.
We are given an undirected, connected graph with up to 30 vertices, where each vertex belongs to at most 5 simple cycles. A simple cycle here is a closed path where each vertex has exactly two neighbors.
We start with an array of length n, filled with zeros. An operation chooses a positive integer x that is strictly larger than the current minimum value in the array. The operation does not let us choose which position receives the increment.
We are given several independent scenarios. In each scenario there is a collection of bags, each with an initial weight. Time proceeds in discrete seconds. At every second we are forced to remove exactly one remaining bag.
We are given a hidden permutation of integers from 1 to $n$, and we can only access it indirectly through interactive queries. There are four types of queries.
We are asked to recover a hidden permutation of the numbers from 1 to $n$ through a limited set of interactive queries.
We are given a hidden binary string made of opening and closing brackets, and we are allowed to probe it indirectly.
We are given a simple undirected graph whose vertices are labeled from 1 to n. The label itself is also the index of the vertex. The graph does not change, but each query focuses only on a contiguous segment of vertices, from l to r.
We are given a permutation of numbers from 1 to $n$, and a process that colors these numbers one by one in the order of the permutation. Each cell starts white with a score of zero.
We are given a hidden string made only of opening and closing parentheses. We cannot see it directly. Instead, we can query any multiset-like sequence of indices, and the judge constructs a new string by taking the characters at those indices in order.
We are given a hidden bracket sequence of length $n$, consisting only of '(' and ')'. The goal is to reconstruct this sequence by asking at most 550 interactive queries.
We are given a permutation of integers from 1 to n. For each element in this permutation, we are allowed to either leave it as-is or replace it with its “mirror” with respect to 2n, defined as $2n - pi$.
We are given a collection of segments on a line, each segment also acting as an edge between two vertices. From this set we must choose some subset of edges. Two different quantities are computed from the chosen subset.
We are given a multiset of non-negative integers, which we can think of as a bag of numbered tiles. Our goal is to repeatedly choose subsets of tiles and increase a score using one of two rules: either add the sum of the chosen tiles to the score, or add the minimum excluded…
We start with a finite set of distinct positive integers. A single move depends entirely on the current minimum element of the set.
The problem gives us an array of integers, each between 1 and some upper bound $m$, and asks us to find four distinct indices $p, q, r, s$ such that the pair $(ap, aq)$ and the pair $(ar, as)$ are both coprime.
We are given two binary strings, a and b, each of length n. They define a virtual n × n grid where each cell (i, j) contains the value a[i] XOR b[j]. Yuri starts at the top-left cell (1,1) and can only move either right or down.
We are given two arrays, a and b, both of length n. We can perform an operation on a at most once per index: for any index i from 1 to n-1, we can set a[i] to a[i] XOR a[i+1].
We are given a tree, an undirected connected graph with no cycles. Kagari can perform an operation that "re-roots" a path: choose two vertices, remove the edges along the path connecting them, and then reconnect all vertices along that path directly to the starting vertex.
We need to construct an integer array of length n with two properties. The first property says neighboring elements must always have opposite signs. Since their product must be negative, neither element can be zero, and the signs must alternate.
We start with a multiset $S$ of size $n$ and we want to transform it into another multiset $T$ of the same size. The only allowed move takes one element $x$ from $S$, deletes it, and replaces it with either $x+k$ or $ The core question is whether repeated applications of these…
We are given two arrays of equal length, a and b, and a machine called The Lever that iterates a process in which it adjusts the elements of a toward the elements of b.
We are given a rectangular grid of ballerinas, each performing one of 26 possible movements represented by lowercase English letters. Conceptually, each row is a string, and the entire grid is an array of strings.
We are asked to analyze a connected undirected graph representing the Chamomile Valley, where nodes are houses and edges are lanes between them. Rada wants to know which lanes are guaranteed to be part of every shortest path from house 1 to house n.
Each deal lets us buy exactly $3^x$ watermelons for $$3^{x+1} + x cdot 3^{x-1}$$ coins. We need to buy exactly $n$ watermelons. We may use at most $k$ deals. Among all valid ways to do that, we want the minimum total cost.
The problem presents a team of two players, Vadim and Kostya, who each have a collection of cards with numeric values.