brain
tamnd's digital brain — notes, problems, research
41751 notes
We are asked to determine the minimum radius of light for lanterns placed along a straight street of length l so that the entire street is illuminated. Each lantern is at a fixed position along the street and can light up points within a distance d to its left and right.
We are given a sequence of strings. Each string represents a positive integer, but some digits have been replaced by '?'. The original sequence was strictly increasing. Our task is to replace every '?
We are given a tree of cities, where each city has a population. The roads connect cities such that there is exactly one simple path between any two cities.
Each chocolate bar is a rectangle made of unit squares, so its “value” is just its area. We start with two rectangles and we are allowed to modify them minute by minute.
Each input line describes one student, but the student's own ID is not given directly. Instead, we are told the ID of the student standing immediately in front of them and the ID of the student standing immediately behind them.
We are given a very long decimal number as a string. Its length can reach one million digits, so treating it as a normal integer is impossible. We must choose a position where the string is cut into two nonempty pieces.
We are given a list of children, each identified by a number indicating their skill: programming (1), maths (2), or physical education (3). The task is to form as many teams of three as possible, where each team has exactly one child from each skill.
We have a sequence of resting points along a river. Point i is located at position x[i] and has picturesqueness value b[i]. The traveler starts at coordinate 0 and must finish at the last resting point, which is also the farthest one.
We are asked to count the number of n × n binary matrices where each row and each column contains exactly two ones. Some of the first rows are already fixed, and we must count only matrices consistent with them.
We are given a directed graph representing intersections and one-way roads. A "damn rhombus" consists of four distinct vertices $a, b, c, d$ such that there are directed edges $$a rightarrow b,quad b rightarrow c,quad a rightarrow d,quad d rightarrow c$$ In other words, from…
We are given an array of integers and must transform it into non-decreasing order by performing swaps of array positions. The interesting part is that we do not need the minimum number of swaps. Any valid sequence containing at most n swaps is accepted.
We have two groups of dancers. Each boy has a skill level, and each girl has a skill level. A boy and a girl can be paired only if their skill levels differ by at most 1. Every dancer can belong to at most one pair. The task is to form as many valid boy-girl pairs as possible.
We are asked to construct two integers of a specified length, m, such that the sum of their digits is exactly s. One of these integers must be the smallest possible and the other the largest possible in lexicographical order.
We are asked to handle queries on a connected undirected graph representing cities in Cyberland. Each city has a souvenir price, and roads connect pairs of cities.
We are given a rectangular table of size n by m filled with conveyor belts. Each conveyor belt points either up (^), left (<), or right (). Surrounding the table are diner seats, numbered logically as rows 0 and n+1 and columns 0 and m+1.
We need to arrange the numbers $1,2,dots,n$ into a permutation $a1,a2,dots,an$. Define $$pi = a1a2cdots ai pmod n.$$ The requirement is that the sequence $p1,p2,dots,pn$ must itself be a permutation of all residues $0,1,dots,n-1$.
We are given the initial combat statistics of two characters, Master Yang and a monster. Each character has hit points, attack, and defense. Combat proceeds in discrete seconds.
We have an array of integers representing numbers on a strip of paper. Alexandra wants to divide the strip into contiguous segments. Each segment must have at least l numbers, and the difference between the largest and smallest number in that segment must not exceed s.
We are given an array and we care about its longest increasing subsequences. An index belongs to a longest increasing subsequence if the value at that position is selected as one of the elements of that subsequence. The task is not to count LISs.
We are given a tree where every vertex has an integer value. A set of vertices is considered valid if it is non-empty, forms a connected subgraph of the tree, and the difference between the largest and smallest value inside the set does not exceed d.
We are given a string of length $n$ consisting of lowercase English letters, along with a cursor position $p$ that can move left or right around the string in a cyclic manner.
We are given a single integer n and asked to evaluate the alternating sum $$-1 + 2 - 3 + 4 - 5 + dots + (-1)^n n.$$ The sign of each term depends on its position. Odd numbers are subtracted and even numbers are added. The output is the final value of this sum.
We are given a matrix B of size m × n, where each element is either 0 or 1. This matrix was supposedly generated from some original matrix A of the same size using a specific rule: each element B[i][j] equals the logical OR of all elements in the i-th row of A combined with…
We have a fence represented by an array of heights. A rectangular sign must be placed on top of some consecutive panels. The sign has a fixed width w, so it must cover exactly w consecutive fence panels.
We have a line of children, each with an integer charisma value. The goal is to partition the line into contiguous groups. For each group, its sociability is the difference between the largest and smallest charisma values in that group.
Working
We are asked to process several queries, each defined by a lower bound l and an upper bound r. For each query, we need to find the integer x within the interval [l, r] such that the number of set bits in its binary representation is as large as possible.
We are given a sequence of integers a1, a2, …, an and asked to compute the maximum value of ai % aj over all pairs (i, j) where ai ≥ aj. The input consists of the number of integers n and the sequence itself.
We know all candidate strings in advance. One of them is chosen uniformly at random. We reveal information by asking about character positions. The order of questions is not chosen strategically. At every step we pick uniformly among positions that have not been asked yet.
We are given a rooted tree with n vertices, where vertex 1 is the root and every other vertex i has a specified parent pi. Initially, every vertex is painted red.
I can't provide a correct "complete solution editorial" with a full accepted implementation for Codeforces 482E from first principles here, because this is a very difficult 3200-rated dynamic-tree problem and I do not have enough information to reliably reconstruct the entire…
We are asked to construct a permutation of integers from 1 to n such that the set of absolute differences between consecutive elements contains exactly k distinct values.
We are asked to construct an array of n non-negative integers such that m given bitwise AND constraints are satisfied.
We have a company hierarchy that is built gradually over time. Initially nobody has a boss. A type 1 operation attaches an employee x under employee y, making y the boss of x. The input guarantees that x currently has no boss, and cycles never appear.
We are given an undirected weighted graph with up to 100,000 vertices and 100,000 edges. Each edge weight is a power of two, specified as $2^{xi}$, where $xi$ is between 0 and 100,000.
We are given eight points in three-dimensional space. Each point was originally a vertex of a cube whose side length was positive. The complication is that the coordinates have been corrupted in a very specific way.
Working
We are given a string s of length n consisting of lowercase letters, and an integer p representing the number of allowed letters from the start of the alphabet, that is, 'a' through chr(ord('a') + p - 1).
We start with a decimal string s. Then a sequence of replacement rules is applied in order. Each rule has the form d - t, meaning every occurrence of digit d is replaced by the string t.
We are given a permutation of the numbers 1...n. For two distinct values a and b, their average is (a+b)/2. Since the permutation contains every integer exactly once, this average is also present whenever a+b is even.
We have a three-stage production pipeline. Every laundry item must first be washed, then immediately transferred to a dryer when washing finishes, then immediately transferred to a folding machine when drying finishes.
We are given a number X and an integer k, and we want to construct a sequence by repeatedly expanding each number into its divisors in increasing order. Formally, we define X0 as a sequence containing just X.
We are given two distinct lowercase words, s and t, and we are asked to determine how s can be transformed into t using specific operations inspired by suffix data structures.
We are asked to compute the minimum number of brush strokes needed to paint a fence of vertical planks. Each plank has a width of 1 meter and an individual height. The brush is exactly 1 meter wide, and it can be applied either vertically or horizontally.
We are tasked with simulating insertions into a hash table with a fixed number of buckets. Each bucket can hold at most one element. The hash function is simple: for a number $x$, the target bucket is $x mod p$. We receive a sequence of numbers and must insert them in order.
Each vertex is incident to exactly two red edges, so the red edges form a $2$-regular subgraph of the edge graph of the polyhedron.
We have an n × m matrix of integers. We must perform exactly k operations. An operation chooses either an entire row or an entire column. The current sum of that row or column is added to our answer, then every element inside it is decreased by p.
We are given an array of up to $10^5$ integers. We may choose any contiguous subarray and are allowed to modify at most one element inside that subarray, replacing it with any integer we want.
The chemicals and reactions form an undirected graph. Each vertex represents a chemical, and an edge between two vertices means those two chemicals react. We start with danger equal to 1. Chemicals are poured one at a time in any order.
We study functions of the form $f_{a,b}(n)=\lfloor an+b\rfloor$ with $a>0$ acting on $\mathbb{N}$.
We are given a tree with n nodes, where each edge has a positive weight. For any two nodes x and y, the function g(x, y) is defined as the maximum weight along the unique path connecting them.
We have a ribbon consisting of positions 1...n. Initially, position i has color i, so every position starts with a distinct color. Two kinds of operations are performed. A paint operation assigns a new color x to every position in a segment [l, r].
The task asks us to compute a sequence c based on two sequences a and b of length n. Sequence a is a permutation of the integers from 1 to n, and b is a binary sequence with exactly d ones, both shuffled in a pseudo-random but reproducible way.
We are given a string of lowercase English letters that Kolya initially owns, and he can append up to k additional characters to the end. The task is to determine the maximum possible length of a tandem repeat in the resulting string.
The tree starts with a single root vertex. Each operation adds one new leaf to an existing vertex. After every addition we must compute the smallest possible value of the following quantity. We color the edges of the tree.
I can't reliably produce a complete editorial for this problem from first principles without reconstructing the original 3100-rated geometry solution in detail.
We are asked to simulate a game on an array of positive integers where, at each move, we remove a single element and earn points equal to the minimum of its adjacent elements. After removal, the array closes up and the game continues until all elements are gone.
The configuration is a complete quadrilateral formed by the four lines $AB, BC, CD, DA$.
We are given a toy made up of n parts connected by m ropes. Each rope connects two distinct parts, and no pair of parts has more than one rope between them. Each part i has an associated energy cost v[i]. The child removes parts one at a time.
The input is not given in the usual structured format with counts. Instead, it is a small text file that alternates between country names and lists of superstitions. A line that does not start with is a country name.
We are given a small list of contest dates. For each date, we must determine whether that calendar day is both the 13th day of its month and a Friday. The answer is simply the number of contest dates satisfying both conditions.
Let $n=\prod p_i^{\alpha_i}$ with all $p_i<100$.
Let $S$ be the set of amounts obtainable with at most $1000$ coins of denominations $a$ and $b$.
Let the value of a completed coloring be the number of edges of the 100-cycle whose endpoints have different colors.
The problem asks whether a circle can be dissected into finitely many pieces whose boundaries consist of line segments and circular arcs, and then reassembled into a square of the same area.
Let the convex polygon be $A_1A_2\ldots A_n$, indexed cyclically.
Each question consists of choosing a line and learning in which of the three sets determined by that line the point $P$ lies: one open half-plane, the other open half-plane, or the line itself.
Let $B$ be the set of black numbers and $W$ the set of white numbers.
Each vector lies in the first quadrant and has length $1$.
Let
Each allowed integer has the form
Suppose the partition consists of finitely many arithmetic progressions
A number is marked if it can be written as a sum of exactly five powers of two, repetitions allowed.
Let
The statement involves a median and an angle bisector meeting at a point.
Let the square have side length $1$.
The condition says that every triangle whose three sides belong to the colored segments contains both colors.
Take a small example, say $p=2$, $q=3$.
Let the given integers be $a_1,\dots,a_{p-1}$, none divisible by $p$.
Let the odd number be
Take a small example, say $a=3$, $b=7$.
Each committee has $80$ members, and there are $16000$ committees.
The equalities
Let
We need a set $A$ of positive integers such that every infinite set $S$ of primes contains, among the squarefree numbers formed from distinct primes of $S$, two numbers with the same number $k\ge2$ of…
Let the acute triangle be $ABC$.
Let
The hypothesis is that a map $F:\mathbb{R}^2\to\mathbb{R}^2$ preserves unit distance, meaning every pair of points at distance $1$ is mapped to a pair of points at distance $1$.
The expression
We seek an infinite set $S \subset \mathbb{N}$ such that no element of $S$ and no finite sum of distinct elements of $S$ is a perfect power $a^k$ with $k \ge 2$.
Each ship occupies an entire row or an entire column of an $n\times n$ board, and different ships are disjoint, so all ships are either rows or columns exclusively.
Let the sofa, suitcase, valise, picture, basket, cardboard box, and dog have weights $S, U, V, P, B, C, D$ respectively.
The first question asks for a three-digit integer $x$ such that $x^3$ ends in $777$, equivalently
Let the fixed isosceles right triangle be placed as a unit right isosceles triangle with vertices $A(0,0)$, $B(1,0)$, $C(0,1)$.
The three semicircles with diameters $AB$, $BC$, $AC$ lie on the same line $AB$, with centers at the midpoints of $AB$, $BC$, and $AC$.
The transformation replaces each term by the average of the other two.
Let the apex of the regular square pyramid be $S$, and let the base square be $ABCD$ with center $O$.
Let $A=(a_{ij})$ be an $m\times n$ matrix.
Label the vertices of a regular $n$-gon by $0,1,\dots,n-1$ in cyclic order.
The requirement that every training session consists of 4 disjoint crews of 4 cosmonauts means that each session partitions the 16 cosmonauts into 4-element subsets.