brain
tamnd's digital brain — notes, problems, research
43815 notes
We have an (n times m) height map. The browser can display any rectangle containing exactly (a) consecutive rows and (b) consecutive columns. For every possible position of that rectangle, we need its minimum height, and finally we need the sum of all those minima.
We have (n) convex polygons. Polygon (i) is given by its vertices in counterclockwise order, and the total number of vertices across all polygons is at most (300,000). For every query ([l,r]), we need the number of vertices of the Minkowski sum of polygons (l,l+1,ldots,r).
We have an array of up to (10^5) positive integers, and for every ordered pair of elements (ai,aj) we form a new decimal number by interleaving their digits from the least significant side. If one number has more digits, its remaining most significant digits stay in front.
We have an array of (n) note frequencies. We may choose any nonempty subsequence, so the chosen positions have to remain in their original order, but positions may be skipped.
I can write the editorial, but there is a problem with the supplied problem data: Codeforces Gym 102284A is indeed “Что? Где? Когда?
For each query, we are given positive integers (X) and (N). Consider the (N+1) terms of the binomial expansion [ (1+X)^N, ] where the term with index (i), using one-based indexing, is [ Ti=binom{N}{i-1}X^{i-1}. ] We may choose any subset of these indices.
We have up to 50 students, and every student must be assigned to either Matt's class or Sean's class. Student (i) has a base probability of passing Matt's class and another base probability of passing Sean's class.
We classify every lowercase letter as either a vowel or a consonant. The vowels are a, e, i, o, u, and y, so there are 6 possible vowels and 20 possible consonants. Every ? in the input may be replaced independently by any of the 26 lowercase letters.
We need the area common to two centered shapes: a square with side length s and a circle with radius r. Since their centers coincide, the answer depends only on how the circle reaches the four sides and corners of the square.
We have a sequence of selling days. On day (i), exactly (ci) cups are requested. Every cup consumes (x) lemons and (s) ounces of sugar. Lemons can be purchased individually, while sugar is sold only in five-pound bags.
Each test case describes the jersey numbers of exactly 10 soccer players. Mack always wears number 18, while Zack always wears number 17. For every set of 10 numbers, we must determine whether the set contains Mack, Zack, both, or neither.
We have (N) pairs ((pi,fi)). When a pair is reached, the player receives (pi) rubles and can stop immediately, paying (fi) rubles. If (fi) is negative, paying it means receiving additional money. If the player reaches the final pair, stopping is mandatory there.
Each student has taken some subset of the available courses, and for every course they took we know their grade. For a particular student, we must find the other student whose grades are most similar on the courses they have both taken.
We have an array of positive chapter prices. Whenever a debt is due, Dostoyevskiy may sell any subset of the already written chapters, and the debt can be paid exactly when its value equals the sum of that subset.
The problem asks us to choose a point (p=(pt,pi)) that represents the parameters we want to use, together with the smallest possible value of (t).
We have n leshys, each with a fixed power. At the beginning, every leshy is the root of its own hierarchy, so there are n separate trees. A meeting operation + i j says that leshy j becomes subordinate to leshy i.
We are given two positive integers (A) and (B), representing the fraction (A/B). We may choose any integer base (beta ge 2), and we want the smallest base in which this fraction has a finite representation after the radix point.
We have trees (T2,T3,ldots,TN), where tree (Ti) contains exactly (i) cities. Every tree is connected and has exactly (i-1) streets. All but at most two of these trees are stars centered at city 1.
The city is modeled by line segments in the plane. A building is represented by a segment with an associated height, and a rocket trajectory is another segment. Whenever a rocket trajectory intersects a building segment, that building is a possible collision.
Each collective farm produces k[i] bags of grain. For a query (l, r, x, m), we consider only farms from l through r. If a farm supplies m families, the number of bags left after giving every family the same integer number of bags is exactly k[i] mod m.
We have three stacks arranged from left to right, containing a, b, and c rocks. On every turn, the current player chooses one nonempty stack and removes between 1 and m rocks.
There are initially N cards in the box, one card for every label from 1 through N. Whenever a label is drawn for the first time, that card is placed on the desk and one fresh card is added to the box. The label of the fresh card is chosen uniformly from all N possible labels.
We have (N) performers. Each performer has an instrument ID (V) and an ability value (P). The final order must be sorted by instrument ID. Inside one instrument group, however, we are free to arrange its performers however we want.
Samuelo's text is a string s, and Roppa's guessed hidden message is another string t. The guess is considered correct if we can delete some characters from s while keeping the remaining characters in their original order and obtain exactly t.
We have a line of (N) buildings, where building (i) has height (hi). Lario starts on one chosen building and makes exactly one jump.
This is an interactive search problem disguised as a coin-change problem. There is an unknown positive integer quantity (X), with (1 le X le 10^6). We have (n) droppers, and using dropper (i) once adds (ai) units of liquid.
We have the Fibonacci sequence indexed from 1, with (F1=F2=1) and (F{k+2}=F{k+1}+Fk). For a given (n), the available humans correspond to the first (n) indexed Fibonacci values.
We have an array of (n) wall heights. A destruction operation chooses an interval ([a,b]) and removes exactly (s) meters from every wall in that interval, except that a wall cannot become negative. In other words, every affected height changes from (hi) to (max(0,hi-s)).
We are given one text string with no spaces. The task is to find the longest prefix of that string whose characters are all decimal digits. The prefix must be non-empty. If the very first character is not a digit, then no valid prefix exists and we print -1.
Each team has three strings of its own length. At every position, the team may choose the character from any one of its three members, independently of every other position. Thus a team with strings (P,Q,R) can construct up to (3^n) different strings.
Each course is a vertex in a directed graph. If a[i] = j, then course i must be completed before course j. A course with a[i] = 0 has no course after it in this prerequisite relation.
We have a string of length (n), indexed from 1 to (n), and (q) updates. An update chooses a starting position (i), a step (a), a number of steps (k), and a character (c). The affected positions form one arithmetic progression: [ i, i+a, i+2a, ldots, i+ka.
We have one non-empty string s. The only allowed operation is appending characters to its right end. The goal is to append as few characters as possible so that the entire resulting string becomes a palindrome.
We are given an (ntimes n) integer matrix (A) and positive integers (b1,ldots,bn). For a vector (x), define (y=Ax). The integral asks for the (n)-dimensional volume of all vectors (x) whose image (y) lies inside the axis-aligned box [ 0le yile bi.
We have n rooms arranged from left to right. Each room contains piles of stones, and a grouped input record (p, q, c) means that room q contains c distinct piles whose size is p. A query gives an interval [l, r].
We have a fixed C60 fullerene, whose 60 carbon atoms are the vertices of a truncated icosahedron, the familiar soccer-ball polyhedron. Each vertex may either remain unchanged or receive one of n atom types.
We need to choose an initial velocity for a basketball thrown from (P=(x0,y0)) so that it reaches (Q=(x1,y1)) at some time (t), while the initial speed does not exceed (v{max}). The official problem uses the physical equation [ B(t)=P+v0t+frac12gt^2, ] where (g=(0,-9.80665)).
We have a stack containing the cards labeled from 1 through n, appearing in some permutation. The magician must discard the cards in increasing label order, so card 1 must be discarded first, then card 2, and so on. Only the top card can be discarded.
The problem asks us to process an integer array and, for every possible value of (k), determine how many array elements can be selected into a collection of increasing subsequences. Every selected subsequence must contain at least (k) elements.
We have a dartboard centered at the origin. The board is divided radially into w equal wedges, and it has three concentric scoring regions. The innermost circle of radius b is the bullseye and always gives 50 points.
We have a text file consisting of several lines. For each line, only its length matters. A cursor position is described by a line number and a column number, where column 0 is immediately before the first character and column s[i] is immediately after the last character.
The problem models two households whose electricity consumptions are positive integers. The electricity company uses a progressive tariff: the first 100 CWh cost 2 Americus each, the next 9,900 cost 3 each, the next 990,000 cost 5 each, and every unit beyond 1,000,000 costs 7.
We maintain an array of quirky integers. A quirky integer is square-free, and every prime factor is below 300. There are only 62 such primes, so every value can be represented by a 62-bit mask telling us which primes occur in its factorization.
We have a triangular arrangement of pins with n pins on the bottom row, n - 1 on the row above it, and so on, for a total of [ 1+2+dots+n=frac{n(n+1)}2 ] pins. After the ball is rolled, the only pin that the ball itself can knock down is the top pin.
We have a two-pile impartial game. A position is represented by the two pile sizes, say (x, y). On a turn, a player may remove any positive number of stones from exactly one pile.
We have a connected undirected graph whose vertices represent buildings and whose vertex weights represent the cost of choosing that building for reconstruction. On one day, we choose a building (v).
A lucky number is a positive decimal number whose digits are only 4 and 7. A super lucky number has two additional restrictions: its total number of digits must itself be lucky, and the number of 4 digits or the number of 7 digits must itself be lucky.
For each test case, we are given three lists of non-negative integers, called A, B, and C. For a list such as A = [a1, a2, ..., ak], define its score as [ P(A)=a1!cdot a2!cdots ak!. ] The task is to determine which of the three lists has the largest score.
We have several shopping sprees. For each spree, the items appear in a fixed order, with value a 1 ,a 2 ,…,a s . We want to choose a subset of these items with maximum total value. The restriction is about every prefix of the array.
The puzzle uses exactly nine truffles. Each truffle has one of three shapes, square, round, or triangle, and one of three flavors, vanilla, strawberry, or chocolate. Since every combination occurs exactly once, the nine physical truffles are all distinct.
The email network is a directed graph. Each person is a vertex, and an entry saying that person u has person v as a contact creates a directed edge u - v. The starting person receives the first email and forwards it to every contact, and every recipient does the same forever.
We have several trips to Fujiyama Sushi. On each trip there are c cars, and every car carries exactly four people, so there are 4c family members in total. Each car has its own arrival time, measured from the beginning of the trip. Each person has an eating time.
The task is to examine several names and decide whether each name contains more vowels than consonants. The only vowels are the five lowercase letters a, e, i, o, and u. Every other lowercase letter is a consonant.
We are given a task number written as a sequence of decimal digits. A split chooses several cut positions between digits, so every resulting piece is interpreted as a separate task number.
We have n animals. Animal i has three parameters a i , b i , and c i . If the cage currently contains at most c i animals, this animal contributes a i aggression. If the cage contains more than c i animals, it contributes b i , where a i ≤b i .
Есть n человек и k последовательных печатей. Печати расположены в фиксированном порядке: сначала человек должен получить первую, затем вторую и так…
We have two current offers, x from Barnum and y from Carlisle, with x <= y. Barnum increases his offer by a, then Carlisle decreases his offer by b. On the next pair of moves the changes become 2a and 2b, then 3a and 3b, and so on.
There are n train cars. In car i, a[i] seats are still free after the chemistry team has bought its tickets. The informatics team has exactly k participants and wants to buy tickets so that every car in which they travel becomes completely full.
We need to count strings of length (n) over an alphabet of 35 characters, namely the digits 1 through 9 and the lowercase letters. A string is valid if it contains no tandem repeat whose length is at least (n-k).
We have a weighted tree with (n) vertices. A matching is a set of edges such that no two selected edges share an endpoint. For every (k=1,2,ldots,n-1), we need the maximum possible sum of edge weights among all matchings containing exactly (k) edges.
We are given a tree with up to (200,000) vertices. Somewhere in this tree there is one hidden special vertex (u). We know the entire tree, but not (u), and we must discover it through interactive queries. A query chooses a vertex (x) and a set of vertices (V).
For each query ((l,r,k)), we look only at the subarray (al,ldots,ar). We must choose exactly (k) nonempty pairwise disjoint contiguous pieces of that subarray and maximize the sum of all elements covered by those pieces. The pieces may be adjacent.
For every inserted edge, we know its two endpoints, the number of stones on it, and a positive value representing how much we earn if that edge is included in our chosen graph.
We have a connected undirected graph and need the determinant of its adjacency matrix modulo (998244353). The graph has up to (25,000) vertices and (500,000) edges, but the unusual condition involving (k+1) vertices is the real structural constraint.
The graph starts as a triangle and is repeatedly expanded by choosing a triangular face, inserting a new vertex into it, and connecting the new vertex to all three vertices of that triangle.
The game looks enormous because one move replaces a single tuple by up to (2^n-1) new tuples, and the initial position already contains (n!) tuples. The useful way to look at it is not as a simulation, but as an impartial game whose positions have Sprague-Grundy values.
We maintain a string of lowercase letters that grows only by appending one character to its right end. A query asks for a length (k), and we must count how many substrings of length (k) are exactly equal to the prefix of the whole string of length (k).
We have an (n times m) grid of lowercase letters. A route starts at the upper-left cell, ends at the lower-right cell, and consists only of moves right and down. Every route visits exactly (n+m-1) cells, so every route produces a string of the same length.
The board stores a five digit decimal number, with leading zeroes allowed. Initially it displays 00000. The hidden number x is guaranteed to lie in the interval [L, R].
We have an array of spoon counts, where position i initially contains a[i]. A shuffle l r operation takes every value currently located in the interval [l, r] and randomly permutes those values among the same positions.
We have an array of N popcorn bags, where P[i] is the amount of popcorn in bag i. There are C competitors, and every competitor can eat at most T popcorn per second. The bags must be divided into contiguous segments.
We have a circle of at most 13 contestants. There are four copies of each card value being used, plus one wildcard. Each contestant starts with four ordinary cards, while the starting contestant also receives the wildcard and therefore initially has five cards.
We have an undirected weighted graph whose vertices are planets and whose edges are direct travel routes. Every planet has a temperature.
The track contains N equally spaced signs, and Vinicius plans to run exactly V complete laps. Since one lap passes all N signs, the entire training consists of V N sign passages.
The mafia hierarchy forms a rooted tree, with member 1 as the root. Every other member has exactly one direct superior, so every member has a unique path upward to the boss.
We have an (N times M) rectangular grid of crossings. A vehicle starts at one crossing, chooses one of the four cardinal directions, and then moves at speed one crossing per second until it either leaves the grid or collides.
We need to construct an (n times n) checkerboard, where cell ((i,j)) must contain stone if (i+j) is even and sand otherwise. The value (n) is even and at most (50). The difficulty is not choosing the final colors. The difficulty is the order in which cells can be reached.
We have two rows of n tables, one row for each floor. A 1 at position i means a team occupies that table, while 0 means the table is free. The printer may be installed on any table, including an occupied one. Suppose the printer is at position p on one chosen floor.
There are (n) friends, and each friend wants a different T-shirt size. Monocarp enters one contest for every friend and requests exactly that friend's size.
We have (p) radio stations. Choosing station (i) means signing a contract with it, and this is possible only when the chosen signal power (f) lies inside its interval ([li,ri]). For a fixed (f), a station outside its interval is forced to remain unselected.
We have an even-length ticket split into two equal halves. Every position already contains a digit or contains ?, meaning that its digit has been erased. The two players alternately choose one remaining ? and replace it with any digit from 0 through 9.
We have a tree whose vertices are numbered from 1 to (n), and exactly (k) of those vertices are colored. For an uncolored vertex (x), imagine cutting (x) away from the tree. Every neighbor of (x) becomes the root of one connected component.
We are given an undirected tree with vertices numbered from 1 to (n). An automorphism is a permutation of the vertices that preserves adjacency, so after applying the permutation, every edge must still connect exactly the same structural positions in the tree.
The constant can be rewritten as [ varphi=prod{k=1}^{infty}(1-10^{-k}), ] because the (k)-th factor is exactly ((10^k-1)/10^k). We need the digit occupying position (n) after the decimal point, where (n) may be as large as (10^{18}). There are up to (10^5) independent queries.
We need the number of different subsequences of a recursively defined binary string. The first string is ab, and every next string is obtained by taking the previous string twice and then appending one more b. Thus the strings themselves become exponentially long.
We have an array of positive integers (a1,dots,an). The first square root is always taken with a plus sign, while every later term may independently receive either (+) or (-). We need to count how many choices make [ sqrt{a1}pmsqrt{a2}pmcdotspmsqrt{an}=0.
The cabin is a rectangular grid, but most cells are not equally useful. There are two vertical corridors, each one cell wide. The first corridor is immediately after the left seated zone, and the second corridor is immediately after the middle seated zone.
We have a rooted tree with vertex 1 as the root. A move consists of deleting any nonempty set of current leaves, where a leaf is a vertex with no remaining children. Removing several leaves at once is allowed, and their parents may become leaves for the next move.
Only the digits after the decimal point matter. Let that fractional part have length (n). A candidate repeating part must be a suffix of the observed fractional digits, because the repetition has to be continuing at the very end of what Sumika measured.
Invoker maintains a sequence of at most three elements. Pressing Q, W, or E appends that element to the sequence. If there are already three elements, the oldest one disappears first.
We have an undirected graph whose connected components are all cacti. We may choose any set of edges to remove. After the removals, every connected component must be a tree, which is equivalent to saying that the remaining graph must contain no cycle.
We have an n × m grid containing empty cells and blocked cells. Each robot starts immediately above the grid in a distinct column and initially moves downward. Each exit is immediately below the grid in a distinct column. A robot normally continues straight.
For each test case, we are given a positive integer (n), and we need to decide whether the decimal representation of the fraction (1/n) eventually ends.
We have a rooted tree whose root is vertex 1. Every vertex has an integer weight, and its depth is its distance from the root.
For every subset of villagers, consider the area of the convex hull of their houses. A random permutation gives each villager a marginal contribution: when that villager is inserted, compare the new convex hull area with the area before insertion.
A counting program describes how far we move through a fixed well-ordered universe. The empty program changes nothing, + takes the next unused element, concatenation runs two programs one after another, and [P] repeats P infinitely many times.
Let David's age be (d), Aram's age be (a), and let the given integer be (C). The conversation tells us that cubing David's age and multiplying by (C) produces exactly Aram's age squared: [ C d^3 = a^2. ] Both ages are positive integers.
We have an array a[1..N] describing the excitement of the scenes in chronological order. We must cut this array into exactly K non-empty contiguous parts.
We have planets numbered from 1 to (N), and the festival is on exactly one of them. Astrodavid starts at planet 1. A jump by (d0) planets costs (fd), while a jump by (d<0) planets costs (fd), where the input gives these costs for every displacement up to (J).
We have up to 100 fighters. Each fighter is described by a name and three statistics: health, attack, and defence. When two fighters meet, every round deals fixed damage to both sides.