brain
tamnd's digital brain — notes, problems, research
41513 notes
Each dog-walking job can be seen as an item that Alice may choose at most once. A job comes with two pieces of information: a 7-day requirement pattern and a payment value. The pattern is a length-7 binary vector indicating on which days of the week the dog must be walked.
We are given a circular arrangement of $N$ corgis. Each corgi carries a very small “color set”, either one color or two colors, both represented by lowercase letters. The circle means that the first and last corgi are also adjacent.
We are given a rooted tree with node 1 acting as the root of a “proof structure”. Each node represents a subgoal, and leaves are the only things that can be removed during a verification step.
We are given a single string representing a long sequence of genetic markers, where each character is one of 26 possible letters. Our task is to count how many substrings are “valid palindromic gene segments” under an additional biological constraint.
We are given a one-dimensional terrain described by an array of elevations. Each index represents a location along a path, and each location has a height value.
We are given a tree with $N$ nodes, where each node represents a treat with a fixed tastiness value. Two players, Bob and Charlie, repeatedly remove two leaves from the current tree. For each chosen pair of leaves, Charlie picks one to eat and Bob gets the other.
The park is a huge grid where you start at the bottom-left corner and want to reach the top-right corner. Movement is not explicitly constrained, but geometrically the only thing that matters is whether there exists a continuous path from start to exit that avoids all…
Each friend brings a potential job. A job is defined by two things: the set of days in a fixed 7-day week when Alice must walk that friend’s dog, and the payment for completing that job for the whole week.
We are given a circular arrangement of corgis, where each corgi has a small label describing its fur colors. Each label is either a single color or a pair of colors. We want to partition this circle into contiguous segments.
We are given a rooted tree with node 1 acting as a special root representing the final goal, while every other node represents a subgoal derived from it.
The grid describes a dog park laid out as a rectangle of cells. Each cell is either empty, marked by a dot, or contains a single digit from 1 to 9 representing a dog’s height at that position.
We are given a single string of length up to 50,000 consisting of lowercase English letters. Each position represents a gene base, and we are asked to examine every contiguous substring and count those substrings that satisfy two conditions at the same time.
We are given a list of numbers and we must split it into two groups that do not overlap and together contain every element. Each group must contain at least two elements.
We are given a sequence of integers laid out in a single line, and we are asked to find a contiguous segment of this sequence that uses at most three distinct values, while being as long as possible. Think of the array as a timeline of trades in Numerica.
We are given a fixed array of integers and many independent range queries. Each query picks a contiguous segment from index $l$ to $r$, and a modulus value $x$.
We start from a single state described by an ordered pair of positive integers, initially (1, 1). Each move changes the state in a very structured way: either the first component absorbs the second, or the second absorbs the first.
We are given a sequence of length $N$ containing only values $0,1,2,3$. All elements start on board $A$, and we must move them to board $B$ by repeatedly taking the front of $A$ and appending it to $B$.
We are given a collection of line segments on a number line. The key structural constraint is that any two segments are either disjoint or one fully contains the other.
There are many students, but only a relatively small number of them are explicitly connected by “must-stay-together” relationships. These relationships form an undirected graph over students.
We are given a summary of a football team’s season. Each team is described by five numbers: how many matches they won, drew, and lost, and the total goals they scored and conceded across all matches.
We are given a directed weighted graph representing a road network between cities. From a fixed starting city $s$, we want to reach a target city $t$. The graph already contains $M$ roads, and additionally there are $K$ optional roads.
We are given an $n times n$ grid where each cell represents one of three terrain types: usable planting land, a water source, or unusable blocked land. We are asked to count how many horizontal strips of height exactly two rows are “valid gardening strips”.
Each test case gives two arrays of the same length. You process positions from left to right. At position i, you start with the value a[i] and are allowed to optionally multiply it by any subset of the earlier values a[1] ... a[i-1].
We are given two sequences of the same length. At each position we must pick exactly one value, either from the first sequence or from the second, and sum up all chosen values.
Each candidate can be represented purely by which of the $m$ minority groups they belong to. So every applicant corresponds to a subset of a set of size $m$, and the pool contains all $2^m$ possible subsets.
We are given a multiset of positive integers. From this set we want to count how many integers $x$ have the following property: if we take $x$ together with any two numbers from the given set, those three values can always form a non-degenerate triangle.
We are given a sequence of cities in a fixed travel order from 1 to n. Each city has a value a[i], and a parameter c that affects one of the scoring modes.
We are given an initial string and a target string of the same length. The only allowed operation takes a parameter $x$, splits the string into a prefix of length $n-x$ and a suffix of length $x$, reverses that suffix, and moves it to the front, leaving the prefix behind it…
We are given a set of selected cells on an infinite hexagonal grid. Each cell has integer coordinates, and adjacency is defined by sharing a full edge. The grid has the additional geometric property that every grid vertex is incident to exactly three cells.
We start with an array that is initially a permutation of length $n$, specifically $[1,2,dots,n]$. A sequence of $m$ operations is applied in order. Each operation first swaps two positions $xp$ and $yp$, then performs a cyclic right rotation of the entire array.
We are given a set of points in the plane, with the guarantee that no three lie on a single line. We imagine a process that starts from one point together with a directed line passing through it.
We are simulating a group of people moving on an infinite integer grid. Each person appears at a given time, starts at a fixed coordinate, and initially faces north. Time advances in discrete minutes, and every active person performs two actions in a fixed order each minute.
We are given a tree with values on its vertices. A player chooses any two vertices as endpoints of a simple path and walks along the unique path between them. The score of a path is not a simple sum or maximum.
We are given a rectangular grid where every cell starts uncolored. We must output an order in which to color all cells exactly once.
We are working on an $n times n$ grid that starts completely white. We must paint exactly $k$ cells black, but the final pattern must look unchanged after a 90-degree clockwise rotation.
We are given a complete undirected graph on vertices labeled from 1 to n. Every pair of distinct vertices i and j is connected, and the weight of that edge is defined as gcd(i, j).
We are given a rooted tree with vertex 1 as the root. Each vertex has a value called “aliveness”, which is defined recursively from the leaves upward. For any vertex, we first compute a quantity $S$, which is the sum of aliveness of all its children plus one extra unit.
We are given two integers $x$ and $y$, and instead of comparing them in the usual increasing order of natural numbers, we compare them in a very specific permutation of the positive integers called the Sharkovskii ordering. This ordering is constructed in layers.
We are given an array that represents a permutation-like document of essays, where position and value both matter. The value at index i is the label of the essay currently placed there.
We are given two integer arrays of equal length. The first array is a starting configuration, and the second array is the target configuration. We are allowed to perform a sequence of exactly n operations, where each operation is defined by choosing an index i.
We are given a binary array and a second array that describes target segment sizes. If we take the binary array and compress it into maximal runs of equal values, we get a sequence of block lengths. For example, a sequence like 1 1 0 0 0 1 becomes blocks of lengths [2, 3, 1].
We are given $n$ independent dancers placed somewhere on an integer line. Each dancer starts at some integer coordinate, and then simultaneously moves one step either left or right, each direction chosen independently with probability $1/2$.
There are four players, and each player holds exactly two cards. Each card has a rank and a suit. In every game, each player ultimately plays exactly one of their two cards in the first round, and the remaining cards form the second round. The play proceeds in two tricks.
The task can be understood as a shortest path problem on a directed weighted graph, but with an extra layer of state tracking. Each node in the graph can be visited multiple times depending on how many special “bad” nodes have been passed so far.
We are given an array where some positions are “locked” in the sense that elements at those indices are fixed barriers. These locked indices split the array into consecutive regions.
We are given two players, each of whom distributes a fixed number of Rock, Paper, and Scissors tokens. One player has counts for Rock, Paper, and Scissors, and the other player has their own counts of the same three types.
We are maintaining an infinite binary string indexed by positive integers. Initially, every position behaves as if it contains a zero, and then we are allowed to repeatedly overwrite segments of this infinite string.
We are given multiple queries, each query provides two positive integers, which we can think of as the dimensions of a rectangle grid or two independent ranges.
We are given a number of test cases. For each test case, we receive a string of length $n$. The task is to transform the string in a very specific way and decide which of three fixed outputs it matches after processing. The processing rule is simple but strict.
We are given an array of real numbers and many range queries. For each query, we take the subarray defined by its endpoints, compute its arithmetic mean, and then measure how far the elements deviate from this mean using the average of absolute differences.
We are given a grid formed by unit squares, with height $N$ and width $M$. Inside this grid, we want to count how many axis-aligned squares exist, considering all possible sizes.
Working
We are given a tree where each node represents a moment in time, and each node carries a non-negative damage value. A subset of nodes is marked as special, and we must start from node 1 and eventually visit all of these special nodes in any order.
Two players start with two equal-sized collections of numbers. These numbers are not directly compared; instead, they are gradually “decomposed” during a game.
We are given an array of integers and an operation that aggressively reshapes it. In one move, we pick an index i, and then we add a[i] to every other element in the array, leaving a[i] unchanged.
We are given a square grid of size n by n that must be filled with zeros and ones. Each cell represents whether we place a black square (1) or leave it white (0).
We are given a long string of decimal digits, and we need to count how many of its contiguous substrings represent numbers divisible by 11 when interpreted as integers.
We are given an $N times M$ grid of lowercase letters. We are allowed to repeatedly perform a very specific operation: pick any cell $(i, j)$, choose a positive integer $k$, and copy its character to either $(i-k, j-k)$ or $(i-k, j+k)$, provided those target cells stay inside…
Working
We are simulating a very simple random process repeated many times. We start with an array of size $n$, initially all zeros. Then we perform $m$ independent operations, and each operation picks one of the $n$ positions uniformly at random and increments it by one.
We are given two strings of equal length. At every position, we can look at the pair of characters formed by taking one character from the first string and one from the second string.
The problem describes a volcanic pit represented as an $n times m$ grid where each cell stores how much higher that point is compared to the magma level at time zero. Cells with value zero are already at magma level, meaning they are submerged immediately.
We are given an integer $m$ and a linear transformation on integer grid points of the form $$T(i, j) = (a i + b j,; c i + d j),$$ where $a, b, c, d$ are integers in the range $[0, m-1]$. The plane is also partitioned into $m times m$ blocks.
Codeforces 105018M: Colour the Banners
We are given a multiset of positive integers, stored as an array. Two players alternate turns, starting with the first player.
We are given an array indexed from 1 to n with a special multiplicative structure, but that structure is not what we directly compute with. Instead, the process repeatedly transforms the array using divisor aggregation.
We are asked to construct any integer array such that its prefix sums and suffix sums satisfy four extremal conditions simultaneously. For a chosen array, consider the running prefix sum sequence that starts from zero and accumulates elements from left to right.
We are given a string that consists only of opening and closing brackets. The string is guaranteed to be “balanced” in the classical sense, meaning it can be turned into a valid arithmetic expression if we insert plus signs and ones between characters.
We are given a circular arrangement of labeled faces. Each position contains a string label describing the face, and exactly one position is marked with the label "Jaqen", which represents the current position of the traveler.
We start with a number R = 1 and repeatedly multiply it by uniformly random integers from 0 to n-1. After each multiplication we check whether the current value is divisible by n.
We are given a long sequence of real numbers between 0 and 1, and a fixed number of rounds $k$. We traverse the sequence from left to right exactly once, and we cut it into $k$ consecutive parts.
We are playing a repeated interactive betting game against a dealer. In each round, both sides build a score starting from zero by repeatedly drawing random values uniformly from the interval $[0,1]$. On your turn you decide whether to draw another random value or stop.
We are given an $n times n$ grid and several rooks placed on distinct cells. A rook controls every cell in its row and every cell in its column. A cell is considered “safe” only if no rook shares its row or column. The operation allowed is removing rooks from the board.
We are given a binary string and asked to compute, for every prefix ending at position i, how well that prefix can be matched by a previous prefix of the string under a very strict rule. For a fixed position i, we try all possible lengths j from 0 up to i-1.
We are trying to construct two positive integers $a$ and $b$, with $a le b$, under a very specific arithmetic constraint involving their greatest common divisor and least common multiple.
Each rectangle in the input is fully determined by its bottom-left corner and its top-right corner. Because all rectangles start in the non-negative quadrant, the origin (0, 0) acts as a natural reference point. A query gives a point (x, y).
We are asked to determine whether a given integer $x$ can be expressed as a sum of a contiguous block of positive integers starting from some $l$ and ending at $r$.
We are given a rooted tree where each node is painted either black or white. The tree structure defines parent-child relationships with node 1 as the root. For each query node $u$, we look only inside the subtree of $u$, meaning all nodes reachable by moving downward from $u$.
Two long numbers are given as strings, and we are allowed to modify them digit by digit until they become identical. The catch is that digits are not treated as abstract values, but as seven-segment displays made of small “dashes”.
The problem gives a rooted tree where each node stores an integer value. The tree is fixed, but two operations are performed on it repeatedly. One operation overwrites every node in a chosen subtree with the same value.
Each test case describes a park with several trees, where each tree has a fixed height. Amr chooses one tree to hide behind. Whether he gets caught depends only on a comparison between his height and the height of that chosen tree.
We are given several independent scenarios. In each scenario there are $n$ cookies in total, among which $a$ are large. Donia wants to eat some cookies, but she must avoid getting caught. The rule is that after she eats cookies, at least $m$ cookies must still remain uneaten.
We are given two strings of equal length. We are allowed to modify characters in the first string freely, but each modification costs one operation. After modifying, we do not compare it directly to the second string.
We are given an array of positive integers. The array evolves through a sequence of queries, and each query allows a limited number of identical operations called “beautiful decreases”. A single beautiful decrease works on one contiguous segment of the array.
We are given a sequence of instructions that transform a single integer variable starting from 1. Each instruction either doubles the current value or halves it using floor division.
Each player in this game maintains a personal list of other players they would vote against if those players were put on trial.
We are given multiple independent scenarios where a person has a fixed amount of money and wants to buy a drink with a known price. For each scenario, we need to determine how much additional money is required so that the available amount is enough to cover the cost.
We are given a single queue of customers already lined up at a shop. Each customer in the queue requires a known amount of time to be served, and the shop processes them strictly one after another.
We are given two arrays of integers of the same length. We are allowed to repeatedly transform elements, but only in one direction: each operation replaces a value by its largest proper divisor, meaning the greatest divisor strictly smaller than the number itself.
We are given a permutation of size $N$. Then we are given a sequence of $Q$ operations, each operation taking a segment $[l, r]$ and rotating it cyclically to the right by one position. After all $Q$ operations are applied, we obtain a final permutation.
We are given a vertical stack of trucks, each truck contributing a fixed length segment. Initially, the stack is perfectly aligned on the y-axis starting from the origin, so the head of the top truck ends up at a point whose y-coordinate is the sum of all truck lengths and…
We are given a string consisting only of digits 1 and 2, and we are allowed to modify it using a limited budget of coins.
We are given a tree representing a metro network where every station is connected and there is exactly one simple path between any two stations. Two people matter: Psyduck, who starts at a uniformly chosen station, and Iron Bundle, who is located at some station.
We are given a binary array that changes over time through two kinds of operations. One operation flips every value in a range, turning zeros into ones and ones into zeros. The other operation asks us to look at a subarray and play a deterministic removal game on it.
We are given two length-N sequences, and we use them to define an N by N matrix where every entry is formed by multiplying a row weight from the first sequence with a column weight from the second sequence.
We are given a set of trucks placed on a number line, each with a starting position and a constant velocity. Every truck moves in a straight line, and whenever two trucks meet at the same point at the same time, they collide.
We are given a sequence of scheduled trips, each with a start time and an end time. Chad performs these trips in the given order. The key mechanic is that if a trip starts while he is still busy finishing a previous delayed trip, it does not start on its original time.
We are given several independent test cases. In each test case, there is a list of distinct positive integers representing city populations.
We are looking at a deterministic process on a directed graph where every city has exactly one outgoing edge defined by doubling the index modulo $N$. Starting from city $1$, the car repeatedly follows this rule, producing a sequence of visited cities.
We are given a complete directed graph on up to 300 vertices, where every ordered pair of vertices has a weight, which can be positive, zero, or negative.