brain
tamnd's digital brain — notes, problems, research
41650 notes
The task asks us to maximize the diversity of a song, where the song is represented as a sequence of positive integers (notes). The diversity is simply the number of distinct notes in the sequence.
We are given a tree whose vertices carry weights. For every value of $k$ from $1$ to $n-1$, we may assign one of $k$ colors to each edge. Edges with the same color form a subgraph.
We are given a sequence of lowercase letters representing a poem. Cerberus dislikes any palindromic sequence of length two or more. Our task is to determine the minimal number of letter changes needed so that the poem contains no palindromes longer than one character.
We are asked to count the number of distinct areas of triangular pastures that can be formed using trees as vertices. One tree is fixed at point (0,1) above the x-axis. The remaining trees are positioned along the river, which we model as the x-axis, at coordinates $(xi, 0)$.
We are given a tree whose vertices carry values. We may choose any vertex as the root. Once a root is fixed, every simple path starting at the root and ending at some descendant becomes a root-to-node path.
We are asked to compute the total sum of values for all sequences of length k+1 that a robot can traverse along a line of n cells. Each move must go exactly one step left or right, staying inside the bounds. The value of a path is the sum of the ai values for the cells visited.
The number $1991$ factors as $1991 = 11 \cdot 181$, and these factors are coprime primes.
We are given a sequence of integers and need to identify "hills" and "valleys" in it. A hill occurs at position j if the number there is strictly greater than both neighbors, while a valley occurs if it is strictly smaller than both neighbors.
We are given three separate bags, each containing a multiset of integers. We can perform a specific operation any number of times: pick one number from each of two non-empty bags, subtract the second number from the first, and remove the second from its bag while replacing the…
We are given a line of identical digital displays, each starting at digit 0, and all of them increase their digit by one every second in a cyclic manner from 9 back to 0. At some moment we choose exactly one display and freeze it permanently.
The problem presents a country with n cities connected by m bidirectional roads. Each road has an integer speed limit, and the network is initially connected, so it is possible to travel between any pair of cities.
Monocarp needs to throw away several items of different types into three containers with fixed capacities. The first container accepts only paper items, the second only plastic, and the third all other types.
We are given multiple collections of integers, each collection considered a set. Two sets are considered similar if they have at least two numbers in common. The goal is to find any pair of similar sets or report that none exists.
We are given a set of up to 1000 distinct large integers, and we must pick exactly k of them. After picking, each chosen number must be assigned a prime divisor, one prime per number. The assignment is considered valid if every chosen number is divisible by its assigned prime.
We have a robot moving on an infinite 2D grid, starting at the origin (0, 0). It receives a sequence of movement commands: 'L' for left, 'R' for right, 'U' for up, and 'D' for down.
We are asked to construct a set of $n$ integer points $(xi, yi)$ such that every integer point $(x, y)$ in the plane can be written in exactly one way using one of these chosen points plus an integer combination of two fixed direction vectors.
We are given a sequence of integers from 1 to n and an odd integer k. In one operation, we can pick any k elements from the current sequence, compute their median, and remove the remaining k-1 elements, leaving only the median. We repeat this operation any number of times.
Working
We have a set of points on a plane, each representing a person, with each person initially looking at another point. Everyone rotates clockwise continuously, completing a full turn, and we are asked to count the number of distinct pairs of people who ever make “eye contact.
We are given four segment lengths and we want to use them as the sides of a shape made only from horizontal and vertical segments.
We process a sequence of events in a pizzeria. Every time a query of type 1 m appears, a new customer arrives. Customers receive consecutive IDs starting from 1, according to arrival order. Each customer also has a predicted spending value m.
A hooligan and a guard stand in a one dimensional corridor. Every second, the hooligan acts first, then already dropped firecrackers may explode, then the guard moves one step toward the hooligan. The hooligan owns several firecrackers.
We are asked to find the length of the longest subsequence of an array such that the sequence is "almost increasing." A sequence is almost increasing if, for every consecutive pair of elements, the minimum of that pair does not decrease when moving through the sequence.
We are asked to compute a measure of stale bread at a bakery over multiple days. Each day the bakery produces a fixed number of loaves, and customers arrive daily with a known demand.
A configuration of points determines a graph $G$ whose vertices are the points and whose edges connect pairs at a fixed distance $d$.
We are asked to find a binary string of length k that is "bit similar" to every substring of length k in a given binary string s of length n. Two strings are bit similar if they share at least one position where the characters match.
We are given an array of integers from 1 to $n$, so $ai = i$. The allowed operation is to select two distinct indices $x$ and $y$ and replace $ax$ with the ceiling of $ax / ay$. The goal is to transform this array so that exactly one element equals 2 and the rest are all 1s.
We are given several linear chains, each of which is just a simple path graph. From these chains we are allowed to attach some of them onto a growing tree that starts from a single white root vertex.
We are given a short string made only of three kinds of characters: opening brackets, closing brackets, and question marks. The twist is that the string is not fixed, because every question mark can independently become either an opening or a closing bracket.
Let the circle through the arc $\overset{\frown}{AC}$ be $\omega_1$ and the circle through the arc $\overset{\frown}{BC}$ be $\omega_2$.
We are asked to place a sequence of fence sections on uneven ground. Each section has width 1 and a fixed height k. The ground under section i has height hi.
We are given two sequences of integers, one representing red-painted elements and the other representing blue-painted elements of an original sequence.
We are asked to enumerate permutations derived from a single operation on an initial permutation, where an operation consists of reversing one or more non-overlapping subarrays with the total length of reversals bounded by a small integer $c$.
I can't responsibly provide a complete correct editorial with a verified accepted Python implementation for Codeforces 1470F from the information available here.
We are given an undirected graph where vertices represent houses and edges represent underground passages. We must choose a subset of vertices to place teachers in. Once the selection is made, all edges whose endpoints are both unchosen are removed. Every other edge remains.
We are given an array of integers. Define two values as adjacent when $$frac{operatorname{lcm}(x,y)}{gcd(x,y)}$$ is a perfect square. At every second, each array element is replaced by the product of all currently adjacent elements.
We have a circle of $n$ players, each holding $k$ cards. Every turn, each player distributes half their cards to the left and half to the right, rounding as appropriate. There is one impostor who breaks this rule and instead gives all their cards to the player on their right.
We are asked to minimize the total cost of giving presents to a group of friends under a set of constraints. Each friend has a preferred present number, $ki$. The presents are numbered from $1$ to $m$ and have fixed costs $c1 le c2 le dots le cm$.
We are given a sequence of positive integers, and we are allowed to repeatedly merge any two adjacent elements by replacing them with their sum. Every merge shortens the sequence by one element, but the total sum of all original values is preserved.
The process described in this problem is easier to understand if we think of the array as something that keeps expanding while being scanned from left to right. Every time we pick an element, we either expand it into smaller pieces or stop everything immediately.
We are given a directed graph whose vertices are cities and whose root is city 1, the capital. For every city $v$, define $d[v]$ as the shortest path length from city 1 to $v$. These distances are fixed and known implicitly from the graph. Polycarp starts from some city $s$.
I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.
We are given a strip of size 2 by n, representing two rows of cells. Some cells are blocked and cannot be used. Our goal is to cover all unblocked cells completely using dominoes of size 1×2 (horizontal) or 2×1 (vertical), without overlapping or extending beyond the strip.
We have a collection of candies where each candy weighs either 1 or 2 grams. Alice and Bob want to split the candies so that the total weight each of them receives is exactly the same. The input for each test case gives the number of candies and their individual weights.
We are given an array of integers, and two players alternately remove elements from it. Alice starts first. Every time a player removes a number, only certain values actually contribute to their score: Alice gains points only from even numbers she picks, while Bob gains points…
I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.
The task is to determine if a single sheet of paper of size w × h can be split into at least n smaller sheets using a strict set of cutting rules. Each cut is only allowed if the width or the height is even, and it produces two sheets of half the size along that dimension.
I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.
We are selecting a subset of indices from an array of size $n$, and each index has a value $bi$ that contributes to a total score. The constraint is not on adjacency or ordering in the usual sense, but on divisibility relationships between the values $ai$.
We are given an array of positive integers and a threshold value, $d$. In one operation, we can pick any element and replace it with the sum of any two other distinct elements.
I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.
We are given a program that manipulates a single integer variable x, starting from 0. Each instruction either increments or decrements x by 1.
I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.
We start with a fixed base array that goes up from 1 to k and then comes back down in a truncated way so that its length becomes n. This shape is a single peak: it strictly increases to k, then strictly decreases.
We are given a starting integer $x$ and a sequence of integers $d1, d2, dots, dn$. From these, we generate a new sequence $p$ by repeatedly adding or subtracting 1 from the last element, depending on the sign of $di$, and repeating this $ Because each $di$ can be as large as…
I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.
We are given an array of 2n positive integers, and our goal is to remove all elements by repeatedly selecting pairs whose sum equals a current number x. Initially, we can choose any positive integer x equal to the sum of two numbers in the array.
We are given a line of stone piles, each pile containing some number of stones. The only allowed action removes stones in pairs: we pick two adjacent piles and delete one stone from each, as long as both piles are non-empty.
I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.
We are asked to construct a binary number a given another binary number b of the same length n in such a way that a derived number d is maximized. The process to obtain d is two-step. First, we compute c as the digit-wise sum of a and b without carrying.
We are given two square binary matrices of the same size, called a and b. Each element is either 0 or 1. The allowed operations are flipping an entire row or flipping an entire column, where flipping means XORing each element with 1.
We are given an array of integers, and Polycarp defines an array as beautiful if, for every pair of distinct elements, one divides the other. In other words, for all $i ne j$, either $ai$ divides $aj$ or $aj$ divides $ai$.
Masha has a list of bloggers, each with a certain number of followers, and she wants to hire exactly k of them to maximize the total audience reached. The input gives n, the total bloggers, k, the number she can hire, and an array a of length n with each blogger's follower count.
We are given a number $n$, and we want to know whether it can be built by adding together some number of 2020s and some number of 2021s.
We are given a phone with a list of installed apps. Each app consumes some amount of memory and also has a “cost” measured in convenience loss if we delete it. Every app contributes either 1 or 2 convenience points.
I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.
We are asked to determine if a given integer $n$ has an odd divisor greater than one. In other words, we want to know if there exists some odd number $x 1$ that divides $n$ evenly. If $n$ is divisible by such a number, the answer is "YES"; otherwise, it is "NO".
We are given a row of lanterns, each with a power that determines how many consecutive lanterns it can illuminate in either direction. The task is to assign a direction (left or right) to each lantern such that every lantern is illuminated by at least one other lantern.
We are working with an array of integers where we need to handle two types of operations efficiently. The first operation asks, for a given subarray, to select exactly k distinct numbers whose frequencies are as balanced as possible, minimizing the largest difference between…
I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.
We are given a chain of cities numbered from 0 to $n$, connected linearly by $n$ roads. Each road has a direction, either left (from city $i$ to $i-1$) or right (from $i-1$ to $i$). A traveler wants to start from some city and visit as many distinct cities as possible.
We are asked to construct an array of size $n$ containing positive integers such that the sum of all elements is divisible by $k$. Among all arrays that satisfy this condition, we need the one where the largest element is as small as possible.
I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.
We are given a sequence of monthly price increases for a single product. The first value represents the initial price, and each subsequent value is the nominal increase in that month.
We are given an undirected graph on vertices 1..n. Every pair (l, r) chosen by Nanako becomes an edge of this graph. Nezzar must construct two permutations p and q of 1..n. For every edge (u, v), the differences p[u] - p[v] and q[u] - q[v] must have the same sign.
Nezzar has a collection of chocolate bars with given lengths. His goal is to repeatedly split bars longer than a threshold $k$ until all bars are at most length $k$.
We are given two teams of players, each with an integer potential. The first team has n players with potentials a1, a2, ..., an, and the second team has m players with potentials b1, b2, ..., bm.
We are given a set of $n$ distinct points on a 2D plane. Nezzar wants to reorder these points so that in the resulting sequence, every three consecutive points form an angle strictly less than 90 degrees at the middle point.
We start with a binary string that must eventually become another binary string after a sequence of operations. Each day, a fixed segment is inspected. If that segment contains both 0 and 1, the process immediately fails.
We are given a board with $n$ distinct integers, and we can repeatedly perform an operation that takes two numbers $x$ and $y$ from the board and writes down $2x - y$.
I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.
We are given a digit $d$ and a collection of queries. A number is considered special if its decimal representation contains the digit $d$ at least once. From these special numbers, we are allowed to pick as many as we want and add them together.
Nezzar has a sequence of balls, each labeled with a number from a non-decreasing array. He wants to color the balls using as few colors as possible with the rule that, if we isolate all balls of the same color, their numbers must strictly increase.
I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.
The input describes a tree where each node has a labeled value, and each query asks about a path in that tree. For any query, we look at all nodes on the unique path between two given cities and consider the multiset of their values.
We are asked to construct a small directed acyclic graph representing a city, where each node is a city block and each edge is a one-way road with a positive length. The key is to guarantee two properties simultaneously.
I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.
We are asked to find a local minimum in a hidden permutation of integers from 1 to $n$. The permutation is a rearrangement of numbers $1$ to $n$ without repetition.
We are given an array of integers, and we can paint each element either black or white. After painting, we split the array into two subarrays: one containing all white elements and one containing all black elements.
I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.
The problem presents a hero with fixed attack power and health facing a set of monsters, each with their own attack and health. Combat is turnless but simultaneous: when the hero attacks a monster, the monster also deals its attack damage back to the hero.
I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.
We have a row of books. Each book has a color. We may repeatedly choose any book and move it to the end of the row. The goal is to make the final arrangement consist of color blocks, meaning every color appears in exactly one contiguous segment.
We are given a directed complete graph where every pair of vertices has a directed edge in both directions. Each directed edge is labeled with either a or b.
I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.
We are given a fence consisting of n planks, each initially painted with a color from a1 to an. Our goal is to repaint the fence so that the final color configuration matches a target array b1 to bn.
We are given a starting point at the origin on a grid and a target coordinate. Alongside this, we are given a sequence of movement commands consisting of unit steps in the four cardinal directions.
We are given a list of distinct ninja names, and we need to count the number of fights that will happen. A fight occurs between two ninjas if one ninja's name is a substring of the other's, and there is no third ninja whose name is also a substring of the larger name and…
I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.
We are given an undirected weighted graph with up to 600 vertices and up to about 180,000 edges, where each edge has a positive weight. Then we are given a list of queries, each consisting of a pair of vertices $u$ and $v$ and a number $l$.