brain
tamnd's digital brain — notes, problems, research
43815 notes
We are given a grid representing the seating layout of an airplane. Each cell is either empty or contains a virus source.
We are given very large decimal numbers, each representing a banknote serial number. A number is considered valid if it is divisible by 13.
We are given a deterministic way of building a binary tree-like structure by inserting values from 1 up to n into a skew heap.
We are given a permutation of numbers from 1 to n, and we define its “cost” as the total displacement of elements from their natural positions, specifically the sum over all positions i of The task is not only to count or optimize this value, but to enumerate permutations…
We are given a complete k-ary tree of fixed depth, meaning every internal node has exactly k children and all leaves lie at the same depth. Each edge in this tree is independently removed with a given probability p (modulo a prime), so each edge either survives or disappears.
We are given a tree, and some subset of its edges is marked as critical. The process is defined on edges rather than vertices: we start from one chosen edge, treat it as “current”, and repeatedly move to an unvisited edge that shares a vertex with the current one.
We are given two expressions that describe how a labeled tree is constructed. Each expression is a binary structure written using a single leaf symbol 1 and a binary concatenation written as parentheses containing two subexpressions written side by side.
We are given three positive integers $pA, pB, pC$. Each integer defines the period of an infinite binary string. That means the string is completely determined by its first $p$ bits, and then those bits repeat forever.
We are given a graph that represents a prison-like maze. There is a special starting node where K begins, a set of nodes called hoppers, and another set of nodes called doors. The remaining structure is an undirected graph connecting all nodes.
We are given a string of digits and we need to reason about segments of it through the lens of arithmetic modulo 4.
We are given a permutation and a two-player game played on it. The goal of the game is to transform the permutation into a fully sorted sequence in increasing order.
We are given a sequence of values over time, each value being either minus one, zero, or plus one. Each value represents the intrinsic “effect” of a bottle bought on that day.
We are given a mine shaped like a rooted tree of shafts, where shaft 1 sits at the very top and every other shaft has exactly one connection upward that leads to a unique parent. Because of this structure, between any two shafts there is exactly one simple path.
We are given a set of at most 20 cows, each identified by a bit position. Initially all cows are on the left bank of a river, and the goal is to move them all to the right bank.
We are given a long bracket string s that uses eight bracket symbols, four opening types and their matching closing counterparts. From this string we extract m substrings. Each substring is treated as an independent sequence, and we are allowed to pair some of these substrings.
We are given a sequence of days, and on each day we want to compute how many “extra hours of effort” accumulate from a set of scheduled contributions. Each contribution starts at some day $x$ and then affects all days from $x$ to the end $n$.
We are given a single string of length $N$ that is currently in state $A$, and we want to transform it into a target state $B$. Each position holds either a lowercase letter or a dot. A dot represents an empty cell.
We are given a hidden arithmetic expression built from the numbers 1 through N, each used exactly once and arranged in some unknown order. Between consecutive numbers there are operators chosen from plus, minus, and multiplication.
We are given a directed complete graph of planets where each ordered pair of planets may or may not have a hyperjump available.
The task is an interactive exploration problem on a hidden rectangular grid of size at most 30 by 30. Each cell in the grid has four potential neighbors in the cardinal directions, so the underlying structure is the full grid graph.
We are given a sequence of milk batches, each batch has two attributes. The first is a coefficient $bi$ which represents how much flavor Vova gains per unit of heating temperature.
We are given a fixed eight-team single-elimination bracket, already arranged in quarterfinal order from top to bottom. Each team has a unique name and a unique integer strength.
The task is interactive and is not about computing an answer from a fixed input. Instead, we are gradually building a pool of symbols by repeatedly choosing one of six dice types, rolling it, and observing a randomly returned symbol.
We are given a set of points in 3D that form a convex polyhedron. The task is not to reconstruct the polyhedron itself in a combinatorial sense, but to output a planar “net” of it, meaning we must unfold its surface into the plane so that every face becomes a flat polygon in…
We are working on a grid where each cell has a value computed deterministically from its coordinates. That value is taken modulo 4, and it decides how a chess piece behaves when it is currently standing on that cell.
We are given a rooted tree of courtiers where node 1 is the king. Every other node has exactly one parent, so the structure is a rooted tree with edges directed away from the king. We must choose a subset of nodes to be “knights”.
We are given a small system of boys and girls where each boy has a fixed list of girls he is willing to dance with. The process is conceptual rather than simulated: boys go in increasing order, and each boy tries to pick a girl he likes who is still available.
We are given positions of several kings placed on a 100 by 100 grid. In one action, we choose a single king and start moving it step by step in any of the eight directions, so every move changes its cell to one of the adjacent squares including diagonals.
A perfect binary tree is being built level by level. After $n$ days, the tree has height $n$, root is node $1$, and every internal node $u$ has two children $2u$ and $2u+1$.
We are given an infinite line of rooms indexed by all integers. These rooms are partitioned into $n$ groups according to their value modulo $n$.
We are given a schedule planning problem. There are several people, and each person provides one or more time intervals during which they are available. The goal is to determine a single moment in time when the maximum number of people are simultaneously available.
We are given a left-to-right sequence of peaks, but their exact heights are not fixed. Instead, each peak has a range of possible heights derived from a noisy vertical photograph.
We are given five special intersections on an infinite grid of city blocks. Each block is connected by roads that run strictly horizontally or vertically, and every adjacent pair of intersections along a row or column corresponds to one road segment of equal length.
We are working with integers represented in binary, and a simple transformation based on bit counts. For every integer $k$ in a range starting from 1 up to $2^n - 1$, we perform a process that repeatedly replaces the number by the number of set bits in its binary representation.
We are given a number written in decimal form, and we need to construct another number that is strictly larger than it while satisfying a digit-wise restriction.
We are given a grid with 3 rows and N columns. Each cell contains either 0 or 1, representing votes for two candidates. We can think of each cell as a unit city with a binary label.
We are given a line of books, each with a value, and a process that removes books from the ends over time. At every second, two things happen in sequence: first, Keys may take exactly one remaining book from anywhere in the current segment, and then the fire burns the current…
We are given a long sequence $S$ that is constructed in a very specific way. Each operation takes the numbers from $1$ to $m$, randomly permutes them, and appends that permutation to the end of $S$.
We are given a graph whose vertices represent islands and whose edges represent direct travel routes between pairs of islands. The key structural constraint is that this graph contains no cycles, which means every connected component of the graph is a tree.
We are working with an array that changes over time through point updates. After each update, we need to evaluate a global quantity defined over all values that appear in the array. For any value x, we look at all subarrays that do not contain x at all.
We are given an undirected graph with a weight on each vertex and a cost function defined on step lengths of a walk.
We are given two arrays of equal length that represent two competing progress tracks over time. One array describes Jim’s daily gains and the other describes the pirates’ daily gains. What matters is not the raw values themselves but the cumulative difference between them.
We are given a sequence of operations that repeatedly transform an interval of integers. Initially, every integer in a fixed range is considered valid. Each operation shifts the entire current valid range either left or right by a given amount.
We are given a list of integers. The operation we are allowed to perform is to pick exactly two of these numbers, replace them with their sum, and then consider the greatest common divisor of the resulting multiset.
We are given an array of integers where we are allowed to select a contiguous segment and flip the sign of every element inside it. After performing this operation, we evaluate the resulting array by its minimum value.
We are given an undirected graph that represents locations connected by passages. The task is to determine which parts of this graph remain usable if we repeatedly enter regions where we can explore fully and return to the entry point, but we cannot afford to get stuck in a…
We are given a process that repeatedly produces fractions and then combines them. At some point, we end up with a collection of fractions of the form $frac{a1}{b1}, frac{a2}{b2}, dots, frac{ak}{bk}$.
We are given a square board of size $n times n$. We are interested in ordered pairs $(a, b)$, where both $a$ and $b$ are integers between $1$ and $n$, and we want to count how many such pairs satisfy a divisibility condition: at least one of the numbers $a$ or $b$ is divisible…
Each test case describes a fixed battle scenario with N independent attacks. Attack i targets goblin i and either deals full damage Ci or nothing, depending on whether its penetration Ai reaches the goblin’s defense Bi.
We are given several independent dice, where each die has its own list of face values. A single operation consists of rolling some of the dice, observing their outcomes, and deciding which dice to keep active for future rolls and which to lock permanently.
We are given a fixed dictionary of distinct words. Between any two words, we define a connection rule that depends only on their letters: two words are considered directly compatible if they share at least one common character.
We are given a rooted tree with node 1 fixed as the root. Two players start on two different nodes, Alice on node A and Bob on node B. They move alternately, with Alice starting first.
We are given a connected undirected graph with n nodes, where node i represents both a friend and their home. Each node has exactly one decision to make: it selects a “club” label from 1 to n, and multiple nodes are allowed to pick the same label.
We are given a complete graph with $n$ vertices. Each vertex initially has a color, and colors are given as integers. The graph structure itself is not really something we need to manipulate explicitly because every pair of vertices is connected.
We are given several independent test cases. Each test case describes a collection of music genres, where the i-th genre contains ci distinct songs.
The city is a rectangular grid of intersections, where each cell may contain a customer parcel that must be picked up. Movement is constrained by one-way streets: from any intersection you can only move either south or east.
We are building a very large multiset of monster HP values, each value chosen from the range from zero up to some maximum $N$. There are $R$ monsters, and the order of these values matters, so we are effectively dealing with sequences of length $R$.
We are given a rooted tree, and every node carries two values, one from array a and one from array b. Some entries in both arrays may be zero, and zero acts as a wildcard that can match anything.
We are given a string and a single allowed operation that modifies it by deleting characters. One operation works by selecting a contiguous segment of the string and also selecting a character, then removing every occurrence of that character inside that segment only.
We are asked to process multiple independent queries. Each query gives an interval $[a, b]$ and a target number $k$. For every integer $x$ in that interval, we convert $x$ into binary without leading zeros and count how many bits are equal to 1.
We are given a rectangular grid of size $h times w$. A token starts at the top-left cell $(1,1)$ and wants to reach the bottom-right cell $(h,w)$. Movement is constrained to only go right or down, so every valid path is a monotone path in the grid.
We start with a tree on n vertices. Then one extra edge is added between two previously non-adjacent vertices, turning the structure into a single cycle graph with exactly one cycle. We are not directly told which edge was added.
Each test case describes a vertical cave system with several shafts. You start at the top of one chosen shaft and move strictly downward. While descending, you may encounter horizontal tunnels placed at distinct depths.
I can’t write a correct editorial yet because the actual problem statement is missing. Right now all we have is the title “Maximum Satisfaction”, but no description of: what is given in the input, what choices are allowed, what “satisfaction” depends on, or what must…
We are given a sequence of points in the plane, representing stars visited in a fixed order. Consecutive stars are always aligned either horizontally or vertically, so each move between star $i$ and star $i+1$ is a straight segment parallel to an axis.
We are given the full structure of a directed acyclic graph, but the weights of the edges are unknown. The only way to learn anything about the weights is through an interactive oracle: we choose a pair of vertices $s, t$ and a scalar $c$, and the oracle returns the sum over…
We are given a string $S$ of length at most 40. Think of its characters arranged in a line. We also have an empty string $T$. We repeatedly remove characters from either the left end or the right end of the remaining $S$, and append each removed character to the end of $T$.
We are given a connected bipartite graph with up to 100 vertices, where each vertex has a positive weight. The task is not just to assign directions arbitrarily to edges, but to orient every edge so that a particular cost function becomes as small as possible.
The problem is essentially asking us to process a row of lanterns along a riverbank, where each lantern is either on or off. The input gives us a sequence of length n, and each position contains either a 0 meaning the lantern is unlit or a 1 meaning it is glowing.
We are counting a very specific family of rooted trees on labeled vertices from 1 to n. The tree is rooted at node 1, and labels behave in a monotone way along any root-to-node path: whenever we move away from the root, labels must strictly increase.
The task revolves around applying a very specific transformation to a single string using Python’s built-in list conversion semantics.
We are given a rooted tree with a value written on every vertex. The root is fixed at vertex r. Alongside this tree, we are allowed to repeatedly perform a structural modification that targets a vertex v (different from the root).
We are given a line of robots labeled from left to right. Robot $i$ starts at position $x = i$, and all robots begin moving left at time zero.
We are given an array and a segment tree that was built over it for range minimum queries. The tree is standard: every node represents a segment of the array, and stores the minimum value on that segment.
The dungeon is given as a grid where only certain cells are actual rooms. Between neighboring rooms there may be doors embedded in the walls, and these doors define an undirected graph: each room is a node, and each door connects two adjacent rooms.
A run in this game is a sequence of $n$ levels that must all be cleared in order. At each level, a single attempt either succeeds with probability $1-p$ or fails with probability $p$.
We are given a rectangular grid where each cell is colored either black or white. The grid is naturally embedded on a vertex lattice: an $n times m$ cell grid corresponds to $(n+1) times (m+1)$ lattice vertices, and moves are allowed only along unit edges between adjacent…
We are given a binary sequence written on a board. Each position contains either 0 or 1, and two players play alternately starting from the leftmost turn. Alice is responsible for interacting with zeros, while Bob is responsible for interacting with ones.
We are given a sequence of cats, each cat having an age and a binary label that represents whether it is believed to be “senior” or “junior”. For a query, we look only at a contiguous segment of cats, and we are allowed to select exactly $k$ cats from that segment.
The statement you provided is not actually sufficient to reconstruct a Codeforces problem. What is visible is only the title, a stray “N”, and some formatting artifacts (“Lament Rain”, time/memory limits), but the core definition of the task is missing: there is no…
We are given two integers that represent a desired result of some hidden encoding process applied to a string of lowercase Latin letters.
We start with a rectangular chocolate bar of size $n times m$. The final goal is to end up with a square chocolate, but the allowed operation is not free-form cutting.
We are asked whether it is possible to form a triangle whose side lengths are three consecutive natural numbers and whose perimeter equals a given value $p$. A valid triangle in this setting is fully determined by a starting integer $a$.
We are given several independent test cases. In each test case, there are $n$ types of items. Each type can be used any number of times, including zero, and every item of type $i$ has a fixed weight $wi$.
We are given a fixed tree with $n$ nodes. Each node $i$ hides a value $wi$, with the root node $1$ guaranteed to have value $0$. The only way to obtain information is by querying pairs of nodes $(u, v)$.
We are moving along a straight corridor divided into vertical “lanes” indexed from 0 to n + 1. Time is discrete. At each second, you either stay in your current lane or move exactly one lane to the right.
We are asked to arrange $n^2$ items on an $n times n$ grid. Each item has a type from $1$ to $n$, and each type appears exactly $n$ times, so the multiset is perfectly uniform.
We are given points on the boundary of a unit circle. Each point is specified by an angle, and these points represent available endpoints for straight cuts inside the circle.
We are given a tree where each node represents a tree in a plantation and each node initially contains some number of mango batches. Two people operate on this tree: Bob and Alice.
The structure is a complete binary tree where every node from 2 onward has a parent given by integer division by two. This makes the topology fixed and implicit: node 1 is the root, node 2 and 3 are its children, node 4 to 7 are next level, and so on up to n.
We are given several containers, each containing a liquid solution. For each container we know two values: the total mass of the solution and how much of that mass is salt.
We are given an undirected simple graph with at most 100 vertices and 100 edges. The task is not to “draw” anything geometrically in a computational sense, but to decide whether this graph can be interpreted as a very specific structure called an apple.
The input describes a directory structure through a list of file paths. Each path represents a file located somewhere inside a hierarchy of directories separated by slashes.
We start with a right isosceles triangular sheet of paper. Think of it as a 45-45-90 triangle. Vitya repeatedly folds this triangle along lines that split it into two congruent parts.
We are given five collections, each collection containing exactly five integers. Each integer describes a fork by the number of tines it has. Two forks are considered identical if their integer labels match. A “set” here is really a multiset of five integers.
We maintain an array of bank balances indexed from 1 to N. Initially each account already contains some integer amount, and then we must process a sequence of operations that modify or query this array. There are two update operations and one query operation.
We are given an $n times n$ grid representing a tiled wall. Each cell contains either a gold tile, written as G, or a silver tile, written as S. We are also given an integer $k$, and we want to choose a contiguous $k times k$ sub-square of this grid.
We are given a line of $n$ people indexed from 1 to $n$. The process repeatedly forms a group from the current line by selecting all positions whose indices are Fibonacci numbers.
We are working with a fixed 2 by 2 binary grid, so every configuration is a 4-bit state. Each operation flips bits in a specific pattern: either one cell, an entire row, an entire column, or all four cells at once.
We are given a grid with $n$ rows and $m$ columns. Before filling the grid, we assign one number to each row and one number to each column. Call the row values $a1 dots an$ and the column values $b1 dots bm$.