brain
tamnd's digital brain — notes, problems, research
43815 notes
We are working with a tree where we want to select several simple paths, with a strict rule that no vertex can belong to more than one selected path.
We are given a network of servers where each server has an integer label (an encryption key) in a fixed bit range. Some pairs of servers are connected, and a connection is considered safe only if the two endpoints currently hold different values.
We are given a fixed sequence of departure times from station A, strictly increasing, and for each bus we also know a constraint on how “late” it can possibly appear in the arrival order at station B.
We are given a line of dancers, each occupying a fixed position. Every dancer must end up wearing either a white suit or a black suit, and some of these suits are already fixed while others are undecided.
We are given a multiset of information that originally came from a rooted structure, but the structure itself is hidden. There exists a tree on vertices numbered from 1 to n, and each vertex has a unique label equal to its number.
We are given a set of moments inside a working day when Monocarp is willing to drink coffee. Each moment is a specific minute inside a day that lasts from minute 1 to minute m.
We are given a set of keyboard indices that survived a burglary. The key hidden structure is that before the theft, all keyboards formed one continuous block of integers, something like x, x+1, x+2, and so on up to some unknown length.
We are given a grid where every cell has a numeric value, and a chip starts at a specific cell. From its current position, the chip can only move to cells that have strictly smaller values than the current one.
We are given an array of integers, and we repeatedly reduce it until only one value remains. Each reduction step either merges two positions by multiplying their values and storing the result into one of the positions, or removes a single element entirely, but that removal…
We are given several benches, each already occupied by some number of people. Then a group of new people arrives, and each of them must choose a bench and sit there.
We are given a long string and many queries, each asking about a substring. For each substring, we imagine splitting it into several consecutive pieces. Among those pieces, identical pieces are considered the same “band”.
We are given several different observations of the same set of people, each observation being a full ordering of the same $n$ elements.
We are given a set of participants, each described by two numbers. These two numbers represent how much penalty a participant contributes depending on whether they solve the first task or the second task in a two-person training contest.
We are given a multiset of positive integers, and we are allowed to choose any subset of these numbers. For a chosen subset, we compute the greatest common divisor of all selected elements.
We are given a binary string consisting only of characters a and b. We process its prefixes from left to right in a fixed order, meaning we first decide what to do with the prefix of length 1, then length 2, and so on until the full string.
We are given a sequence of prefix values a[0], a[1], ..., a[n] where a[0] = 0. The sequence was originally generated from a hidden array x of length k, but that array is no longer available.
Each student in the school is forced to distribute a fixed number of votes, denoted by $k$, between two candidates. For every student, we are given how many votes they intend to give to Elodreip.
We are dealing with an extremely large conceptual array indexed from 0 up to $2^{30}-1$, but we never actually store its values.
We are working with a fixed tree on $n$ vertices.
We are given a huge grid, but movement is not about stepping cell by cell. Instead, a rook starts at the bottom-left corner and can teleport along an entire row or column, as long as nothing blocks its straight-line path. There are two kinds of obstacles.
We are given a small grid, at most 20 by 20, containing a permutation of the numbers from 1 to nm. The goal is to transform this grid into sorted order when read row by row.
We are given a tree with n vertices, but there is a twist: there are two different labelings of the same underlying tree. In your view, the vertices are numbered from 1 to n and the edges are given in this numbering.
We are given a convex polygon with its vertices already listed in clockwise order. The geometry is fixed: we cannot move points, only choose subsets of vertices.
The input describes a tree where each edge connects two craters and carries a single lowercase letter. If you walk between any two craters, there is exactly one simple path, and that path naturally produces a string formed by concatenating the edge labels along the way.
We are given a fixed set of monomials in two variables, each monomial having the form $x^{ak}y^{bk}$, but with an unknown positive integer coefficient. Before the coefficients are chosen, Ani is allowed to remove at most one monomial.
We are given a set of robots placed on a number line. Each robot sits at a coordinate and has a fixed symmetric visibility range around its position. Inside that range, it can potentially “see” other robots. However, visibility alone is not enough for interaction.
We are given a collection of weapons and a line of ships, and we want to assign each destroyed ship to exactly one weapon. Each weapon has a limited way of interacting with ships, and the goal is to maximize how many ships get assigned and destroyed under those constraints.
We are given a connected undirected graph with up to one hundred thousand vertices and up to half a million edges. Each query asks for the shortest path length between two given vertices, measured in number of edges. A crucial extra constraint changes the structure of the graph.
We are given a group of fighters, each starting with a positive strength value. We repeatedly pick two still-alive fighters, and the one with the smaller index is always removed. The survivor’s strength is updated by subtracting the removed fighter’s strength from theirs.
Codeforces 2013C: Password Cracking
We are given a weighted tree where each node represents a city and each edge represents a bidirectional road with a travel time. The traveler must design a walk that eventually visits every city at least once.
Working
We are given a circle with lamps placed on its boundary in a fixed clockwise order. Between consecutive lamps we know the arc lengths, so the geometry of the circle is fully determined up to rotation.
Each row initially contains a contiguous block of contestants placed on an extremely large integer line of columns. Row $i$ occupies every position from $Li$ to $Ri$, so geometrically each row is just a closed interval.
We are standing on a vertical strip of numbered cells from 1 at the top down to n at the bottom. A token starts at cell n, and we repeatedly move it upward until it reaches cell 1.
We are given a rule that fills an infinite grid with positive integers starting from 1. The placement does not proceed row by row or column by column in a simple linear fashion.
We are asked to construct, for each query, the smallest integer that is at least a given number n, under a digit-restriction constraint. The constraint is that the resulting number may use at most k distinct decimal digits in its representation, with no leading zeros allowed.
We are given three distinct labels that refer to people placed on a perfectly even circle. The circle size is even, but unknown, and the labels are not guaranteed to be consecutive or small.
We are given a line of positions, each position holding a tile that must end up colored either red or blue. Some tiles are already fixed, while others are blank and can be assigned either color.
Codeforces 1559C: Mocha and Hiking
We are given two different forests built on the same set of vertices from 1 to n. Each forest is already acyclic, but they may have multiple connected components.
We are given a permutation that is repeatedly processed by a very specific “two-phase bubble-like” routine. In each iteration, we do not scan all adjacent pairs; instead we alternate between touching only odd edges and only even edges.
We are given only the final match statistics of a tennis game: Alice has won a individual games and Borys has won b individual games. We do not know the order of these games, and we also do not know who served first. What we do know is that service alternates strictly every game.
We are given a permutation of length $n$, where $n$ is always odd. The only operation allowed is to take a prefix of odd length and reverse it. Each operation affects only the first $p$ elements, flipping their order, while the rest of the array remains untouched.
We are given an array of distinct integers and allowed to perform a very specific transformation exactly once. First, we cut the array into exactly k contiguous pieces, each piece non-empty.
We are given an array of integers, and we must split it into two non-empty groups while preserving every element exactly once. Each group has a score equal to its arithmetic mean, and the goal is to maximize the sum of these two means.
We are given a fixed integer n and a range of integers 0, 1, 2, ..., m. Each number in this range is XORed with n, producing a set of values. From this resulting set, we want the smallest non-negative integer that does not appear.
We are asked to construct a string of length n using lowercase English letters such that a very strong parity condition holds: every non-empty substring must appear inside the string an odd number of times when we count all occurrences.
We are given a fixed set of nodes, each labeled by a distinct integer. Two nodes are connected if their labels share any prime factor. This means the graph is determined entirely by the prime factorizations of the given numbers. For each query, we are given two starting nodes.
We are given a sequence of distinct positive integers. After reading the first k elements, we define a score pk that aggregates the remainder produced by dividing every ordered pair (ai, aj) among the first k elements.
We are simulating a typing process where we scan a source string s from left to right. At each position, we either append the current character to an evolving text buffer or press backspace, which deletes the most recently added character if it exists.
We start from the identity permutation, which is simply the numbers from 1 to n in order. Someone first rotates this array cyclically to the right by an unknown shift k, and then performs at most m arbitrary swaps of elements.
We are dealing with a hidden axis-aligned rectangle whose corners lie on integer grid points inside a fixed 200 by 200 grid.
We are given points placed around a circle in clockwise order. Some of these points are already connected by chords, and these initial chords never share endpoints.
We are given a long line of positions from 1 to n·k, each position painted with one of n colors, and each color appears exactly k times. For every color i we must choose exactly one interval [ai, bi] such that both endpoints belong to positions colored i.
We are given a rectangular board with $n$ rows and $m$ columns, containing $n cdot m$ unit cells. Since this product is even, the board can be fully tiled by dominoes, where each domino always covers exactly two adjacent cells sharing a side.
We are given a string made of lowercase Latin letters. We want to select some of its positions and assign each selected position one of two colors, red or green, with three rules. First, every chosen position gets exactly one color, while some positions may remain unpainted.
We are given two non-negative integers, and we can move them in lockstep: every operation changes both values by exactly the same amount, either increasing both by one or decreasing both by one (as long as we do not go below zero).
We are playing an interactive game with a hidden number that always stays in the range from 0 to n − 1. We repeatedly submit guesses. If a guess is correct, the interaction ends immediately.
We are given a sequence of operations that can either insert a value into a multiset or delete the smallest value currently present.
We are given a collection of numbers with even size, specifically 2n integers per test case. The task is to decide whether it is possible to partition these numbers into n disjoint pairs such that every pair consists of two numbers whose sum is odd.
We start with two numbers, and we are allowed to repeatedly “divide” either of them by some integer greater than one, as long as it divides cleanly.
We are given a very small “programming language” where variables store strings. Each variable is either assigned a literal string of length at most five, or defined as the concatenation of two previously defined variables.
We are given a binary grid and we are allowed to flip cells from 0 to 1 or 1 to 0. The goal is to transform the grid so that every square submatrix whose side length is even contains an odd number of ones.
We are asked to construct a permutation of the numbers from 1 to n such that every contiguous segment behaves in a very specific way under the bitwise OR operation. For any subarray, we take all values inside it and compute their bitwise OR.
We are given many independent ranges of integers. For each range $[l, r]$, we need to pick two different integers $x$ and $y$ inside this interval such that their least common multiple is also inside the same interval.
We are given a string of digits and allowed to delete characters anywhere we like, preserving order of the remaining ones. The goal is to transform the string into a special form called “good”.
We are given multiple independent queries, each asking whether a target number can be broken into four distinct positive integers.
We are given a directed structure over indices from 1 to n, where each index i has a value a[i] and a pointer b[i]. The pointer either leads to another index or is absent (represented by -1).
The village is a tree where each house is a node and each road is an edge of length one. Initially, every house has exactly one villager. We must reassign villagers so that every person moves to a different house, forming a permutation of nodes with no fixed points.
We are given an undirected graph where every edge enforces a linear constraint between its endpoints. Each vertex must be assigned a real value, and every edge says exactly what the sum of its two endpoint values must be. Black edges force a sum of 1, red edges force a sum of 2.
We are interacting with a hidden system that has chosen an integer threshold $C$ between 1 and $N$. We can think of the numbers from 1 to $N$ as positions on a line, and every time we pick a position, we are effectively “dyeing” hair with that color.
We are maintaining a dynamic multiset of 3D vectors, each vector representing the amounts of salt, pepper, and garlic powder in a bottle.
We are working with a tree where vertices are gradually removed in rounds. In one round, we are allowed to pick a single internal vertex $v$ and remove exactly $k$ of its current leaf neighbors. A vertex counts as a leaf if it has degree one in the current remaining graph.
The task is to transform a given string into a very specific recursively defined structure centered around the letter 'a'.
We are given an array and we are only allowed to delete a prefix, meaning we remove some number of elements from the front and keep the rest unchanged.
We are given a one-dimensional path from a shore to an island, where the sea between them is split into $n$ positions. Each position has a base depth $di$. Time progresses in discrete steps, and at each time the water level is uniformly shifted by a periodic tide function.
Stopped thinkingDo you like this personality?
We are given a complete permutation of numbers from 1 to $n cdot m$ arranged in an $n times m$ grid. From this grid we extract two small summaries: the set of row maxima and the set of column maxima.
We are given two strings of equal length, built from a small alphabet of 20 letters. We start with string A and want to transform it into string B using a specific operation. One operation works like this: pick a letter x.
We are given two integer arrays, and we want to construct a third array that can be obtained by deleting elements from both of them. In other words, we are looking for a sequence of values that appears in both arrays while preserving order in each.
We are given two binary strings of equal length. The goal is to transform the first string into the second using a very specific operation: pick a prefix, reverse it, and flip every bit inside it. Flipping means turning 0 into 1 and 1 into 0.
We are given a permutation of size $2n$. The task is to decide whether we can split the numbers into two disjoint sequences $a$ and $b$, each of length $n$, such that if we repeatedly simulate a specific “two-pointer merge” process starting from the heads of $a$ and $b$…
We are placing a multiset of values into a circular array of rooms. Each room contains exactly one item, and each item is either a regular chest with a reward value or a mimic that immediately stops the run when entered.
We are given a set of numbered discs from 1 to n, where larger numbers represent larger discs. These discs are initially split across m towers, and each tower already has its discs stacked in decreasing order of size from bottom to top.
We are given a string describing a cyclic opponent strategy in a rock-paper-scissors game. The opponent does not adapt; instead, they choose moves according to a fixed circular string. If they start at some position, they follow the string in order and wrap around forever.
We are working on a very large grid of size $2n times 2m$, but we only care about the white cells, those where the sum of coordinates is even. Among these white cells, some are dynamically toggled between available and unavailable across a sequence of updates.
We are given a short string consisting of lowercase letters and question marks. Each question mark can later be replaced by any lowercase letter. After replacements, we want to end up with a string that contains the fixed pattern "abacaba" as a substring exactly once.
We are choosing exactly $n$ flowers from $m$ available types, where each type can be used an unlimited number of times. The value of picking flowers is not linear per flower, instead each type behaves like a diminishing reward stream.
We are given a permutation of numbers from 1 to n, but the real object we care about is not the values themselves, it is their positions. Initially each position i forms a singleton set containing the value a[i].
Three numbers represent the sizes of three piles of stones. The interaction alternates between us and the opponent.
We are given a sequence of numbers, and we are allowed to swap any two positions, but only if those two positions currently form an inversion in the original array. An inversion is simply a pair of indices where the left value is strictly larger than the right value.
Stopped thinking
We are given a grid of integers, but the final goal is not to preserve these values exactly. Instead, we are allowed to only increase values, and we want to transform the grid into a configuration where every positive cell behaves like a “node” whose value equals how many of…
We are given an array and a very specific primitive operation: we can pick any position and rotate a block of three consecutive elements to the right. That means a local triple [x, y, z] becomes [z, x, y].
We are given a collection of books, each with a reading time and two independent preference flags, one for Alice and one for Bob.
We are trying to construct the smallest non-negative integer $x$ such that if we take a short consecutive block of numbers starting at $x$, specifically $x, x+1, dots, x+k$, and sum the digit sums of all of them, the total equals a given target $n$.
We are comparing two different ways of buying the same number of donuts, and for each way we want to know when it becomes strictly cheaper than the other. In the first shop, the price is linear: buying $x$ donuts costs exactly $a cdot x$.
We are given a binary string and two players who alternately remove exactly two adjacent characters from it. Each move deletes a contiguous pair, so the string shrinks by 2 characters each turn.
We are asked to construct an integer array of length n where every element is positive, does not exceed 1000, and satisfies a global restriction on sums: if we pick any three positions (they may coincide), the sum of two chosen elements is never equal to any element of the array.