brain
tamnd's digital brain — notes, problems, research
43815 notes
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.
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.
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.
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$.
We have m days. On each day, a specific set of friends is available, and we must choose exactly one available friend for that day. The assignment must satisfy a fairness condition. Let limit = ceil(m / 2). No friend may be chosen more than limit times across all days.
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 simulate a playlist with songs labeled by genres, where Arkady listens to songs in order, cycling back to the beginning when reaching the end.
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 prison represented as a rectangular grid of size a × b. Each cell is isolated by walls on all four sides except the perimeter, which leads to freedom.
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 rooted tree where every root-to-leaf path has the same length. Each non-root vertex has a value, while the root has no value attached. Two tokens start together at the root.
We are given a two-dimensional grid of positive integers, where each cell contains a small number between 1 and 16.
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 strictly increasing array a of length n with elements from 1 to k, and multiple queries asking about subarrays. For each query, defined by indices l and r, we need to count how many arrays b exist that are "k-similar" to the subarray a[l..r].
We are asked to reduce a positive integer a to zero using two operations: divide a by another positive integer b using integer division, or increment b by one. Each operation counts as one step, and the goal is to minimize the total number of steps.
We are given a tree with n vertices, meaning a connected graph with n-1 edges and no cycles. Along with the tree, we are given m paths, each specified by its two endpoints u and v.
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 the largest possible median among all contiguous subarrays of a given array with length at least $k$.
We are given a hidden array of distinct values, and we can only interact with it through queries. Each query asks for a subsegment and returns the position of the second largest value inside that subsegment (but the index is reported in the original array).
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 stacks, each with some number of blocks. The task is to decide if we can redistribute blocks, moving them only to the right, to make the stack heights strictly increasing.
We are given several independent test cases. In each test case there is a set of points on a 2D grid, representing houses.
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 design the results of a round-robin football tournament so that every team ends up with the same number of points. There are $n$ teams, and each pair plays exactly once.
We are asked to build a number equal to a given large integer using only building blocks that are themselves made entirely of digit ‘1’. Each building block is an integer like 1, 11, 111, 1111 and so on, and we are allowed to add or subtract these blocks.
We have four layers of items. The first layer contains first courses, the second layer contains second courses, the third layer contains drinks, and the fourth layer contains desserts. Every item has a cost. Between every pair of adjacent layers, some combinations are forbidden.
We are looking for integer triples $(a, b, c)$ such that $1 le a le b le c le n$. Two conditions must hold at the same time.
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 collection of heroes, each with an initial strength or level. They fight pairwise, and whenever two heroes with different levels meet, the stronger one wins and grows stronger. If their levels are equal, the fight is a draw and nobody gains anything.
The task describes a graph of islands connected by bidirectional bridges, where a disaster spreads outward from island 1 one layer per day.
We are managing a flower shop with n types of flowers, each with a fixed price. The shop starts empty, and a sequence of m operations is performed, either adding flowers to inventory, removing them, or asking for a count of distinct bouquets.
We are asked to construct strings of length $n$ using only the letters "a", "b", "c", and "d". For each position $i$ from $1$ to $n-1$, we are given a constraint $ai$.
We are given a set of n distinct integers, each from 1 to n. The task is to assign each number a color, red or blue, such that exactly k numbers are red. The cost of a coloring is defined by counting all pairs (x, y) where x is blue, y is red, and y is divisible by x.
Ann wants to maximize profit by mining and selling Dogecoin over a period of days. She earns exactly one coin per day she mines, and the price of a coin varies each day according to a given list.
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 non-decreasing sequence of integers over a fixed number of days, where each day represents how many problems Polycarp solves.
We are given a string of parentheses that is guaranteed to form a regular bracket sequence. Our goal is to repeatedly remove parts of the string according to two operation types until the string becomes empty.
I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.
We start from zero and want to reach a target value using two kinds of increments. One increment is very small and uniform: we can always add 1 to the current value.