brain
tamnd's digital brain — notes, problems, research
43815 notes
We are given a set of noisy points in the plane that lie close to a small number of circles, or rings. Each ring has a center and a radius, and each sampled point deviates slightly from the exact circumference.
The problem gives us a function $H(x, y) = x^2 + 2xy + x + 1$, and a positive integer $r$. We need to determine whether there exists a pair of positive integers $(x, y)$ such that $H(x, y) = r$.
The galaxy is a small graph of planets connected by wormholes, where distance between planets is measured as the minimum number of edges in this graph. On top of this infrastructure, there are two kinds of actors: empire ships and rebel bases.
We are given a binary string y of length n. We want to count how many cyclic shift amounts k produce a situation where we can reconstruct some binary string x such that if we take x and XOR it with a circular right shift of itself by k, we obtain exactly y.
We are given a sequence of integers that may not be ordered, and we are asked to identify a single element whose removal allows the remaining numbers to form an arithmetic progression.
We are asked to help a group of friends pick exactly two pizzas so that the maximum number of friends are satisfied with the choice.
We are given a sequence of students, each associated with a fixed amount of time they would spend if they successfully pass their exam.
The task is to verify whether a typed word t could plausibly result from pressing the keys of a word s on a keyboard that occasionally repeats letters. Each letter in s must appear in order in t, but it may appear one or more times consecutively.
We are given a long binary string a and a shorter or equal-length binary string b. We slide b across every possible window of a of the same length, and for each position we compare the two strings character by character.
We are given a string s representing a sequence of letters available in a shop, arranged from left to right. Each customer (friend) wants to buy letters to form their name, but they can only purchase a prefix of the shop letters.
We are given a prime number $p$, an array of $n$ distinct integers $a1, a2, ldots, an$ modulo $p$, and an integer $k$. Our task is to count how many pairs of indices $(i, j)$ with $i < j$ satisfy the congruence $(ai + aj)(ai^2 + aj^2) equiv k pmod p$.
We start with a collection of balloons split across $k$ colors. Each color has some initial count, and the total number of balloons is at most one million.
We are given a tree of $n$ nodes where initially every edge has a value of 0. We can perform operations that select any two distinct leaf nodes and add a real number $x$ to every edge along the unique path connecting those two leaves.
We are given a binary string, which is a sequence of characters containing only 0 and 1. A string is defined as good if the count of zeros differs from the count of ones.
We are given a multiset of numbers and asked whether we can place all of them around a circle so that every element is strictly smaller than the sum of its two adjacent elements. The adjacency is circular, so the first and last elements are also neighbors.
We are asked to generate a set of possible passwords under very specific rules. The lock accepts integers between 0 and m-1.
We are given a collection of piles of stones, each pile containing a non-negative integer number of stones. Two players take turns removing exactly one stone from a pile. Tokitsukaze goes first.
We are given exactly three mahjong tiles. Each tile consists of a number from 1 to 9 and a suit, where the suit is one of m, p, or s. A winning hand in this simplified game only requires the existence of a single mentsu.
We are given a set of points on an infinite grid. Each point represents a building site that must eventually be occupied by a skyscraper. We must decide an order to construct these skyscrapers one by one. Two constraints govern whether a building step is valid.
We are asked to calculate the expected number of crosswords Adilbek can fully solve in a fixed amount of time, given that each crossword takes either ti or ti + 1 seconds independently with equal probability.
We are given three strings s, t, and p. We can repeatedly take any character from p and insert it anywhere in s. The goal is to determine if, after some sequence of such insertions, s can become exactly equal to t.
We are given a list of integers, and we repeatedly apply a digit interleaving operation on every ordered pair of numbers in the list, including pairs where both elements are the same.
We are given two horizontal lines of students, each line containing the same number of people. Each student has a height, and we want to build a team by selecting students from these two rows under a strict ordering rule: once we start selecting from left to right, we can…
Each query gives three piles of candies. Alice must take one whole pile, Bob must take one of the remaining piles, and the last pile can be split arbitrarily between them.
We are given a non-decreasing array and asked to split it into exactly $k$ contiguous parts. Each part contributes a cost equal to the difference between its largest and smallest element, and since the array is sorted, this is simply the difference between its last and first…
We are given a list of integers and must split it into two non-empty groups. The requirement is not about sums or sizes, but about multiplicative structure: in each group, if you take the greatest common divisor of all its elements, the result must be exactly one.
We are given a sequence of daily rainfall amounts over the summer, and we need to find the earliest day that is “not-so-rainy.
We are given a sequence of words forming a sentence, and the task is to compress them into a single string by merging them left to right.
In Block Adventure, we have a row of columns with different heights. The player starts on the first column and must reach the last one.
The corridor is essentially two separate circular rings placed one inside the other. The inner ring is split into n equal rooms arranged in a cycle, and the outer ring is split into m equal rooms arranged in another cycle.
We are given a small chessboard and two knights placed on it. One knight is white and moves first, the other is black. On each turn, a player moves their own knight using standard knight moves. The interaction continues until one side wins or 350 moves are reached.
Each student answers a multiple-choice test with $m$ questions, where each question has five possible options. We are given the full answer sheet of every student, but the correct answers are unknown.
We are asked to construct strings made only of two characters, say A and B, where the total number of A’s is fixed to a and the total number of B’s is fixed to b.
Polycarp is a freelancer with an initial rating r. He has a list of projects, each project defined by two numbers: the minimum rating required to start it, and the rating change after completion, which could be positive or negative.
We are given a set of boxers, each with a positive integer weight. Each boxer can adjust their weight by at most 1, either up or down, but the weight must remain strictly positive.
We are given 4n sticks. Every rectangle requires four sticks: two sticks for one side length and two sticks for the other side length. Every stick must be used exactly once. The goal is to split all sticks into exactly n rectangles such that every rectangle has the same area.
We are asked to find the number of positive integers that evenly divide every number in a given array. The array can contain up to 400,000 elements, each of which can be as large as $10^{12}$. Conceptually, we are looking for the set of common divisors of all array elements.
The trains leave at times $$1, 4, 16, 64, dots$$ which are exactly the powers of 4. Given a time $s$, we need to count how many of these departure times are strictly smaller than $s$. The unusual part is that $s$ is not given in decimal.
We are given a directed graph represented as an adjacency matrix, where each vertex has edges to other vertices, but no vertex has a loop to itself. Along with the graph, we are also given a path p as a sequence of vertex indices.
We are looking at strings of length $n$ built from an alphabet of size $k$, chosen uniformly at random. For any fixed string, we examine how many of its prefixes also appear as suffixes of the same length.
We are given a collection of integers, and we interpret each integer as a node in a graph. Two nodes are connected when their bitwise AND is non-zero, meaning they share at least one common bit set to 1.
We are given an array of integers. In one operation, we may choose any element and either increase it by 1 or decrease it by 1. Each such change costs one coin.
We are maintaining a very large array indexed from 1 to 500000, initially all zeros, and we support two operations. The first operation adds a value to a single position.
We are working with a binary grid transformation problem. There is a target grid A filled with zeros and ones, and a second grid B which starts completely empty.
The tree defines a bottom-up majority-like rule where only leaves carry fixed information and every internal node derives its state from its children.
We are given a table with n rows and w columns. Each row contains an array that can be slid left or right within its row, but it must remain fully inside the table and occupy consecutive columns. The arrays can have different lengths, and some elements can be negative.
We are asked to compute a sequence similar to Fibonacci numbers, but instead of summing the previous two terms, each term is obtained by applying the bitwise XOR operation to the two previous terms.
We are asked to move along a straight line from position 0 to position L. The segment is split into ordinary parts and several disjoint special intervals called walkways. Each walkway covers a subsegment $[xi, yi]$ and provides a constant speed bonus $si$.
We are asked to transform a given sequence of integers into a "nice" sequence. A sequence is nice if all occurrences of the same number appear in contiguous blocks. For example, [3, 3, 1, 1, 2] is nice, but [3, 1, 3] is not because the 3s are split by 1.
We are given a matrix with n rows and m columns, where each entry is a positive integer. We can pick any column and rotate it cyclically any number of times. After performing such rotations, we consider each row and take the maximum value in that row.
We are given a list of integers, and we want to partition them into as few groups as possible. Each group has a structural constraint: if you look at the smallest number inside that group, every other number assigned to the same group must be divisible by that smallest number.
We have a small deck of $k$ cards, numbered 1 through $k$, and Wojtek knows $n$ different deterministic shuffles (permutations) of the deck. Each shuffle specifies exactly where each card ends up.
We have a rooted tree with root at vertex 1. Every vertex stores a value x[v]. For any ancestor-descendant pair (u, v), we look at the path from u down to v and compute the gcd of all values on that path.
We are given a very small graph with at most 7 vertices, and a fixed “palette” of 21 dominoes. Each domino corresponds to an unordered pair of values from 1 to 6, so a domino is really a pair like (1,1), (1,2), …, (6,6), with exactly one copy of each pair available.
We are given a collection of string fragments. Originally, all of them came from cutting a long string that consisted of the word "kotlin" repeated several times. After the cuts, the fragments were shuffled.
We are asked to plan the minimum number of visits for a tourist traveling along a fixed cyclic route of cities. The cities are numbered from 1 to n, arranged in a cycle, and the traveler always moves forward: from city i to i+1, and from city n back to city 1.
We are given an array of integers, and we can repeatedly pick any number and divide it by two, rounding down. The goal is to find the minimum number of such operations required to make at least $k$ numbers in the array equal.
We are asked to compute a sum of last digits of page numbers divisible by a given integer. Polycarp reads a book with pages numbered from 1 to n. Every page number divisible by m gets recorded, but only its last digit is written.
We are given several independent experiments, and each experiment consists of a sequence of daily prices of a product.
We have two multisets of points on a circle of length m. The first set contains the office locations. Office i is located in city a[i]. The second set contains the candidates. Candidate j lives in city b[j].
We are given a two-dimensional grid representing a chameleon's body. Initially, all cells are green. Each cell can be either green or blue, and the color may be flipped multiple times. Each flip affects a contiguous horizontal segment of a single row.
We start with a fixed amount of money in rubles and want to convert it into foreign currency using an exchange office that sells only fixed denominations of dollar bills and euro bills. Each dollar costs a fixed amount in rubles, and each euro also has its own fixed ruble price.
We are given a string of parentheses, like "(()))(" or ")(", and we need to determine whether moving at most one bracket to a different position can make it a correct bracket sequence.
We are given a long row of marbles, each painted with one of at most 20 colors. The only allowed move is swapping two adjacent marbles, and we want to use as few swaps as possible. The goal is not to sort the marbles in the usual sense.
We are asked to assign a signal power to a set of radio stations and choose a subset of these stations such that all citizen complaints are satisfied, no two stations interfere, and each chosen station's signal power falls within its allowed range.
We are given two strings, s and t, of equal length composed only of the letters "a" and "b". The task is to make s and t identical using a sequence of allowed swap operations. Each operation lets us pick one character from s and one from t and swap them.
In this problem, we have two football teams playing a match. Each team starts with a certain number of players, denoted by a1 and a2. Throughout the match, the referee shows n yellow cards to players.
We have a line of rooms numbered from 1 to n. Every room must end up connected to the Internet. There are two ways to achieve that. A room can be connected directly, paying a cost equal to its index. Connecting room i directly costs i.
The sequence is built by concatenating “blocks”. The first block is just the string “1”. The second block is “12”.
We are given three rectangles on a plane aligned with the axes. The first rectangle is a white sheet, and two subsequent rectangles are black sheets. Each rectangle is defined by its bottom-left and top-right coordinates.
We are given a line of cans, each with a durability value. Vasya has to shoot all cans exactly once, but the number of shots required to knock down a can depends on how many cans have already been knocked down.
We are given a binary string and asked to count its "good" substrings. A substring is good if its length equals the decimal value of its binary representation, allowing leading zeros.
We are given a string s and we need to predict the outcome of a two-player game for each starting position k in the string. The game begins with a substring consisting of a single character at position k.
We have an undirected graph. Every vertex must be assigned either 0 or 1. For each edge, we write the sum of the values on its two endpoints.
We are given several independent game states. Each state consists of tiles whose values are powers of two. In one move, we may pick two tiles with the same value and merge them into a single tile whose value is their sum.
We have a collection of ticket prices, and we are free to choose the order in which tickets are sold. Two donation programs exist. Every a-th sold ticket contributes x% of its price, and every b-th sold ticket contributes y% of its price.
We have a set of $n$ positive integers on a blackboard and a number $k ge 2$. None of the integers is divisible by $k$. We are allowed to repeatedly pick any two numbers $x$ and $y$, erase them, and write $f(x+y)$ instead.
We are given the TV schedule for the next n days. Each day broadcasts an episode from exactly one show, represented by an integer. A subscription is purchased per show, not per episode. If we subscribe to show x, we can watch every occurrence of x in the schedule.
We are asked to compute a product over a sequence of numbers derived from a pair of integers $x$ and $n$. The function $f(x, y)$ looks at all prime factors of $x$ and for each such prime $p$ determines the largest power of $p$ that divides $y$.
We are given a sequence x of length m. For every value i from 1 to n, we construct a special permutation: pi = [i, 1, 2, ..., i-1, i+1, ..., n] This permutation differs from the identity permutation only because the value i has been moved to the front.
We are simulating the behavior of a smartphone chat interface. The smartphone screen can show at most $k$ conversations. Each incoming message comes from a friend identified by a unique ID. If a conversation with that friend is already on the screen, the screen does not change.
We are given a tree and need to find the largest connected subgraph that can be represented as an intersection graph of line segments on a line.
We are given two integers, x and y, with x y. The task is to determine whether it is possible to choose a single prime number p and repeatedly subtract it from x until we reach y. Importantly, once a prime is chosen, it must be used exclusively; we cannot switch primes mid-way.
We are asked to count the number of "random pictures" of size $n times m$, where each cell is either black or white. A picture is considered random under Ivan's definition if every cell has at most one adjacent cell of the same color. Here, adjacency is horizontal or vertical.
We are asked to arrange soldiers of various heights into a parade formation with exactly $k$ rows. Each row must have the same number of soldiers, and within a row, no two soldiers can differ in height by more than one.
We are tracking whether a single employee, Randall, remains employed after a sequence of yearly “pruning” operations in a company where employees are ranked by a fixed performance value. The company always keeps exactly $N$ employees.
We are given a tree with $N$ junctions and $N-1$ roads connecting them. A tree means that every pair of junctions is connected by exactly one path.
We are given a permutation of integers from 1 to N, which represents Danang's completed homework. Darto wants to submit his own permutation, different enough from Danang's, but still using numbers 1 through N exactly once.
There is not enough information to diagnose the bug or provide a corrected solution. The sample with expected output appears to belong to a string construction problem, but you have not provided: - the problem statement, - the original Python solution, - or even the name of…
We are given a list of sweets, each with a positive integer value representing its sweetness level. Yui wants to eat exactly $k$ sweets for each $k$ from 1 to $n$. However, she cannot eat more than $m$ sweets in a single day. Time is divided into days starting from day 1.
We are asked to rearrange chocolates among boxes so that Alice will be happy. Each of the $n$ boxes has either zero or one chocolate, and at least one box contains a chocolate.
There is not enough information to diagnose the bug or provide a corrected solution. The sample with expected output appears to belong to a string construction problem, but you have not provided: - the problem statement, - the original Python solution, - or even the name of…
We are asked to determine whether a target sum S can be constructed using two types of coins. One type has value n and there are a coins of it, the other type has value 1 and there are b coins of it.
The input does not give the number directly. Instead, it gives its prime factorization as a list of prime factors, where equal primes may appear many times. Suppose a prime $q$ appears $c$ times. Then every divisor chooses an exponent between $0$ and $c$ for that prime.
We have three participants and a set of problems numbered from 1 to n. Each participant currently holds some subset of problems, but the subsets may not respect the desired division: the first participant should hold a prefix of the problems, the third participant should hold…
We have a line of students numbered from 1 to n. Among them, two students are rivals, located at positions a and b. The gym teacher wants to maximize the distance between these two students, where distance is simply the absolute difference of their positions.
We are given a tree where each vertex does not have a fixed color. Instead, every vertex has a range of possible colors, and we imagine choosing one integer color independently for each vertex within its allowed interval.
There is not enough information to diagnose the bug or provide a corrected solution. The sample with expected output appears to belong to a string construction problem, but you have not provided: - the problem statement, - the original Python solution, - or even the name of…
We are given a house with n rooms. For each room, we know two numbers: ci, the maximum number of radiators we can install, and sumi, the total number of radiator sections required to adequately heat that room.
We have two independent electrical grids in a palace, each forming a rooted tree with node 1 as the head. The trees supply electricity to devices through their leaves.