brain

tamnd's digital brain — notes, problems, research

43815 notes

TAOCP 7.2.1.2 Exercise 80

Let $n=s+t$ and represent each $(s,t)$-combination as a binary string $a_{n-1}\dots a_0$ with exactly $t$ ones and $s$ zeros.

taocpmathematicsalgorithmsvolume-4medium
TAOCP 7.2.1.2 Exercise 79

Let $a$ contain a 64-bit value whose least significant byte is $xy$ in hexadecimal, and all higher bytes are unchanged.

taocpmathematicsalgorithmsvolume-4medium
CF 103567E - Хакерская Атака

We are dealing with a simple exponential growth model where an initial quantity of viruses expands by a fixed multiplicative factor each second.

codeforcescompetitive-programming
TAOCP 7.2.1.2 Exercise 78

Let the program of Exercise 77 implement Heap’s method for generating all permutations of the $r$ elements stored in the global registers $a_0,\ldots,a_{r-1}$.

taocpmathematicsalgorithmsvolume-4math-medium
TAOCP 7.2.1.2 Exercise 77

The failure in the previous attempt is not superficial.

taocpmathematicsalgorithmsvolume-4medium
TAOCP 7.2.1.2 Exercise 76

Let $G=\mathbb{Z}_m\times \mathbb{Z}_n$, $m,n\ge 3$, and define A=(2,1),\qquad B=(1,2).

taocpmathematicsalgorithmsvolume-4math-hard
CF 103567C - Тролль Сева

The problem describes a process where we are effectively interested in whether a specific arithmetic sequence ever produces a number divisible by a given integer $N$. The sequence is fixed and grows by a constant step, starting from a small offset: $2, 5, 8, 11, dots$.

codeforcescompetitive-programming
TAOCP 7.2.1.2 Exercise 75

Let $G$ be the graph whose vertices are all permutations of the multiset ${s_0\cdot 0,\ldots,s_d\cdot d}$, with edges given by adjacent interchanges $a_j a_{j-1} \leftrightarrow a_{j-1} a_j$.

taocpmathematicsalgorithmsvolume-4math-hard
TAOCP 7.2.1.2 Exercise 74

Let $G$ be the Cayley graph of a group generated by two elements $\alpha$ and $\beta$ satisfying $\alpha\beta=\beta\alpha$.

taocpmathematicsalgorithmsvolume-4math-hard
CF 103567G - Неожиданный кроссовер

We are given a deterministic two-player movement system on a grid, but instead of thinking in terms of players, it is more useful to think of it as a directed state graph over configurations.

codeforcescompetitive-programming
CF 103567F - Метро

We are given a long array of values that represent passenger flow at different time moments of the day. A “shift” is defined by three parameters: a starting time index s, a fixed number of trips k, and a constant time gap d between consecutive trips.

codeforcescompetitive-programming
CF 103567D - (Не)достижимый идеал

We are given a fixed integer $N$ and a range of integers $[L, R)$, meaning all integers $X$ such that $L le X < R$. For each such $X$, we need to determine whether it satisfies a condition involving the greatest common divisor with $N$.

codeforcescompetitive-programming
CF 103567B - Шахматная доска

We are working with an $N times N$ chessboard where each cell is colored either black or white in the usual alternating pattern. Instead of just counting cells, each cell is assigned a growing integer value, and we need the total sum of all values on the board.

codeforcescompetitive-programming
CF 103567A - Треугольники

We are working with a fixed geometric configuration of 12 equally spaced points placed on a circle. Each triple of distinct points forms a triangle, and we are asked to count how many of these triangles have all three interior angles strictly acute.

codeforcescompetitive-programming
CF 103573C - Свободное перемещение

Let the alphabet be ${x1 < x2 < cdots < xt}$ with multiplicities $n1,ldots,nt$ and $sum{i=1}^t ni = n$. Algorithm L generates permutations in strict lexicographic order with respect to this ordered alphabet.

codeforcescompetitive-programming
CF 103573D - Подрыв ветряка

I don’t have the actual statement for Codeforces 103573D (“Подрыв ветряка”) in your prompt, so I can’t safely reconstruct the problem or produce a correct editorial without guessing.

codeforcescompetitive-programming
CF 103573B - Биомаркеры

I can’t reliably write a correct Codeforces-style editorial for “103573B - Биомаркеры” because the problem statement (input/output definition and constraints) is missing from your message.

codeforcescompetitive-programming
CF 103573A - Стать сильнее

I’m missing the actual problem statement for Codeforces 103573A - Стать сильнее, so I can’t responsibly write a correct editorial yet.

codeforcescompetitive-programming
TAOCP 7.2.1.2 Exercise 73

Let $G$ be the Cayley graph whose vertices are the $N$ permutations of the multiset ${s_0\cdot 0,\dots,s_d\cdot d}$ and whose edges correspond to adjacent interchanges $a_{\delta_k}\leftrightarrow a_{...

taocpmathematicsalgorithmsvolume-4math-hard
CF 103575B - Even Tree

Let the alphabet be ${x1 < x2 < cdots < xt}$ with multiplicities $n1,ldots,nt$ and $sum{i=1}^t ni = n$. Algorithm L generates permutations in strict lexicographic order with respect to this ordered alphabet.

codeforcescompetitive-programming
CF 103575E - Draft Laws

We are given a tree with $n$ vertices, and a palette of $k$ colors. Some vertices may already be fixed to a specific color, while others are free.

codeforcescompetitive-programming
CF 103575D - Add and Multiply

We are given two arrays of the same length. We are allowed to increase individual elements of the first array by some nonnegative amounts, and we increase the corresponding elements of the second array by the same chosen nonnegative amounts.

codeforcescompetitive-programming
CF 103575A - Designing a New Logo

We are working with a rectangular grid that needs to be “painted” using two types of cells, black cells that form a structural skeleton and white cells that can be expanded freely from that skeleton.

codeforcescompetitive-programming
CF 103575C - Primle

We are interacting with an unknown secret number that is guaranteed to be prime and has a fixed digit length. The only way to obtain information is by making queries: we output a candidate number, and for each position we receive feedback indicating whether our guess matches…

codeforcescompetitive-programming
CF 103577G - Matematical Transformation

We are given a tree rooted at node $1$, where every node stores a numeric value, initially $0$. Two types of operations are performed online. The first operation asks for the sum of values along the unique simple path between two nodes $u$ and $v$.

codeforcescompetitive-programming
TAOCP 7.2.1.2 Exercise 72

Let the multiset be $\{s_0 \cdot 0,\; s_1 \cdot 1,\; \ldots,\; s_d \cdot d\}, \qquad s_0 + s_1 + \cdots + s_d = n.$ Let $V$ be the set of all distinct permutations of this multiset.

taocpmathematicsalgorithmsvolume-4math-medium
TAOCP 7.2.1.2 Exercise 71

Let the multiset be $\{s_0 \cdot 0,\; s_1 \cdot 1,\; \ldots,\; s_d \cdot d\}, \qquad s_0 + s_1 + \cdots + s_d = n.$ Let $V$ be the set of all distinct permutations of this multiset.

taocpmathematicsalgorithmsvolume-4research
TAOCP 7.2.1.2 Exercise 70

Let $\sigma$ and $\tau$ be the two involutions on permutations of ${1,2,\dots,n}$ given by adjacent transpositions on disjoint parity classes, in the standard TAOCP σ–τ framework, so that every step o...

taocpmathematicsalgorithmsvolume-4math-hard
CF 103577L - Convert to heap

We are given a rooted tree where each vertex already has an integer value. The root is node 1. Alongside the tree, we are given a list of update values. Each update lets us pick any subset of vertices and add that update value to every chosen vertex.

codeforcescompetitive-programming
CF 103577M - Classroom Reordering

We are given an array that encodes a directed structure over n labeled chairs. Each index represents a chair, and each value tells us which chair is directly in front of it.

codeforcescompetitive-programming
CF 103577K - Walking Tiles

We are given two sets of points on an infinite 2D integer grid. One set contains “loose tiles” and the other contains “fixed tiles”.

codeforcescompetitive-programming
CF 103577J - Just enough squares

We are given a simple polygon drawn on top of a rectangular grid of unit squares. Each vertex of the polygon lies on integer coordinates, and the polygon edges are straight segments between consecutive vertices.

codeforcescompetitive-programming
CF 103577I - Impossible problems

We are given a set of $n$ problem setters and $n$ topics. Each ordered pair $(setter, topic)$ may have a cost, meaning how many hours that setter needs to prepare a problem of that topic. Only some of these pairs are available, given as $m$ entries.

codeforcescompetitive-programming
CF 103577H - Hiking trip

Three participants move along a straight line segment from position 0 to position d. Two of them, Eli and Rafa, move independently toward the same destination d with constant speeds, but they start at different positions and have different speeds.

codeforcescompetitive-programming
CF 103577F - Flow of binary matrix

We are maintaining an $n times n$ binary matrix that changes over time, and after every update we must report a single summary value called the flow. The flow is defined as the number of rows that consist entirely of ones plus the number of columns that consist entirely of ones.

codeforcescompetitive-programming
CF 103577E - Molecules

We are given a tree describing an open-chain molecule, meaning there are n atoms connected by n−1 bonds and there are no cycles. The task is to output a permutation of all atoms. For any such permutation, consider a fixed atom u.

codeforcescompetitive-programming
CF 103577C - Corona

Each test case gives a genome string, and we must assign a numerical score that comes from all of its contiguous substrings. For any substring, we look at how strongly its prefix pattern repeats at the end of itself.

codeforcescompetitive-programming
CF 103577A - Artistic Swimming

We are given a directed weighted graph where nodes represent designated points in a swimming pool and edges represent direct swimming routes between them. Each edge has a travel time.

codeforcescompetitive-programming
CF 103577D - Derivative of polynomial

The input is a single string that represents a polynomial written in a compact grammar. Unlike standard algebraic notation, there are no spaces and the structure is encoded using signs, digits, the variable x, and an optional exponent marker b.

codeforcescompetitive-programming
CF 103577B - Blockchain

We are given one or more undirected multigraphs. Each edge connects two vertices and carries a positive integer weight.

codeforcescompetitive-programming
CF 103584E - Truffula Trouble

I’m missing the actual problem statement for Codeforces 103584E - only the template is present. Without the description of the task, inputs, and outputs, I can’t reliably reconstruct the intended algorithm or write a correct editorial.

codeforcescompetitive-programming
TAOCP 7.2.1.2 Exercise 69

Each vertex is a permutation of the multiset ${0,0,0,1,1,1}$, hence each vertex is uniquely represented by a strictly increasing triple $c_3c_2c_1 \quad\text{with}\quad 5 \ge c_3 > c_2 > c_1 \ge 0,$ w...

taocpmathematicsalgorithmsvolume-4hard
CF 103584I - Baobab

The problem statement for Codeforces 103584I - Baobab is missing from your message, so I don’t have the actual rules, inputs, or task definition needed to write a correct editorial.

codeforcescompetitive-programming
CF 103584H - Sling Trees

I cannot produce a correct editorial yet because the actual problem statement for Codeforces 103584H - Sling Trees is not present in your prompt, and it is not accessible from the information provided.

codeforcescompetitive-programming
CF 103584G - Perfect Cacti: Part 1

The problem statement is missing, so there isn’t enough information to reconstruct what needs to be solved. “Perfect Cacti: Part 1” alone doesn’t tell us the input format, the required output, or even the core graph or combinatorial condition the solution is supposed to…

codeforcescompetitive-programming
CF 103584A - New Garden

We are given a nursery with a fixed number of tree slots, and a shop that sells several types of trees. Each type has a limited supply of identical seeds, and every seed of a type produces a tree with a fixed beauty value.

codeforcescompetitive-programming
CF 103584F - Giant Sequoia

I can’t write a correct Codeforces editorial without the actual problem statement. Right now “103584F - Giant Sequoia” is just a title in the prompt, and everything else (input format, task, constraints, operations on the “giant sequoia”, etc.) is missing.

codeforcescompetitive-programming
TAOCP 7.2.1.2 Exercise 68

Each vertex is a permutation of the multiset ${0,0,0,1,1,1}$, hence each vertex is uniquely represented by a strictly increasing triple $c_3c_2c_1 \quad\text{with}\quad 5 \ge c_3 > c_2 > c_1 \ge 0,$ w...

taocpmathematicsalgorithmsvolume-4math-hard
CF 103584B - White Goosefoot

Let $a{n-1}dots a1a0$ be a binary string with $sum{j=0}^{n-1} aj=t$ and define $bj=ajoplus a{j-1}$ for $1le jle n-1$. The energy is $r=sum{j=1}^{n-1} bj.$ Each $bj=1$ exactly when $ajne a{j-1}$, so $r$ equals the number of transitions in the sequence $a0,a1,dots,a{n-1}$.

codeforcescompetitive-programming
CF 103584D - Collecting Syrup

I can’t reliably write a correct editorial for this yet because the full statement of Codeforces 103584D - Collecting Syrup is not actually available in what you provided, and it also isn’t present in a standard accessible form from the problemset snippet I retrieved.

codeforcescompetitive-programming
TAOCP 7.2.1.2 Exercise 67

Each vertex is a permutation of the multiset ${0,0,0,1,1,1}$, hence each vertex is uniquely represented by a strictly increasing triple $c_3c_2c_1 \quad\text{with}\quad 5 \ge c_3 > c_2 > c_1 \ge 0,$ w...

taocpmathematicsalgorithmsvolume-4hard
CF 103584C - Redwoods

The problem statement is missing, so there isn’t enough information to write a correct editorial yet. “Codeforces 103584C - Redwoods” alone doesn’t tell us the actual task (tree structure, queries, DP, geometry, etc.

codeforcescompetitive-programming
CF 104508L - List of Orders

I can’t produce a correct editorial for this as-is because the actual problem content is missing. Right now the statement you provided only shows the title “List of Orders” with empty input/output sections, so there’s no way to know what the algorithmic task is, what…

codeforcescompetitive-programming
TAOCP 7.2.1.2 Exercise 66

Vertices are all permutations of the multiset ${0,0,0,1,1,1}$, equivalently all binary strings $a_5a_4a_3a_2a_1a_0$ with $\sum_{i=0}^5 a_i = 3$.

taocpmathematicsalgorithmsvolume-4medium
CF 104508M - More Japanese Monsters

A set $V subseteq {0,1}^n$ closed under $oplus$ (bitwise addition modulo $2$) is a vector space over $mathbb{F}2$ under the usual operations. The zero vector $0^n$ belongs to $V$, and closure under $oplus$ implies closure under finite XOR-sums.

codeforcescompetitive-programming
CF 104508F - Fake Solution

The problem statement you provided only contains the label “F” without any description of the input, output, or rules.

codeforcescompetitive-programming
TAOCP 7.2.1.2 Exercise 65

Let $q$ be a primitive $m$th root of unity and let N = n_1 + \cdots + n_t.

taocpmathematicsalgorithmsvolume-4math-medium
TAOCP 7.2.1.2 Exercise 64

Let $q$ be a primitive $m$th root of unity and let N = n_1 + \cdots + n_t.

taocpmathematicsalgorithmsvolume-4medium
CF 104508K - Known Problem

Let $C=(c1,c2,c3,c4,c5)$ be an ordered 5-card selection of distinct cards from a standard $52$-card deck, and let $k in {1,2,3,4,5}$ designate the starter card. The object counted is the pair $(C,k)$. Let $Sigma(C,k)$ denote the cribbage score defined by rules (i)-(v).

codeforcescompetitive-programming
CF 104508H - Harmony Coloring

The statement as provided is not sufficient to reconstruct the problem. Right now the input and output sections are empty and the only identifier is “Harmony Coloring”, which is not enough to reliably infer the rules, constraints, or required output behavior.

codeforcescompetitive-programming
TAOCP 7.2.1.2 Exercise 63

Let $q$ be a primitive $m$th root of unity.

taocpmathematicsalgorithmsvolume-4math-medium
TAOCP 7.2.1.2 Exercise 62

Let $q$ be a primitive $m$th root of unity, so $q^m=1$ and $1+q+\cdots+q^{m-1}=0$.

taocpmathematicsalgorithmsvolume-4math-medium
CF 103964C - The Battle of Chibi

The problem is about simulating or evaluating a confrontation scenario over a linear structure of positions, where each position contains a value representing some strength, cost, or contribution to the battle outcome.

codeforcescompetitive-programming
CF 103666F - Маша и матрёшки

We are given a collection of matryoshka dolls, each with a numeric size. A doll can be placed inside another doll only if its size is strictly smaller. Each doll can contain at most one other doll directly, so the structure we build is a chain rather than a branching structure.

codeforcescompetitive-programming
TAOCP 7.2.1.2 Exercise 61

Let $\beta_0,\ldots,\beta_{M-1}$ be a revolving-door listing of all $(s,t)$-combinations of ${0,1,\ldots,s+t-1}$, where $M=\binom{s+t}{t}$, and consecutive terms differ by a single adjacent exchange i...

taocpmathematicsalgorithmsvolume-4medium
CF 103666H - Робот

Represent each domino ${i,j}$, $0 le i le j le 6$, as an undirected edge between vertices $i$ and $j$ in a multigraph $G$ on vertex set ${0,1,dots,6}$, with one loop at each vertex $i$ corresponding to ${i,i}$.

codeforcescompetitive-programming
TAOCP 7.2.1.2 Exercise 59

Let $\beta_0,\ldots,\beta_{M-1}$ be a revolving-door listing of all $(s,t)$-combinations of ${0,1,\ldots,s+t-1}$, where $M=\binom{s+t}{t}$, and consecutive terms differ by a single adjacent exchange i...

taocpmathematicsalgorithmsvolume-4math-medium
CF 103666A - Алёна, помни возраст Вити!

We are given a snapshot from two different birthdays of two brothers who always celebrate on the same day of the year, which means their ages always increase synchronously by exactly one each year. At some past birthday, Vitya was n years old and his brother was m years old.

codeforcescompetitive-programming
CF 103665H - Двоичная последовательность

We are given a binary string $t$, and we are allowed to compare it against a special infinite family of binary strings $sm$. Each $sm$ is fixed: it starts with 0 and alternates every position, so it looks like 0101… up to length $m$.

codeforcescompetitive-programming
TAOCP 7.2.1.2 Exercise 58

Algorithm E generates all permutations by a sequence of adjacent interchanges and returns to the starting permutation, as indicated by its structure involving steps $E2$ and $E5$, and by the cyclic in...

taocpmathematicsalgorithmsvolume-4math-medium
TAOCP 7.2.1.2 Exercise 57

Step E5 performs the single operation a_{j-c_j+s} \leftrightarrow a_{j-q+s}.

taocpmathematicsalgorithmsvolume-4hm-medium
TAOCP 7.2.1.2 Exercise 56

The flaw in the previous solution is that it never connects the modified step $E5'$ to the _actual control structure_ of Algorithm E.

taocpmathematicsalgorithmsvolume-4math-medium
CF 103665K - Совместное счастье

We are given a patient who may suffer from exactly one disease among $k$ candidates. There are $n$ available medical tests. Each test checks a specific disease $di$, takes $ti$ minutes, and consumes $bi$ milliliters of blood.

codeforcescompetitive-programming
CF 103665B - Переводчик

We are given a word that belongs to exactly one of two alien alphabets. One alphabet uses only the letters A and B, while the other uses only the digits 0 and 1.

codeforcescompetitive-programming
TAOCP 7.2.1.2 Exercise 55

Define \gamma_m=\beta_m\alpha_m.

taocpmathematicsalgorithmsvolume-4math-hard
CF 103637H - Hockey championship

We are given a patient who may suffer from exactly one disease among $k$ candidates. There are $n$ available medical tests. Each test checks a specific disease $di$, takes $ti$ minutes, and consumes $bi$ milliliters of blood.

codeforcescompetitive-programming
CF 103637A - Agile permutation

We are given a permutation of the numbers from 1 to n, and the goal is to transform it into the identity permutation where every position i contains value i. Two operations are available. One operation lets us swap any two elements at a fixed cost a.

codeforcescompetitive-programming
CF 103627F - Lag

We are asked to process a collection of weighted geometric updates and then answer queries about how much total weight lies inside axis-aligned prefix rectangles of the form $[1, x] times [1, y]$.

codeforcescompetitive-programming
CF 103627K - Fake Plastic Trees 2

We are given a tree rooted at vertex 1, where each vertex has an integer weight. Along with the tree, we are given two parameters, a lower bound L and an upper bound R, and a target number K.

codeforcescompetitive-programming
TAOCP 7.2.1.2 Exercise 54

Let the prefix operation in step C3 be denoted by a transformation on ordered $k$-tuples.

taocpmathematicsalgorithmsvolume-4medium
TAOCP 7.2.1.2 Exercise 53

Let Algorithm H act on a Sims table ${S_k}_{1 \le k \le n}$ as in Section 7.

taocpmathematicsalgorithmsvolume-4math-hard
TAOCP 7.2.1.2 Exercise 52

Let the Sims table (36) be the standard Sims table for the symmetric group on $n$ symbols, in which the basic generators are the adjacent transpositions acting on positions, so that each entry $\sigma...

taocpmathematicsalgorithmsvolume-4math-medium
TAOCP 7.2.1.2 Exercise 51

The statement is **false in general**.

taocpmathematicsalgorithmsvolume-4math-medium
CF 103627G - Critical Vertex

We are given an undirected graph and we want to evaluate, for each vertex, how “critical” it is under a slightly non-standard notion of connectivity.

codeforcescompetitive-programming
CF 103627A - Points

The problem deals with two collections of points, one set we can think of as set U and another as set V. Each point is not just a single number but a pair of coordinates, written as (ux, uy) for elements in U and (vx, vy) for elements in V.

codeforcescompetitive-programming
CF 103604K - Split

We are given an array that is guaranteed to start in non-increasing order, so values never go up as we move to the right. On this array we must support two kinds of operations. The first operation modifies a single interior position.

codeforcescompetitive-programming
TAOCP 7.2.1.2 Exercise 50

We restart the argument from the actual structure of (13), tracking how each update clause transforms under the duality map, and we verify case by case that the transformed rules are exactly those of...

taocpmathematicsalgorithmsvolume-4math-simple
TAOCP 7.2.1.2 Exercise 49

Consider an additive alphametic in base $10$ of the form \text{SEND} + \text{MORE} = \text{MONEY}, where distinct letters represent distinct digits in ${0,1,\dots,9}$ and leading letters $S$ and $M$ a...

taocpmathematicsalgorithmsvolume-4hard
TAOCP 7.2.1.2 Exercise 48

Algorithm $X$ and Algorithm $L$ both enumerate all $n!$ permutations of $a_1 a_2 \dots a_n$.

taocpmathematicsalgorithmsvolume-4math-medium
CF 103604L - Uranium

I can’t reliably write a correct Codeforces-style editorial for “103604L - Uranium” without the actual problem statement.

codeforcescompetitive-programming
TAOCP 7.2.1.2 Exercise 47

Let $C_t(n)$ denote the lexicographically ordered sequence of all $t$-combinations $c_t \ldots c_1$ of ${0,1,\ldots,n-1}$ in the sense of Algorithm L.

taocpmathematicsalgorithmsvolume-4math-medium
CF 103604I - River

I’m missing the actual problem statement for Codeforces 103604I - River, so I can’t reliably reconstruct the intended solution or write a correct editorial.

codeforcescompetitive-programming
TAOCP 7.2.1.2 Exercise 46

Let endo-order be the order on fixed-length binary strings induced by lexicographic order on their numeric representations, as used throughout Section 7.

taocpmathematicsalgorithmsvolume-4medium
CF 103604J - Shelters

We are given a tree of houses where house 1 is a special node acting as a permanent shelter. Every house initially contains some number of people. The roads between houses are bidirectional, and initially all roads are usable. We process two types of updates.

codeforcescompetitive-programming
CF 103604E - Intervals

I can’t reliably write a correct editorial for this without the actual problem statement. “Codeforces 103604E - Intervals” isn’t a standard public statement I can reconstruct from the title alone, and guessing would very likely produce a completely wrong solution and…

codeforcescompetitive-programming
TAOCP 7.2.1.2 Exercise 45

Let endo-order be the order on fixed-length binary strings induced by lexicographic order on their numeric representations, as used throughout Section 7.

taocpmathematicsalgorithmsvolume-4medium
CF 103604D - Rainy Garden

I can’t produce a correct Codeforces-style editorial yet because the problem statement for “103604D - Rainy Garden” is not actually included in your prompt, and it is not uniquely recoverable from the contest ID alone.

codeforcescompetitive-programming
CF 103604H - Magic Powers

I don’t have the actual statement of Codeforces 103604H - Magic Powers in your prompt, so I can’t reliably reconstruct the problem, constraints, or the intended solution path.

codeforcescompetitive-programming
TAOCP 7.2.1.2 Exercise 44

Let an $(s,t)$-combination be represented by a binary string $a_{n-1}\dots a_0$ with $n=s+t$ and $\sum a_i=t$, as in Section 7.

taocpmathematicsalgorithmsvolume-4medium
CF 103604G - Parenthesis

I’m missing the actual problem statement for Codeforces 103604G - Parenthesis, and I can’t reliably reconstruct it from the ID alone.

codeforcescompetitive-programming