brain

tamnd's digital brain — notes, problems, research

41230 notes

CF 104182A - Universal Paperclips

The process in this problem evolves over time in discrete seconds. During a single full cycle of length n, the system behaves consistently: you perform some number of upgrades, you execute some number of clicks, and those clicks generate a certain number of paperclips.

codeforcescompetitive-programming
CF 104195D - Рейд на транспортер

We are given a set of participants, each described by two numbers: a strength value and a riding speed. We want to choose some of them and arrange them in a line so that strength never decreases from front to back, and speeds also never decrease, while also ensuring that…

codeforcescompetitive-programming
CF 104195C - Connection with Eywa

We are given a circular string of length $n$, and from it we define $n$ “individuals” by taking every cyclic rotation of this string. So the $i$-th individual is simply the original string rotated so that position $i$ becomes the first character.

codeforcescompetitive-programming
TAOCP 7.1.4 Exercise 256

Let $x \in \mathbb{N}$ with binary expansion x = 2^{e_1} + \cdots + 2^{e_t}, \quad e_1 > \cdots > e_t \ge 0.

taocpmathematicsalgorithmsvolume-4math-hard
CF 104195A - План защиты

We are given a sequence of incoming attacks, each with a strength value. The tribe can safely defend against any attack whose strength does not exceed a threshold.

codeforcescompetitive-programming
CF 104195B - Паякан в беде

I can’t write a correct editorial without the actual problem statement. “Codeforces 104195B - Паякан в беде” isn’t enough on its own, and I don’t have the task details (input format, constraints, or what needs to be computed).

codeforcescompetitive-programming
CF 104196M - Tomb Hater

We are given a rectangular grid of characters, and a list of valid words over the same alphabet. A path starts on any cell in the top row and must end on any cell in the bottom row. Each move goes one step to the South, West, or East, and stepping outside the grid is forbidden.

codeforcescompetitive-programming
TAOCP 7.1.4 Exercise 255

A multifamily $f$ assigns to each set $\alpha$ a multiplicity $m_f(\alpha) \in \mathbb{N}$.

taocpmathematicsalgorithmsvolume-4medium
TAOCP 7.1.4 Exercise 254

Let the Shannon decompositions from (52) be written in the standard form for monotone functions, f = (\bar x_1 \wedge f_l)\ \vee\ (x_1 \wedge f_h), \qquad g = (\bar x_1 \wedge g_l)\ \vee\ (x_1 \wedge...

taocpmathematicsalgorithmsvolume-4math-medium
CF 104196L - Statues

We are given a small grid representing a park. Each cell is either empty water, marked by −1, or contains a statue with a unique positive height. All statues are distinct, so we can think of them as having a strict global order from smallest to largest.

codeforcescompetitive-programming
TAOCP 7.1.4 Exercise 253

Let $f(x_1,\ldots,x_n) = (\bar{x}_1 \wedge f_0) \vee (x_1 \wedge f_1)$, where $f_0, f_1$ are Boolean functions of $x_2,\ldots,x_n$.

taocpmathematicsalgorithmsvolume-4math-hard
CF 104196K - Stable Table

We are given a rectangular grid made of unit squares, where each cell belongs to exactly one labeled piece. A single piece is a connected set of cells (connected by shared edges), and different pieces can be interwoven, even containing holes formed by other pieces.

codeforcescompetitive-programming
CF 104196I - Pinned Files

We are given a list of files, each file having a unique label from 1 to n. At any moment, the editor maintains an ordering of these files, but this ordering is split into two contiguous parts.

codeforcescompetitive-programming
CF 104196F - Growing Some Oobleck

We are given a set of circles in the plane. Each circle starts with a fixed center, an initial radius, and a linear growth speed. As time increases, every circle expands outward, so its radius increases linearly.

codeforcescompetitive-programming
CF 104196D - Downsizing

We are given a circle centered at a fixed point $O$ with radius $r$, and a convex polygon that lies entirely outside the interior of this circle.

codeforcescompetitive-programming
CF 104196E - Gambling Game

We are given a random ordering of the numbers from 1 to m. Think of it as shuffling m distinct tokens and revealing them one by one. Alongside this, we are given a “card” made of n disjoint pairs of numbers.

codeforcescompetitive-programming
TAOCP 7.1.4 Exercise 252

Let $f(x_1,\dots,x_n)$ be a monotone Boolean function.

taocpmathematicsalgorithmsvolume-4math-hard
CF 104196A - 1s For All

The task defines a way to “build” an integer using only the digit one, combined with three operations: addition, multiplication, and digit concatenation.

codeforcescompetitive-programming
CF 104196B - Abridged Reading

We are given a collection of chapters where each chapter has a page cost. There are directed dependency relations of the form “chapter a must be read before chapter b”, and each chapter can depend on at most one earlier chapter.

codeforcescompetitive-programming
CF 104196C - Ball of Whacks

The object in this problem is a fixed 30-piece polyhedron where each piece has a well-defined position in a global structure.

codeforcescompetitive-programming
TAOCP 7.1.4 Exercise 251

Let $f(x_1,\dots,x_n)$ be a monotone Boolean function.

taocpmathematicsalgorithmsvolume-4math-research
CF 104197K - King of Swapping

We are given a directed graph on $n$ vertices. Each vertex represents a position containing a number, and the graph encodes allowed moves of a distinguished element (the “king”) or, equivalently, allowed swaps between positions. A move is only possible along directed edges.

codeforcescompetitive-programming
CF 104197L - Least Annoying Constructive Problem

We are given an odd number of vertices or an even number with a small adjustment, and we must explicitly construct a structured list of edges between labeled nodes.

codeforcescompetitive-programming
CF 104197I - Increasing Grid

We are given an $n times m$ grid where some cells are already fixed to be either 0 or 1. Our task is to count how many full completions of the grid exist such that the final matrix is non-decreasing along both rows and columns, and all pre-filled constraints are satisfied.

codeforcescompetitive-programming
CF 104197H - Help Me to Get This Published

We are working with a complete graph whose edges are colored, with the restriction that no triangle uses three distinct colors. This restriction is the classical Gallai property and it forces a strong hierarchical structure on how colors can appear across the graph.

codeforcescompetitive-programming
TAOCP 7.1.4 Exercise 250

A monotone Boolean function $f(x_1,\dots,x_5)$ is uniquely represented by its set of minimal true points, an antichain $A \subseteq 2^{[5]}$, and conversely every antichain determines such a function...

taocpmathematicsalgorithmsvolume-4hard
CF 104197G - Graph Problem With Small $n$

We are given a graph with vertices numbered from 0 to n − 1, where n is small enough that we can consider subsets of vertices explicitly. The graph is undirected, and the core task revolves around reasoning about Hamiltonian paths that are constrained to subsets of vertices.

codeforcescompetitive-programming
CF 104197F - F*** 3-Colorable Graphs

We are given a connected undirected graph. The vertices are already conceptually split into two groups by index, but that split is only used as a starting coloring trick: vertices in the first group can be colored differently from the second group so that the original graph is…

codeforcescompetitive-programming
CF 104197D - Distance Parities

We are given a complete description of pairwise distances between nodes in a hypothetical graph, but only the parity of those distances matters.

codeforcescompetitive-programming
CF 104197E - Excellent XOR Problem

We are given an array of integers, and the task is to decide whether it can be split into multiple contiguous parts under constraints defined by XOR values of these parts.

codeforcescompetitive-programming
CF 104197B - Binary Arrays and Sliding Sums

We are working with binary arrays of length $n$, where each element is either 0 or 1. From any such array $a$, a derived array $b$ is defined through sliding sums over a fixed window size $k$.

codeforcescompetitive-programming
CF 104197A - Adjacent Product Sum

We are given a list of numbers and we want to place them around a circle. Once placed, every element contributes to the total score through the product with its two neighbors on the circle.

codeforcescompetitive-programming
TAOCP 7.1.4 Exercise 25

Algorithm C in this section evaluates a BDD bottom-up by assigning to each node $v$ a value depending only on its LO and HI successors, with sink nodes providing the base cases and each internal node...

taocpmathematicsalgorithmsvolume-4math-medium
CF 104199J - Кошачий ужин

We are given a line of cats, each with a fixed “happiness contribution” if it eats from its personal bowl. There is also one shared bowl that any number of cats can use. If a cat uses its own bowl, it contributes its value, otherwise it contributes nothing.

codeforcescompetitive-programming
CF 104199D - Демонтаж

We are given a row of buildings, each with a fixed height. You start from the ground outside the buildings, and your goal is to retrieve an item located on the roof of a specific building indexed by m.

codeforcescompetitive-programming
CF 104199B - Расстановка мебели

We are given a hotel with several rooms, each room having a required number of chairs in an ideal plan. In reality, the hotel has a total of $N$ chairs that must be distributed across $K$ rooms.

codeforcescompetitive-programming
CF 104199C - Безлюдный отель

We are given a word written as a sequence of lowercase Latin letters. A token starts on the first character and moves according to a deterministic rule that depends entirely on how many times the current character appears in the word.

codeforcescompetitive-programming
CF 104199A - Лифт

We start at floor 0 and want to reach a target floor D. At every move, the elevator allows exactly two possible actions: go up by 3 floors or go down by 2 floors. Each action counts as one button press.

codeforcescompetitive-programming
TAOCP 7.1.4 Exercise 249

Let $f(x_1,\dots,x_n)$ be a Boolean function with truth table $\tau$ and BDD $T(f)$.

taocpmathematicsalgorithmsvolume-4hm-hard
CF 104207K - Knightmare

We are watching a knight moving on an infinite chessboard. It starts from a single square, and every time it jumps, it moves according to the usual chess knight rules.

codeforcescompetitive-programming
CF 104207I - Inkopolis

We are given a connected undirected graph with exactly one cycle, meaning the number of edges equals the number of vertices. Each edge has a color.

codeforcescompetitive-programming
CF 104207H - Equidistance

We are given several points in an N-dimensional Euclidean space. The key condition is that every pair of given points is exactly one unit apart, so these points already form a perfectly regular geometric structure where all mutual distances are identical.

codeforcescompetitive-programming
CF 104207J - Subway Chasing

We are given a linear subway line with stations numbered from 1 to N. Between every pair of adjacent stations i and i+1 there is an unknown travel time ti, and these values are strictly positive integers bounded above by 2×10^9.

codeforcescompetitive-programming
CF 104207F - Fair Lottery

We are given several groups of people. Each group has a fixed size, and if a group is chosen in a lottery outcome then all its members win together. In any single outcome, the total number of winners across all chosen groups is limited by an upper bound $M$.

codeforcescompetitive-programming
CF 104207G - Alice's Stamps

We are given a line of positions from 1 to N, where each position represents a distinct stamp type. Instead of buying stamps individually, Alice can only purchase bundles, and each bundle contributes all stamp types in a contiguous interval [L, R].

codeforcescompetitive-programming
CF 104207B - Same Digit

We are given a single digit $D$ and a target integer $N$. Using only copies of the digit $D$, we are allowed to build arithmetic expressions using concatenation and standard operations like addition, subtraction, multiplication, division, factorial, negation, and a few unary…

codeforcescompetitive-programming
CF 104207D - Mr. Panda and Circles

We are working on a line segment that has integer positions from 0 to $M-1$. At each integer coordinate we may place at most one circle center, and we must place all $N$ circles.

codeforcescompetitive-programming
CF 104207E - Evil Forest

We are asked to size production for a sequence of painting competitions. Each competition has a known number of participants, and every participant consumes exactly one sketchpad.

codeforcescompetitive-programming
CF 104207C - Rich Game

Each test case describes a repeated interaction where a player tries to maximize how many badminton sets he can win, starting with no money. In each point of a match, he can choose whether to intentionally win or lose that point.

codeforcescompetitive-programming
TAOCP 7.1.4 Exercise 248

A Boolean function is sweet when every subtable arising from any prefix assignment is a bead.

taocpmathematicsalgorithmsvolume-4math-medium
CF 104207A - Dogs and Cages

We are given a system with the same number of dogs and cages, both labeled from 0 to N − 1. Each dog independently chooses a cage uniformly at random, and each cage can hold at most one dog, which means the final configuration is a random permutation of the dogs over the cages.

codeforcescompetitive-programming
CF 104217H - Sled Ordering

We are building ordered sequences of length $N$, where each position is filled with one of two indistinguishable types: spotted or brown. Because cows of the same type are identical, a valid configuration is fully described by a binary string of length $N$.

codeforcescompetitive-programming
CF 104217F - The Austin Longhorn Race

We are given a set of checkpoints scattered in a 2D plane. Each checkpoint appears only at a specific time, and if we happen to be exactly at its coordinates at that exact time, we can collect some amount of reward.

codeforcescompetitive-programming
CF 104217G - Journey to Nome

Let the given BDD for $f(x1,dots,xn)$ be a rooted directed acyclic graph whose branch nodes are labeled by variables $V(u)in{1,dots,n}$ and whose sink nodes are $bot,top$, with orderedness ensuring that along every directed path the labels strictly increase.

codeforcescompetitive-programming
CF 104217E - Snowy Hill

We are given an array representing snow heights along a straight hill. The array is monotonic non-decreasing, meaning as we move from index 0 to index N−1, values never decrease.

codeforcescompetitive-programming
CF 104217D - Outfit Ordeal

Connection interrupted. Waiting for the complete answer

codeforcescompetitive-programming
CF 104217C - Sled Circle

We are dealing with a circular track of n evenly spaced positions, labeled from 0 to n-1. Each dog starts at a unique position i, and every dog moves clockwise at a constant speed vi, meaning that after t time steps, dog i will be located at position (i + t · vi) mod n.

codeforcescompetitive-programming
CF 104217A - Swapped Signs

We are given two uppercase strings, one representing the current word displayed on a board and another representing the word we want to replace it with.

codeforcescompetitive-programming
CF 104217B - Max Difference

We are given a single integer $n$, and we are asked to look at all permutations of the sequence $(1, 2, 3, dots, n)$. Each permutation is interpreted as a number formed by concatenating its elements in order.

codeforcescompetitive-programming
TAOCP 7.1.4 Exercise 247

A truth table of order $n$ is a binary string of length $2^n$.

taocpmathematicsalgorithmsvolume-4math-hard
CF 104218J - March March

We are given a directed graph on $n le 20$ labeled cities, where some one-way roads already exist. The intended goal is to ensure that there is a valid “March March route” that visits cities in order from 1 through $n$, meaning that for every consecutive pair $i to i+1$, we…

codeforcescompetitive-programming
CF 104218I - Balto's Training

We are given a directed structure over $N$ villages. From every village there are exactly two outgoing roads: one labeled left and one labeled right, each pointing to some (possibly the same or different) village.

codeforcescompetitive-programming
CF 104218G - Journey to Nome

We are given a fixed number $M$, and we are interested only in positive integers that share no prime factor with $M$. In other words, we filter the natural numbers and keep only those that are coprime to $M$, then index this filtered sequence starting from 1.

codeforcescompetitive-programming
CF 104218E - Snowy Hill

We are given an array representing snow heights along a straight hill. The values are non-negative and the sequence is monotonic non-decreasing from left to right. Each query asks for a contiguous segment whose elements sum exactly to a given value $K$.

codeforcescompetitive-programming
CF 104218D - Outfit Ordeal

We are simulating a stack-like wardrobe where clothing items are inserted, removed from the top, and occasionally removed from the middle by name. Each operation modifies or queries this pile. There are three operations.

codeforcescompetitive-programming
CF 104221B - Динислам и столовая

We are given a line of students who must eventually “clear” their dishes, and each student contributes some amount of work measured in seconds. The initial situation contains a queue of $n$ existing students.

codeforcescompetitive-programming
CF 104221E - Чайный магазин

We are given several possible positions for a shop along a straight line and a set of customers, each living at a fixed point and having a personal tolerance threshold.

codeforcescompetitive-programming
CF 104221D - Карим и дороги

We are given an undirected simple graph with $n$ intersections and $m$ roads. Each road connects two distinct intersections, and between any pair of intersections there is at most one road.

codeforcescompetitive-programming
CF 104221C - Кузя и день рождения

Kuzya is preparing a birthday party, but the number of guests he can invite depends entirely on how a cake is sliced at an unknown bakery. There are several bakeries in his city, and each bakery always cuts a cake into a fixed number of slices.

codeforcescompetitive-programming
CF 104221A - Сафия и подсчет карандашей

Something went wrong. If this issue persists please contact us through our help center at help.openai.com.

codeforcescompetitive-programming
TAOCP 7.1.4 Exercise 246

Let $G=(V,E)$ be a graph, and let $f$ be a monotone Boolean function on $V$ expressed in family algebra as in Section 7.

taocpmathematicsalgorithmsvolume-4math-medium
CF 104229D - Tourists

We are given a country whose road network forms a tree. Each city is a node, and every pair of cities is connected by exactly one simple path.

codeforcescompetitive-programming
CF 104229B - Lego Wall

We are building a rectangular structure of width $w$ and height $h$ using two types of pieces. One piece is a single unit cube that occupies exactly one cell. The other is a domino-shaped piece of size $2 times 1$, placed horizontally, covering two adjacent cells in the same row.

codeforcescompetitive-programming
CF 104229C - SocialEngineering

We are given a connected undirected graph where vertices represent people and edges represent friendships. Two players take turns moving along edges, effectively walking through the graph, but with a strict rule that each edge can be used at most once throughout the entire play.

codeforcescompetitive-programming
CF 104230D - Chika Wants to Cheat

We are designing a system that assigns a unique identifier to each number using a pattern drawn on a very small geometric canvas, a 2 by 2 square with integer lattice points.

codeforcescompetitive-programming
CF 104230B - Superpiece

We are working on an infinite chessboard where each query gives a start square and a target square, together with a set of chess pieces that are allowed to be used. A move means choosing one of the allowed pieces and applying one legal move of that piece from the current square.

codeforcescompetitive-programming
CF 104234M - Siteswap

We are given a sequence that describes a repeating juggling pattern over discrete beats. On each beat, either a throw happens with a specified delay, or nothing happens.

codeforcescompetitive-programming
CF 104234L - Directed Vertex Cacti

We are asked to count how many directed graphs can be formed on n labeled vertices under two structural restrictions, together with a global edge count constraint.

codeforcescompetitive-programming
CF 104234K - Determinant, or...?

We are given an array of length $2^n$, and from it we construct a $2^n times 2^n$ matrix. The rows and columns are indexed from $0$ to $2^n - 1$, and the entry at position $(i, j)$ is defined as $a{i , So each matrix entry does not depend on two independent values of the array…

codeforcescompetitive-programming
TAOCP 7.1.4 Exercise 245

Let $f:\{0,1\}^n\to\{0,1\}$ be monotone.

taocpmathematicsalgorithmsvolume-4math-medium
CF 104234J - Persian Casino

We are simulating a constrained gambling process that behaves less like independent betting and more like a controlled state machine with limited “time travel” resets. Prince starts with a single coin and must go through exactly n betting rounds.

codeforcescompetitive-programming
CF 104234I - DAG Generation

We are looking at a randomized procedure that constructs a directed acyclic graph by processing vertices one by one. At any moment there is a set of already inserted vertices, and a set of remaining vertices.

codeforcescompetitive-programming
CF 104234G - Palindromic Differences

We are given an array of numbers, and we are allowed to reorder it arbitrarily. For each chosen ordering, we build a second array consisting of consecutive differences between adjacent elements.

codeforcescompetitive-programming
CF 104234H - Graph Isomorphism

We are given an undirected simple graph on $n$ vertices. From this graph, we conceptually generate all graphs that can be obtained by relabeling vertices in every possible way. Two relabelings that produce different edge sets count as different graphs.

codeforcescompetitive-programming
CF 104234F - Palindromic Polynomial

We are given several independent test cases. In each one, a hidden polynomial is known to have a symmetric coefficient pattern, meaning the coefficient list reads the same from left to right and from right to left.

codeforcescompetitive-programming
CF 104234E - Garbage Disposal

We are given a continuous block of integers from L to R. Think of these numbers as both “positions” and “items” at the same time. For every number i in this segment, we must assign it a distinct number yᵢ from the same segment, forming a permutation of the interval.

codeforcescompetitive-programming
CF 104234D - Triterminant

We are given a binary sequence where each element is either +1 or −1. From this sequence we build, for every prefix length k, a determinant of a special k by k matrix.

codeforcescompetitive-programming
CF 104234B - Super Meat Bros

We are building two independent story sequences, one for Meatio and one for Meatigi. Each sequence is formed by concatenating story arcs.

codeforcescompetitive-programming
CF 104234C - Testing Subjects Usually Die

We are repeatedly trying to identify a hidden number between 1 and n. The hidden number is not chosen uniformly: each value i has a given weight pi, and the actual probability of being the correct answer is proportional to these weights.

codeforcescompetitive-programming
CF 104234A - Square Sum

We are given a modulus $m$, and then a list of values $z1, z2, dots, zn$. For each query value $zi$, we want to count how many ordered pairs $(x, y)$ with $0 le x, y < m$ satisfy the congruence $$x^2 + y^2 equiv zi pmod m.

codeforcescompetitive-programming
CF 104235J - Счастливая конфигурация

We are given an array length $n$ and a prime number $k$ such that $n$ is divisible by $k$. The indices $1..n$ form a permutation $P$, and we are asked to construct such a permutation. The constraint introduces a second hidden object: another permutation $B$ of $1..

codeforcescompetitive-programming
TAOCP 7.1.4 Exercise 244

Let the edges of $P_3$ be $e_1$ and $e_2$, where $e_1$ joins vertices $1$ and $2$, and $e_2$ joins vertices $2$ and $3$.

taocpmathematicsalgorithmsvolume-4medium
CF 104235I - Отгадай два числа

We are interacting with a hidden pair of integers $A$ and $B$, both in the range from $0$ to $10^9$. We do not see them directly. Instead, we can send a query value $X$, and the system returns the value $(A oplus X) + B$, where $oplus$ is bitwise XOR.

codeforcescompetitive-programming
TAOCP 7.1.4 Exercise 243

Let $\mathcal{f}$ be a family of sets.

taocpmathematicsalgorithmsvolume-4math-medium
CF 104235H - Красно-синие маршруты

We are given a directed graph where every vertex has exactly two outgoing edges: one red edge and one blue edge. From any starting vertex, a move consists of repeating a fixed pattern of edge traversals, and we must determine where we end up after applying that pattern many…

codeforcescompetitive-programming
CF 104235E - Запросы на массиве

We are maintaining a mutable array where two operations repeat over time. One operation asks, for a fixed position i, to look strictly to the right and find the smallest value that is strictly greater than a[i]. The other operation flips the sign of a single element in the array.

codeforcescompetitive-programming
CF 104235D - На уголки не разрезать!

We are given a rectangular grid of size $n times m$, fully covered by unit cells. A player wants to tile all remaining cells after removing exactly one cell using a specific shape called a “corner tromino”: a shape made of three cells that forms an L, i.e.

codeforcescompetitive-programming
CF 104235C - Разговор о деревьях

We are working with a tree on $n$ vertices where vertex 1 and vertex 2 are fixed in a special way: the distance between them is exactly $m$, and no pair of vertices in the tree is farther apart than $m$.

codeforcescompetitive-programming
CF 104235B - Мед в сотах

We are given two identical geometric objects on a grid, each object is a regular hexagon of side length 1. Each hexagon is placed in a fixed orientation: two of its edges are vertical, and its lowest vertex is anchored at an integer coordinate point.

codeforcescompetitive-programming
CF 104235A - Красивое окно

We are given a rectangular window of height H and width W. Two cuts are made. First, we choose a vertical cut at some integer position A, splitting the window into a left rectangle of width A and a right rectangle of width W - A.

codeforcescompetitive-programming