brain
tamnd's digital brain — notes, problems, research
41650 notes
We are given a circular arrangement of parrots, where each parrot has a numeric “influence radius” derived from its respect level. If a parrot at position i starts speaking at time 0, then at time 1 all parrots within distance ri to its left and right also start speaking.
We are given a multiset of weights, each weight having an integer mass between 1 and 100, but the weights are indistinguishable to us. We do not know which physical item corresponds to which mass, only the full list of masses exists somewhere in our friend’s knowledge.
We are given a tree and we are allowed to remove any subset of its edges. After removals, the tree becomes a forest. On this resulting forest, we consider all possible matchings and focus on those that achieve maximum size.
We are given the multiset of utensils that remained after a banquet and the number of guests who attended. Each guest received several identical “dishes”, and each dish came with a fixed set of utensils.
We are given a single string representing the winner’s handle, and we must print it as a rectangular grid. Each cell of the grid contains either a character from the string or an asterisk.
We are working in a city where movement is allowed only along two types of roads. The first type is the standard integer grid: you can travel freely along any vertical line x = k or horizontal line y = k, and the cost is simply Euclidean distance along those lines, which…
We are given a collection of up to 30,000 integers, each representable in at most 12 bits. Alongside this, we are given many “bitwise machines”, where each machine defines a transformation from two input numbers into one output number.
We are given several independent piles of chips. Each pile has a large initial size, and two players, Alice and Bob, first choose how many chips they will remove per move, denoted by a and b. After these choices, they play a turn-based game on all piles combined.
We are given a collection of integers, each of which is known to be “almost prime structured” in the sense that its number of divisors is very small, between 3 and 5.
We are given a permutation of values placed on a line of positions from 1 to n. A token starts on any chosen position, and two players alternate moving it.
We start with a large square piece of cloth with side length $a$. From one corner, a smaller square of side $b$ is cut out. The remaining cloth is an L-shaped region whose area is simply the area of the big square minus the area of the removed square, so $a^2 - b^2$.
We are given a square chessboard with coordinates from 1 to n in both directions. A queen is fixed at one cell, and it attacks along rows, columns, and diagonals in the usual chess sense.
We are given a sequence of geometric intervals on the number line. Think of each interval as a segment of paint on an infinite ruler. Now instead of working with single intervals, we look at contiguous blocks of these intervals.
We are given two arrays indexed by bitmasks of length n, so each index represents a subset of an n-element universe encoded as a binary number from 0 to 2^n - 1.
Codeforces 1034C: Region Separation
We are given a list of positive integers and are allowed to delete some of them. After deletion, we look at the greatest common divisor of the remaining numbers.
We are given a very large rectangular grid where each cell can be identified by coordinates $(x, y)$. We repeatedly place two chess pieces at a time, but only if the Manhattan distance between the two chosen empty cells is exactly 3.
We are given a collection of straight line segments drawn on the integer grid. Each segment connects two lattice points, but the segment itself may pass through many other lattice points depending on its slope.
We start with a directed acyclic graph. Some vertices have no incoming edges, these are called sources, and some have no outgoing edges, these are sinks. The graph is guaranteed to have the same number of sources and sinks, and this number is at most 20.
We are looking at integers through the lens of their prime factorizations. Every number (x ge 2) can be uniquely written as a product of primes, and we focus on the exponents in that decomposition.
We are working with a notion of “sparse” numbers in base 10. A number is considered valid if, when you write it in decimal, at most three of its digits are non-zero.
The figure is a broken line made from points at integer x-coordinates from 0 to 2n. Initially every point lies on the x-axis, so every y-coordinate is zero. The only way to modify the shape is to pick an odd-indexed point and increase its height by one unit per move.
We are given a base string and then asked to answer many independent games played on substrings of it. Each game starts from a chosen segment of the string, and two players alternate turns.
We are given a fixed base string s. Each query selects a contiguous segment s[l..r] and a comparison string x. From that segment, we consider every distinct substring, meaning every string formed by choosing a start i and end j with l ≤ i ≤ j ≤ r.
Codeforces 1037A: Packets
We are given two binary strings of equal length. Think of them as two rows of switches, where each position is either on or off.
We are given a tree with vertices labeled from 1 to n, and a proposed ordering of all vertices. The task is to decide whether this ordering could arise from running a breadth-first search starting at vertex 1, under some valid choice of adjacency ordering.
We are given a list of integers and a target value s. The goal is not to make all elements equal to s, but only to ensure that after we sort the array, the middle element becomes exactly s. Since the length is odd, there is a single well-defined median position.
We are given a string made of uppercase letters, but only from the first $k$ letters of the alphabet. The task is not to rearrange or modify the string, but to select a subsequence of characters while preserving order.
We are given a binary string s and a length n. We want to construct all binary strings t of length n. Each such t is treated as circular, meaning its end wraps back to its beginning.
Each block can be viewed as a weighted undirected edge between two colors, where each endpoint is one of two possible colors depending on orientation.
We are given a line of slimes, each carrying an integer value, and we repeatedly perform an operation where one slime absorbs an adjacent slime. If a slime with value $x$ eats a neighbor with value $y$, that neighbor disappears and the eater’s value becomes $x - y$.
We are given the integers from 1 to n, and we must split them into two non-empty groups so that every number is used exactly once. After splitting, we compute the sum of numbers in each group and look at the greatest common divisor of these two sums.
We are given a sequence of photo intervals on a very large number line. Each photo covers a fixed window of length w, starting at position xi, so photo i covers [xi, xi + w - 1].
We are dealing with a single moving target on a very large numbered line of stations from 1 to n. At any moment there is exactly one station where the train is located, but after every query the train is allowed to move up to k stations left or right, and this movement is…
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 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 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 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.