brain

tamnd's digital brain — notes, problems, research

43815 notes

CF 104355F - 渡渡鸟游乐场

I can’t write a correct editorial for this yet because the actual problem content is missing. Right now the statement only shows the title, input/output sections are empty, and there’s no description of what operations, structures, or constraints are involved.

codeforcescompetitive-programming
CF 104355E - 全错

I can’t write a correct editorial for this because the actual problem content is missing. What you provided only includes the title “E 全错” without any description, input/output format, or constraints.

codeforcescompetitive-programming
CF 104355D - 点集扩张

The problem statement is missing from your prompt (it only shows the title “点集扩张” without any description, input, or rules). Without that, I can’t reliably reconstruct the task or produce a correct Codeforces-style editorial.

codeforcescompetitive-programming
CF 104355A - 大水题

The problem statement is intentionally minimal, essentially just labeling the task as a “big easy problem” without specifying any real computation.

codeforcescompetitive-programming
CF 104355B - 原粥率

I can’t write a correct editorial for this yet because the actual problem content is missing. Right now we only have the title “原粥率” and no description, input format, or required output behavior, which makes it impossible to reconstruct the algorithm without guessing.

codeforcescompetitive-programming
CF 104355C - 话剧

I can’t reliably write a correct editorial from that yet because the actual problem content is missing. Right now you’ve only provided the title “话剧”, but there are no constraints, no input/output format, and no description of what needs to be computed.

codeforcescompetitive-programming
CF 104359F - Пазл

We are given two configurations of a very thin grid with two rows and many columns. Each cell contains either a 0 or a 1. In one configuration we start with some arrangement of ones and zeros, and in the other configuration we want to reach a target arrangement.

codeforcescompetitive-programming
CF 104359E - Пират Серёжа

We are given a grid of size $n times m$ that contains each integer from $1$ to $nm$ exactly once. Think of each number as occupying a unique cell in a grid graph where movement is allowed only between edge-adjacent cells. We are allowed to construct a walk on this grid.

codeforcescompetitive-programming
CF 104359D - Шлюзы

We are given a linear system of water tanks arranged in a row. Each tank has a fixed capacity. Initially all tanks are empty, and each tank has a pipe that can be turned on, producing a constant inflow of one unit of water per second into that tank.

codeforcescompetitive-programming
CF 104359A - Вордл наоборот

We are given a secret word S of length n, where all characters are distinct, and a color pattern P describing how another unknown guessed word T was evaluated against S using Wordle rules. The evaluation works position by position. If T[i] equals S[i], the result is green.

codeforcescompetitive-programming
CF 104359B - Палиндромные числа

We are given a decimal number represented as a string of length $n$. Our task is to construct another positive integer of the same length, also with no leading zeros, such that when we add it to the given number digit by digit, the resulting sum forms a palindrome.

codeforcescompetitive-programming
CF 104359C - Помогаем природе

We are given an array representing moisture levels along a line of trees. Each operation modifies a contiguous segment in a very structured way. One operation decreases a prefix by 1, another decreases a suffix by 1, and a third operation increases the entire array by 1.

codeforcescompetitive-programming
CF 104360F - Необычный массив

We are given an array and we focus on each position independently. Fix an index $i$. We look at every contiguous subarray that contains this index. For each such subarray, we sort its elements and locate the value $ai$ inside this sorted list.

codeforcescompetitive-programming
CF 104360E - Игра с картами

We are given a sequence of moves. At the start, Bob holds two integers, one in his left hand and one in his right hand, both equal to zero. At each move i, Alice presents a new number ki. Bob must choose whether to replace the value in his left hand or in his right hand with ki.

codeforcescompetitive-programming
CF 104360D - PriceFixed

We are given several product types, each requiring a fixed number of purchases. Every purchase normally costs 2 units of money. There is a global counter that increases every time we buy any item, regardless of type.

codeforcescompetitive-programming
CF 104360A - Старт олимпиады

There are $n$ participants taking part in an olympiad. Each participant $i$ starts at a fixed time forming an arithmetic progression: the first starts at time $0$, the second at time $x$, the third at $2x$, and so on, so participant $i$ starts at $(i-1)x$.

codeforcescompetitive-programming
CF 104360C - Стабильные параллели

We are given a collection of student skill levels, and we want to split them into several groups called parallel classes. Inside each class, if we sort students by skill, every adjacent pair must differ by at most a fixed value x.

codeforcescompetitive-programming
CF 104360B - Вася и Петя

We are given a string of lowercase English letters. Each query selects a contiguous substring, and we transform that substring using a fixed rule: every character is expanded independently, where a letter at position x in the alphabet is repeated exactly x times.

codeforcescompetitive-programming
CF 104361E - Шахматные баталии

We are working on a rectangular grid of size $2n times 2m$ with a fixed chess coloring: a cell $(i, j)$ is white if $i + j$ is even, otherwise it is black. Only white cells matter for the game.

codeforcescompetitive-programming
CF 104361D - Перевернутые родословные

We are given a structure on $n$ labeled people where each person has either zero or exactly one child. If a person has no child, their outgoing pointer is 0. Otherwise, every person points to exactly one child index in $[1, n]$.

codeforcescompetitive-programming
TAOCP 7.1.4 Exercise 17

A reduced ordered binary decision diagram (BDD) for a Boolean function $f(x_1,\dots,x_n)$ consists of a rooted directed acyclic graph in which each non-sink node $v$ has a variable index $V(v)\in{1,\d...

taocpmathematicsalgorithmsvolume-4hard
CF 104361B - Выбор цветов для букета

We are given a bouquet that must contain exactly n flowers, and there are m flower types. Each type can be used any number of times. The reward model for a type is not constant per flower.

codeforcescompetitive-programming
CF 104361C - Межпланетные электрички

We are working with a cyclic daily timetable split into minutes. A passenger railway service must run forever with a fixed periodic pattern: trains depart exactly every m/2 minutes, and each departure occupies the platform for a fixed interval before it.

codeforcescompetitive-programming
CF 104361A - Подготовка к экзамену

We are asked to construct three integers $a, b, c$, all chosen from a fixed interval $[l, r]$, together with a positive integer $n$, such that a linear expression holds exactly: $$n cdot a + b - c = m.$$ The input gives us the bounds $l$ and $r$, and a target value $m$.

codeforcescompetitive-programming
CF 104363K - Turn-based Game

We are simulating a sequence of battles where each battle consists of fighting a small group of identical monsters. Each monster has a fixed amount of health, and every attack reduces the chosen monster’s health by exactly one.

codeforcescompetitive-programming
CF 104363L - Subxor

We are given an array of integers and a fixed integer $K$. For each query, we look at a subsegment of the array, from index $l$ to $r$, and we want to choose a contiguous subarray inside this segment that maximizes its length under a constraint on XOR.

codeforcescompetitive-programming
CF 104363J - XOR String

We are given a circular string, so substrings are allowed to wrap from the end back to the beginning. Each position in this circle has a lowercase character and an associated integer value.

codeforcescompetitive-programming
CF 104363I - Club

We are given a collection of n clubs, and we must assign each club one of m badge types. Multiple clubs can share the same badge type, but every badge type must appear at least once. After the assignment is fixed, a participant repeatedly visits clubs.

codeforcescompetitive-programming
CF 104363H - KingZ

We are given a fixed 10×10 board where each cell represents a battlefield tile. Some cells are walls and cannot be used. Every other cell may initially contain a number of troops and also belongs to a category such as core, keep, lawn, or neutral territory.

codeforcescompetitive-programming
CF 104363G - Gravity

We are given a set of points in the plane, each representing an asteroid of equal mass. We must split these points into two nonempty groups.

codeforcescompetitive-programming
CF 104363F - Folder

We are given a rooted tree where each node represents a folder. Folder 1 is fixed as the root, and every other folder has exactly one parent. So the structure is a hierarchy of directories.

codeforcescompetitive-programming
CF 104363D - Pandemic

We are asked to count how many valid “distribution plans” Kanade can follow while serving a row of $n$ rooms arranged in a line. The process always moves strictly from left to right, never revisiting rooms.

codeforcescompetitive-programming
CF 104363E - Ethernet

We are simulating a very small randomized process on a fixed set of ports and cables, where each cable ultimately ends up plugged into exactly one port. There are n ports labeled from 1 to n and n cables also labeled from 1 to n.

codeforcescompetitive-programming
CF 104363C - Compass

We are dealing with a system of three rotating components. Each component has a position on a circular scale, and each full rotation brings it back to the starting point after a fixed number of steps. The twist is that we do not directly choose how much each component rotates.

codeforcescompetitive-programming
CF 104363B - Chevonne's Game

We are given a binary string representing a row of pearls, where each pearl is either white or black. The system supports two operations over time. One operation flips the colors of all pearls in a range, turning white into black and black into white.

codeforcescompetitive-programming
CF 104363A - Magic Computer

We are given a process involving a collection of USB disks, where each disk initially holds a unique file. The computer has a very unusual constraint: at any moment, it only interacts with the two most recently inserted disks, and when two disks are inserted together they…

codeforcescompetitive-programming
TAOCP 7.1.4 Exercise 169

Let $f$ be a read-once Boolean function of $22m+1$ variables, represented by a rooted formula tree in which each variable appears exactly once.

taocpmathematicsalgorithmsvolume-4math-research
CF 104366L - Spatial Quantum Energy Theory

We are given a system of atoms, where each atom is defined by a subset of at most 20 possible elementary particle types. Each particle type has a fixed energy value.

codeforcescompetitive-programming
CF 104366M - Easy Problem of Prime

We are given many independent queries. Each query provides a number $n$, and for that value we first imagine all integers from $2$ up to $n$. For each integer $i$, we define a value $f(i)$, where $f(i)$ is the smallest number of prime numbers whose sum equals exactly $i$.

codeforcescompetitive-programming
CF 104366J - Less Time on the Road

We are given a directed graph where every edge has unit cost, and the graph is guaranteed to be strongly connected. Two workers start at vertex 1. A sequence of requests arrives, and each request specifies a vertex that must be visited to perform a repair.

codeforcescompetitive-programming
CF 104366K - The Secret Comparison

Two competitors each have a single integer score. The task is to compare these two numbers and declare who has the higher score, or whether they are equal. The input consists of exactly two integers, representing the scores of the two players.

codeforcescompetitive-programming
CF 104366I - Subsetting and Summing

We are given a collection of 3D vectors. From these vectors we may choose any subset, including the empty set, and sum the chosen vectors component-wise to obtain a single resultant vector.

codeforcescompetitive-programming
CF 104366H - Light the Street

We are placing streetlights along a one-dimensional segment of length $n$. We are allowed to choose up to $k$ positions for these lights.

codeforcescompetitive-programming
CF 104366G - Expected Sum

We are given a long decimal string, interpreted as a sequence of digits placed left to right. Between every adjacent pair of digits, we independently decide whether to insert a plus sign.

codeforcescompetitive-programming
CF 104366E - Triangle Pick

We are given a collection of triangular surfaces in 3D space. Each triangle is a flat solid piece defined by three vertices.

codeforcescompetitive-programming
CF 104366F - MPFT

We are simulating a chat group that changes over time. People either join the group or send messages, and the group has strict rules that can forcibly remove members. The first rule is a capacity constraint. The group can hold at most N people.

codeforcescompetitive-programming
CF 104366D - Concrete Painting

We are given a collection of segments on a number line. From these segments, we consider every possible subset of them. For any chosen subset, we imagine painting all of its segments onto the number line, where overlapping parts are still counted only once.

codeforcescompetitive-programming
CF 104366B - Problem B

The town is a rectangular grid of intersections with roads connecting adjacent intersections in the usual four-direction structure. Vehicles enter from any boundary road endpoint and must eventually leave through some boundary endpoint.

codeforcescompetitive-programming
CF 104366C - Abstract Painting

We are given a collection of axis-aligned line segments on an infinite 2D plane. Each segment is either vertical or horizontal. Two segments are considered connected if they physically intersect at any point, including touching at endpoints.

codeforcescompetitive-programming
CF 104366A - Cask Effect

We are given several wooden boards, each with a fixed length. The “strength” or “capacity” of a cask built from these boards is defined as the length of the shortest board used in it.

codeforcescompetitive-programming
TAOCP 7.1.4 Exercise 168

Let a read-once Boolean function $f(x_1,\dots,x_n)$ be given, and let $B(f)$ denote the number of BDD nodes including sinks, as defined in Section 7.

taocpmathematicsalgorithmsvolume-4hm-project
CF 104369M - Computational Geometry

We are given a convex polygon described by its vertices in counterclockwise order. The task is to choose two distinct vertices and draw a chord between them, but not every pair is allowed: the chord must actually split the polygon into two regions, and both resulting pieces…

codeforcescompetitive-programming
CF 104369L - Classic Problem

We are given a very large graph on vertices labeled from 1 to n, where every pair of vertices is connected by an edge, so the graph is complete.

codeforcescompetitive-programming
CF 104369J - X Equals Y

We are asked to choose two bases, one for $x$ and one for $y$, so that when both numbers are written in their respective bases, the resulting digit sequences are identical when read from least significant digit to most significant digit.

codeforcescompetitive-programming
CF 104369K - Peg Solitaire

We are given a very small chessboard, at most six rows by six columns, with up to six pegs placed on distinct cells.

codeforcescompetitive-programming
CF 104369I - Path Planning

We are given a grid where every cell contains a distinct integer from the range $[0, n cdot m - 1]$. We start at the top-left cell and can only move right or down until reaching the bottom-right cell.

codeforcescompetitive-programming
CF 104369H - Canvas

We are given a sequence of length $n$, initially filled with zeros. We also have $m$ operations. Each operation selects two positions $li < ri$ and assigns values $xi$ and $yi$ to those positions, overwriting whatever is currently there.

codeforcescompetitive-programming
CF 104369G - Swapping Operation

We are given an array of non-negative integers. For any split point $k$, we can divide the array into a prefix and a suffix. For that split, we compute the bitwise AND of the prefix and the bitwise AND of the suffix, then sum the two results.

codeforcescompetitive-programming
CF 104369F - Traveling in Cells

We are given a line of cells, each cell having a fixed position, a color, and a value associated with a single removable ball. The structure changes over time because both colors and values of individual cells can be updated.

codeforcescompetitive-programming
CF 104369E - New but Nostalgic Problem

We are given a collection of strings and we are allowed to pick exactly k of them. Once the subset is fixed, we look at every pair inside it and compute their longest common prefix. Among all these pairwise LCP values, we take the lexicographically largest one.

codeforcescompetitive-programming
CF 104369D - New Houses

We are given a line of houses indexed from 1 to m, and we must place n people into distinct houses. Two people are considered neighbors only when they occupy adjacent house indices.

codeforcescompetitive-programming
CF 104369C - Trading

We are given a street with several shops, each shop offering the same type of product at a fixed price. In each shop, the price is symmetric: if you buy or sell one unit there, the cost or revenue is exactly the same value.

codeforcescompetitive-programming
CF 104369B - Base Station Construction

We are given a line of positions from 1 to n, where each position has a cost for building a base station. We are allowed to choose any subset of positions to build base stations, paying the sum of their costs.

codeforcescompetitive-programming
CF 104369A - Programming Contest

We are looking at a yearly event that starts at some initial year y1. From that year onward, the contest is intended to happen once every year. However, there is a small list of exceptional years where the contest did not take place.

codeforcescompetitive-programming
TAOCP 7.1.4 Exercise 167

We restart from the structural characterization of read-once Boolean functions and the defining property of reduced ordered binary decision diagrams.

taocpmathematicsalgorithmsvolume-4medium
CF 104373K - Link-Cut Tree

We are given an undirected graph where each edge has a very special weight: the i-th edge in input order has weight $2^i$.

codeforcescompetitive-programming
CF 104373J - Colorful Tree

We are building a tree incrementally. The structure starts with a single node, and each operation either attaches a new node to an existing node with a weighted edge or changes the color of an existing node.

codeforcescompetitive-programming
CF 104373I - LCS Spanning Tree

We are given a collection of strings, each representing a vertex in a complete undirected graph. Every pair of vertices is connected, and the weight of an edge is defined by how similar the two strings are: specifically, it is the length of the longest substring that appears…

codeforcescompetitive-programming
CF 104373H - Permutation on Tree

We are given a rooted tree with $n$ labeled vertices. We consider all permutations of the vertices, but we only keep those permutations that respect the tree’s ancestor structure: whenever a node $u$ is an ancestor of node $v$, then $u$ must appear earlier in the permutation.

codeforcescompetitive-programming
CF 104373G - Cyclic Buffer

We are given a circular array that contains a permutation of the numbers from 1 to n. There is a fixed window of size k that represents the “visible” part of the buffer, specifically the first k positions at any moment.

codeforcescompetitive-programming
CF 104373D - Shortest Path Fast Algorithm

The algorithm in the statement is a modified shortest path routine that behaves like SPFA but uses a priority queue instead of a FIFO queue. Every time a vertex is extracted from the queue, it relaxes its outgoing edges.

codeforcescompetitive-programming
CF 104373F - Sandpile on Clique

We are given a complete graph with $n$ vertices, where every vertex is connected to every other vertex. Each vertex starts with some number of chips.

codeforcescompetitive-programming
CF 104373E - Pass the Ball!

We are given a directed mapping over n children. Each child always passes whatever ball they currently hold to exactly one fixed destination child p[i].

codeforcescompetitive-programming
CF 104373B - The Matching System

We are given a length $n$, and we must construct two binary strings of that length: a pattern string and a target string. The pattern is not purely binary; it also contains two special symbols that define a recursive matching process against the binary string.

codeforcescompetitive-programming
CF 104373A - So I'll Max Out My Constructive Algorithm Skills

We are given a square grid of size $n times n$, where every cell contains a distinct integer from 1 to $n^2$. You can think of this grid as a weighted graph laid out on a lattice: each cell is a node, and edges exist between orthogonally adjacent cells.

codeforcescompetitive-programming
CF 104373C - Laser Trap

We are given a set of points in the plane. Each point acts as a laser generator, and every pair of generators is connected by a straight laser segment. So for n points, the system forms a complete geometric graph where every edge is a segment between two given coordinates.

codeforcescompetitive-programming
TAOCP 7.1.4 Exercise 166

We restart the argument from the formal semantics of ordered binary decision diagrams and build canonicity directly from evaluation, without assuming any uniqueness of a construction procedure.

taocpmathematicsalgorithmsvolume-4math-hard
CF 104375K - Kingdom Power C.

The game can be modeled as a directed graph where each level is a node and each prerequisite relation is a directed edge. If there is an edge from level u to level v, then finishing u unlocks v, so v becomes playable after u is completed.

codeforcescompetitive-programming
CF 104375J - Jumping Reaction

We are given an array of integers where each value represents a “jumping energy” of a substance. When two substances with energies $a$ and $b$ are mixed, they contribute an energy of $ab$.

codeforcescompetitive-programming
CF 104375I - Improving Chewing Candy

We are given a circular arrangement of candy blocks, where each block has a flavor represented by a lowercase letter. The circularity means the first and last positions are adjacent, so any segment we take can wrap around the end of the string.

codeforcescompetitive-programming
CF 104375H - Hell or paradise?

We are given a collection of words and a long string written on a monster’s body. The task is to determine how many ways we can cut this long string into consecutive pieces so that each piece exactly matches one of the given words.

codeforcescompetitive-programming
CF 104375F - Finding the Best Guess

We are given a tree where every node carries a positive weight. A process runs for exactly $n$ rounds. In each round, one remaining node is chosen uniformly at random.

codeforcescompetitive-programming
CF 104375G - Growing game

We are given a pile of chips and two players who alternate turns, starting with Jane. On each turn, the player removes between 1 and a bounded number of chips, where the bound grows with the turn index.

codeforcescompetitive-programming
CF 104375E - Employees Bonus

We are given a company hierarchy that forms a rooted tree. Each employee corresponds to a node, and every node has a subtree consisting of all employees they supervise directly or indirectly, including themselves. The company processes a sequence of bonus events.

codeforcescompetitive-programming
CF 104375D - Dynamic Collection

We maintain a multiset of integers with two operations: inserting or modifying the structure in a specific ordered way, and answering how many elements lie inside a numeric interval. The collection is not just a static bag.

codeforcescompetitive-programming
TAOCP 7.1.4 Exercise 165

We restart the argument from the ROBDD construction rules and avoid manipulating the coupled recurrences in an unjustified way.

taocpmathematicsalgorithmsvolume-4math-medium
CF 104375C - Counting Stars

We are given a set of points in the plane, each representing a star. We want to count how many valid “spoke constellations” can be formed. A configuration is defined by choosing one star as a center and then selecting other stars around it in a very structured way.

codeforcescompetitive-programming
CF 104375A - Aliases

Each person’s full name is given as a sequence of words. From that name, a compact identifier called a NAME is constructed by taking the first letter of every word and concatenating these letters in order. So a name like “jose osorio jimenez orozco” becomes “jojo”.

codeforcescompetitive-programming
CF 104375B - Bucket storing

We are given a situation where coffee is first packed into several identical small containers. Each small container always holds exactly $K$ units of coffee, and there are $N$ such containers. So the total amount of coffee is simply $N times K$.

codeforcescompetitive-programming
CF 104377O - 捕鱼达人!

We are given a set of points in the plane, each point carrying a positive or negative value. A fisherman stands at the origin and can deploy a net in a very flexible way.

codeforcescompetitive-programming
CF 104377N - 解密

We are given a sequence of 2×2 matrices that play the role of convolution kernels, and another implicit sequence of 2×2 matrices that acts as the inverse under the same convolution rule. More concretely, each input test case gives a list of matrices $A0, A1, dots, A{n-1}$.

codeforcescompetitive-programming
CF 104377M - 数字模拟

We are given a fixed-height ASCII picture consisting of 5 rows and 18 columns. Each column contains either a star character or a dot-like blank representation, and together these characters encode three digits written side by side.

codeforcescompetitive-programming
CF 104377L - MEX问题

We are given a sequence of integers, and we are asked to count how many of its subsequences satisfy a structural constraint that depends on the MEX of every prefix of that subsequence.

codeforcescompetitive-programming
CF 104377K - 字符串游戏

We are given two players, each owning a collection of string “tiles”. The first player has $n$ distinct tile types, and each type can be used an unlimited number of times. The second player has $m$ tile types, also with unlimited supply.

codeforcescompetitive-programming
CF 104377J - BLG冲冲冲!

We are given a full matrix describing the outcome probabilities between every pair of 8 teams. For any two teams $i$ and $j$, the entry $a{i,j}$ gives the probability that $i$ defeats $j$ in a single match, with the complementary probability $a{j,i}$ ensuring that exactly one…

codeforcescompetitive-programming
CF 104377H - 账号已注销,我想账号已注销了

We are given a sequence of $n$ pillars, each with a height. From this sequence we are allowed to choose a non-empty subsequence while preserving the original order. After selecting, we only keep the chosen pillars.

codeforcescompetitive-programming
CF 104377I - 这真的是签到题

We are given a list of integers and asked to select the largest value in that list that satisfies a specific structural property: every prime factor of that value must also appear somewhere in the list.

codeforcescompetitive-programming
TAOCP 7.1.4 Exercise 164

A Boolean function $f(x_1,\dots,x_n)$ is **read-once** if it can be expressed by a formula in which each variable $x_i$ appears exactly once.

taocpmathematicsalgorithmsvolume-4math-hard
CF 104377G - 我的车呢?

We are standing in a 2D plane and there is a hidden point representing a car. We are given one crucial parameter, a radius r, and we can interactively move a point anywhere in the plane and receive a binary answer: whether our current position is within distance r of the…

codeforcescompetitive-programming
CF 104377F - 珂朵莉树

We start with an array of length $n$. The array is repeatedly modified by choosing a random interval $[l, r]$ uniformly among all $frac{n(n+1)}{2}$ possible subsegments, and assigning all elements in that interval a new value that has never been used before.

codeforcescompetitive-programming