brain
tamnd's digital brain — notes, problems, research
41641 notes
We are given a number $r$, and we want to compute a function built from counting pairs of positive integers under a constraint involving their sum and gcd structure.
We are asked to construct a short DNA-like string over the alphabet {C, G, A, T}. Each query gives two target values: the number of subsequences equal to C-A-T (CAT degree) and the number of subsequences equal to G-A-T-A (GATA degree), where subsequences preserve order but may…
We are given a sequence of numbers and asked to compute a global value that depends on all increasing subsequences inside it.
We are given two integer arrays of the same length. Each position contains a pair of numbers, and we are allowed to perform a specific reduction operation that, in essence, keeps replacing a larger value by subtracting the smaller one, similar to repeated Euclidean subtraction.
We are given two different structures over the same set of vertices labeled from 1 to N. One structure is a tree, so between any two vertices there is exactly one simple path. The other structure is an arbitrary undirected simple graph.
We are given two stacks of crates. Each crate has a unique label from 1 to n, except one special crate labeled 0, which is “ours” and is not part of the loading order. The initial configuration is fixed: we are told the bottom-to-top order of each stack.
We are given a list of $n$ guests, each carrying a numerical strength value. Every unordered pair of distinct guests forms a dancing duo, and each duo contributes a score equal to the square root of the sum of their two strengths.
We are given a rectangular screen aligned with the coordinate axes. Its lower-left and upper-right corners define a fixed axis-aligned rectangle in the plane. Separately, we are given a line segment representing the path of a stapler pin, defined by two endpoints.
We are given a tree with weighted edges of weight 1, plus one additional special edge called a portal that connects two fixed vertices $x$ and $y$. The portal can be used any number of times, and every use has cost 0.
We are given a simple interactive story that reduces to a decision about whether a value should be accepted immediately or allowed to “grow” once more. A starting amount of money $x$ is offered to the first person.
We are given a text string consisting of letters, and the task is to compute how many times each distinct letter appears.
I can’t write a correct editorial yet because the actual problem statement for Codeforces 106082E - Word Tree isn’t included in your message (it looks truncated to just the title and placeholder text).
We are given three ingredients: a dictionary of words where each word has a fixed 2D integer vector, a long text that acts as a reference corpus, and a set of queries.
We are given a target binary string of length $N$, and we start from an all-zero array of the same length. We are allowed to perform an operation that picks a starting position $i$ and XORs a fixed 8-bit pattern $B$ onto the array, aligned so that $B[j]$ affects position $i+j$…
We are given a small collection of domino tiles, each tile labeled with two numbers from 1 to 6. A tile can be used in a sequence if one of its ends matches the currently exposed number at either the left or right end of an evolving chain.
We are working with a sequence of length $N$, where $N$ is a power of two and can be as large as $2^{18}$. The array supports two operations that both act on a segment $[l, r)$.
We are asked to count sequences of length $n$, where each element is an integer in the range $[0, 2^m - 1]$. Two conditions must hold simultaneously. First, no two adjacent elements are allowed to be equal.
We are given two permutations of the same length, call them $p$ and $q$. Each position $i$ represents a paired state: one value from $p$ and one value from $q$.
We start with a single equilateral triangle whose size is described by its height $H$. The process is iterative. In each operation, the triangle is subdivided into four congruent equilateral triangles, and only the central one is kept while the other three are discarded.
We are working on a rectangular city grid with $N$ rows and $M$ columns. You are allowed to place $K$ fire stations on arbitrary grid cells.
We are given a list of positions on a number line, each position representing where a person lives. The goal is to choose one of the given positions as a meeting point so that the sum of walking distances from all people to that chosen point is as small as possible.
We are given a list of numerical valuations, one per student, representing how much each student values a dormitory spot. Only the top m students by declared value will receive dormitory rights.
We are given three labeled points in the plane, and each point can be moved repeatedly. A single move picks one of the points and relocates it anywhere in the plane, but under a strict geometric constraint: the angle formed at the moved point by the segments to the other two…
We are given positions of enemies and positions of observers on a number line. For each observer, we care about enemies that lie within a specific distance band from them. Each observer at position b defines two radii.
We are given a rectangular grid where each cell contains a non-negative integer. From each row, we must pick exactly one element. After selecting one number per row, we compute the bitwise AND of all chosen values.
We are given a sequence and a constant threshold value. For every contiguous subarray, we compute its sum, then replace that sum by the larger of the sum and the constant. The value of the whole array is defined as the sum of these adjusted subarray values over all subarrays.
We are asked to construct an array a of length n, where each position i contains a positive integer not exceeding $10^9$.
We are controlling a single creature whose “state” is an integer value from 0 up to n. We start at state 0 and want to eventually reach state n. There is a shop that sells helper creatures. Buying a helper of value i costs ai, and there is unlimited supply for every i.
We are given a fully specified deterministic tournament between 16 teams. Every pair of teams has a fixed outcome encoded in the input: for any initial seed positions i and j, exactly one of them wins if they ever meet, and this result never changes.
We are given a tree with n nodes. Each node independently contains an enemy with probability pi, given as a fraction ai / bi modulo a large prime. For any choice of a target node x, the protagonist starts from some leaf node and walks along the unique simple path to x.
We are given a rectangular grid with dimensions $n times m$. On this grid, there are $k$ mineral fields. Each mineral field is defined by a center cell $(xi, yi)$ and a Chebyshev radius $disi$, meaning it occupies every grid cell whose row and column are both within $disi$ of…
We are building a small team with a limited number of slots, and we want to maximize total attack power. There are two types of units. One type is a basic unit, which always contributes a fixed attack value $a$.
Each input test case gives two stellar classifications written in a fixed format: a capital letter followed by a digit. The letter represents a coarse temperature class ordered from hottest to coldest as O, B, A, F, G, K, M.
We are given two configurations of a 3 by 3 grid, each cell containing a distinct digit from 1 to 9. So each grid is really a permutation of the numbers 1 through 9 arranged in row-major order.
We are simulating a production pipeline with k workers arranged in a line. Each worker has a private inbox. Over time, n items arrive at specified workers at specified minutes. Once an item is in a worker’s inbox, it participates in a synchronized daily routine.
We are given a list of positive integers, and we are allowed to perform exactly $k$ operations. Each operation picks a single position and increases that element by 1.
We are given a decimal integer $A$ with no leading zeros. Think of its digits as positions in a sequence. We want to construct another integer $B le A$ such that the digit sequence of $B$ can be interpreted as a valid weighted parenthesis system.
We are simulating a point moving inside a vertical strip between two horizontal boundaries, at heights 0 and H. Inside this strip, there are point obstacles called boards. These boards are not intervals or segments, they are exact coordinates.
We are asked to construct an array of length $n$ consisting of distinct positive integers. The array is not arbitrary: every pair of adjacent elements must be coprime, meaning their gcd is exactly 1.
We are given a sequence of integers and we repeatedly look at its prefixes. For each prefix of length i, we must decide whether we can construct a permutation of positions and a permutation of values so that the prefix values appear as “window maxima” of a carefully chosen…
We are given a cyclic structure with $n$ rotating rings, each ring associated with a step size $ai$ and an initial position $bi$ on a regular $m$-gon.
We are maintaining a dynamic array that starts with an initial sequence and then grows over time by appending elements. Over this evolving array, we are asked to process two kinds of operations that are intentionally obfuscated so that each query depends on the previous answer.
We are given a set of weapon choices and a separate set of support sets. Each weapon has a base attack value and a bonus that contributes either to critical rate or critical damage depending on its type.
We are given an array of integers placed on positions from 1 to N. A “path” is formed by picking any starting position and then repeatedly either stopping or jumping to a strictly larger index.
We are given a classical memory size expressed in megabytes and asked how many qubits are needed in a quantum-style model so that it can represent every possible classical memory state of that size.
We are given a tree where each vertex must be assigned a value from 1 to 5. The number of vertices assigned each value is fixed in advance, so exactly cnt1 vertices must get value 1, exactly cnt2 vertices must get value 2, and so on up to 5.
We are given a single integer $X$. We need to find the largest integer $Y$ such that $Y le X$ and the binary representation of $Y$ is a palindrome.
We are given a rooted tree where each node represents a state of a system, and each edge from a parent to a child is labeled with a lowercase letter.
We are given two strings of equal length representing the state of a collection of qubits. The first string describes an “isolated” configuration, where some positions are stable bits 0 or 1, and some positions are uncertain and marked as , meaning the qubit is in…
We are simulating a bathhouse that consists of a grid with 2m rows and n columns. Each cell can hold at most one person. Rows are naturally paired: row 1 faces row 2, row 3 faces row 4, and so on.
We are given a graph with 2n cities split into two rows. The first row contains cities labeled from 1 to n, and the second row contains cities labeled from n+1 to 2n.
We are given an undirected graph with n vertices and m edges. The graph can already contain self-loops and multiple edges between the same pair of vertices.
We are looking at a partially dealt hand from a two-deck card game. The full deck has 108 cards, meaning each rank-suit combination appears twice.
We are given a one-dimensional world that behaves like a lane from position 0 to a large endpoint. Enemies spawn at the left end at specific times, each with an initial health value. Once spawned, every enemy moves right by one unit every second.
We are given a square assignment problem where there are as many employees as jobs. Each employee-job pair has a profit that comes from two parts: a structural part derived from the employee’s skill value and the job’s requirement value, and an optional bonus that applies…
We are given a mutable integer array. Two types of operations are applied over time. One operation increases every element in a contiguous segment by the same value.
We are given two players who each hold a multiset of Rock, Paper, and Scissors cards. Both players will play all their cards over n rounds, one card per round per player, and each round is evaluated by the usual Rock-Paper-Scissors rules.
We are given two integers $x$ and $y$ such that there is at least one integer strictly between them. The task is to pick an integer $z$ that lies strictly inside the interval $(x, y)$, and at the same time is “compatible” with both endpoints in the sense that it shares no…
We are given an array $a$ of length $n$, and a sequence of $k$ operators, each being either a sum operation or a product operation.
We are given a tree where each vertex starts with a color. Then we process a sequence of repaint operations, each of which overwrites colors on a specific set of vertices. The goal is to determine the final color of every vertex after all operations are applied in order.
We are given several hidden positions on a number line from 1 to 100000. These positions represent locations of firefly groups. We do not know the positions, and multiple groups may exist at different points.
We are asked to evaluate a range expression over integers from $l$ to $r$. For each number $x$ in this interval, we take the bitwise XOR of $x$ with a fixed integer $y$, interpret the result as a value, and then aggregate those results over the entire range.
We are given a single array f of size n. This array is claimed to be the final state of a Disjoint Set Union structure that started from f[i] = i for every element and then had at most n calls to a merge(u, v) operation. The DSU implementation is slightly asymmetric.
We are given an array, and instead of computing a classical longest increasing subsequence, we apply a very specific greedy procedure to every contiguous subarray and sum the results.
We are asked to construct an integer array of length n, assigning a value to each position in a line of Nabis. The assignment must satisfy two sliding window constraints simultaneously. For every contiguous segment of length p, the sum of its elements must be strictly positive.
Codeforces 105911H: Bingo Game
We start with $n$ identical coins, all initially showing heads. Another player secretly flips exactly $k$ of them to tails, and we do not know which subset was chosen.
We are given a tree with nodes labeled from 1 to n. The structure of the tree is fixed. Each query provides three values l, r, and x, and asks for a single node: if we consider only the nodes in the contiguous label range from l to r, and treat x as the root of the tree, we…
We are given a row of statues, each initially pointing in one of four directions arranged in a cycle: front, right, back, left, and then back to front again after a full rotation.
We are given a binary string representing a schedule over n time slots. Each position is either 1, meaning TreeQwQ is currently on a date, or 0, meaning free time.
We are given a directed graph where each cave is a node and each one-way passage is a directed edge with a weight called difficulty. Alice starts at a specified node with an initial integer stamina.
We are given a grid where some cells are marked as occupied and all occupied cells form one connected region if we move in four directions.
We are given several line segments inside a rectangular box aligned with the coordinate axes. Each segment has both endpoints on the surface of the box, so every segment “lives” entirely within or on the boundary of the cuboid.
We are given a sequence of tree heights. We must perform exactly $s$ operations, and each operation reduces the height of exactly one tree by one unit.
We are given a binary grid with n rows and 4 columns. Each cell tells us whether a note exists at that time step (row) and lane (column). A 1 means a note must be played, and a 0 means empty space.
We are given a two-player deterministic game played with a pile of skewers. At the start there are x skewers and a parameter k. Players alternate turns, with OC always moving first.
We are given a line of positions from 1 to n. A player starts at one of the two endpoints and moves forward in time through m events.
We are given an array that changes over time, and we must answer two kinds of queries on it. One query modifies a single position, and the other asks whether a chosen contiguous segment of the array has a very specific property. The property itself is defined indirectly.
We are given several integer arrays, and for each one we want to build a subsequence with a very specific structural property. Take any chosen subsequence and sort it.
We are given several independent test cases. In each test case there are multiple casinos and several existing players. For every casino, each of the existing players has already committed a nonnegative number of dice.
We are given a grid where each cell contains an integer value, and we consider all monotone paths from the top-left corner to the bottom-right corner, where each move is either right or down.
We are given several independent test cases. In each test case, there are multiple groups of identical items. Group i contains aᵢ items, and every item in that group has weight exactly 2^{bᵢ}. All items from all groups must be packed into m identical knapsacks.
We are given a list of numeric attributes, where each attribute starts with an initial value. Alongside this, there are several constraints.
We are given a very long integer sequence, but it is not provided explicitly. Instead, it is given in compressed form as runs of equal values. Each run says that a value v is repeated l times, and adjacent runs always have different values.
We are given three small integers $A$, $B$, and $C$, and then a list of up to 1000 query values $X1, X2, dots, XQ$. For each query value, we must evaluate a fixed cubic expression, take its absolute value, and finally combine all results using bitwise XOR.
We are given a directed weighted graph where nodes represent gas stations and edges represent one-way roads with travel distances. We start at node 1 and must reach node N. Every valid route from 1 to N has two competing criteria.
Two moving objects are given on a 2D plane, each one represented as a rigid triangle. Each triangle is described by three fixed vertices at time zero, and then the entire triangle translates with a constant velocity vector.
Each person chooses exactly one other person as their “true love”. From this we build a directed graph on $N$ vertices where every vertex has exactly one outgoing edge, possibly to itself.
We are given an infinite collection of cards where each card is labeled by a power of a fixed integer $n$. The first card has value $n^0$, the second $n^1$, the third $n^2$, and so on.
We are comparing two containers filled with ice cream: a cylindrical bottle and a cone with an extra dome on top. The bottle is a simple cylinder with radius rL and height hL, completely filled. Its capacity is just the usual cylinder volume.
Codeforces 105895B: Royale Bataille
We are given a noisy black-and-white image represented as an $n times m$ grid of characters. Each cell is either 0 or 1, where 1 corresponds to a white pixel and 0 corresponds to a black pixel.
We are given a small grid, up to 8 by 8, where each cell is either allowed or forbidden. Allowed cells contain a cat and are marked with a character like Y, while forbidden cells are marked with N.
We process a sequence of events where each event reveals a value and a profit structure. Alongside this sequence, we maintain a cache with limited capacity.
We are given a square grid of size $n times n$, where each cell contains an integer between $0$ and $n$. We are allowed to modify at most half of the cells in the grid, rounding down. Each modification replaces the current value with any integer in the same range.
We are given a fully connected graph on $n$ vertices, but the edge weights are not arbitrary. Each vertex $i$ has a value $ai$, and the weight of the edge between $i$ and $j$ is defined as $min(ai, aj)$.
We are asked to construct a tree on nodes labeled from 1 to n. The tree must be rooted at node 1, and the only thing that matters in all constraints is the distance from node 1 to every other node in that tree.
We are given a sequence of integers, and the goal is to make all elements equal using a specific operation. Each operation is performed by choosing an index $i$, and then choosing one of three effects. The first effect changes only $ai$ by increasing or decreasing it by 1.
We are given a sequence of integers representing rhyme labels of poems generated line by line. We are allowed to delete any number of lines, but we are not allowed to reorder the remaining ones.
We are given an array of positive integers. Each query focuses on a contiguous segment of this array, and for that segment we are allowed to pick any subsequence (not necessarily contiguous, but preserving order) to form a “game array”.