brain
tamnd's digital brain — notes, problems, research
41832 notes
We are asked to count arrays of integers that meet a very particular set of conditions. We have a starting number, $b0$, and we want to consider sequences $b0, b1, dots, bn$ where consecutive elements differ by exactly 1.
We have an array $a$, and a recursively defined value: $$f(1)=sqrt{a1}, qquad f(i)=sqrt{f(i-1)+ai}.$$ After every point update $ak leftarrow x$, we need the integer part of $f(n)$. The first obstacle is that the recurrence uses real numbers.
We are simulating a queue of students where the front of the queue is repeatedly served for a limited number of minutes. Each student, once served, leaves to “process” their porridge for a fixed number of minutes, and then returns to the queue.
We are asked to count ordered pairs of integers $(a, b)$ with $1 le a le n$ and $1 le b le m$ such that $b cdot gcd(a, b)$ is divisible by $a+b$. The inputs are multiple test cases, each specifying a pair of limits $n$ and $m$.
We are given a village with n houses aligned in a row. Each resident has a preference for which side of a street they want to live on: left (0) or right (1).
We are asked to decide whether Alice can paint a ribbon of n parts using m colors such that Bob, who can repaint at most k parts into the same color, cannot make the entire ribbon monochromatic.
Codeforces 1975I: Mind Bloom
Codeforces 483B: Friends and Presents
We are asked to help Elsie evaluate her paintings on a 1D canvas of n cells. Each cell can be painted or left empty, and the painting's beauty is determined by a 2D array a.
We are asked to consider a network of islands where initially every pair of islands is connected by a bridge. There are n islands, numbered from 1 to n, and Everule lives on island 1. Dominater can destroy up to k bridges to reduce the number of islands that Everule can reach.
Comprehensive guide to HSK 4 grammar: complex comparisons, formal negation, pivotal constructions, topic-comment structures, and upper-intermediate patterns.
We are given a collection of time intervals, each interval belonging to a different lecturer. Lecturer i is available on a continuous range of days from li to ri, and can be assigned to at most one conference day.
We have a 2-row grid with $n$ columns, and each cell contains an arrow pointing either left or right. The robot starts at the top-left corner, and each second it first moves to an adjacent cell (up, down, left, right) and then follows the arrow in the new cell.
We are given a permutation, and we observe it evolving over time by revealing its prefix. After revealing the first $q$ elements, we throw away all values greater than $q$, but keep the relative order of the remaining values.
We are asked to construct an exact sum using coins of values 1, 3, and 5. For each target amount n, we want to pay exactly n using any number of 3 and 5 coins, and we are only forced to use 1-coins when it becomes unavoidable.
Codeforces 1973E: Cat, Fox and Swaps
We are given two rooted trees on the same labeled vertex set from 1 to n, both rooted at 1. Each tree is described by its parent array, so every node knows its immediate parent except the root.
Codeforces 1975C: Chamo and Mocha's Array
We are asked to count the number of polynomials with non-negative integer coefficients that satisfy a very specific evaluation property.
We are asked to simulate a two-player game on an array of integers, but with a compressed representation where we only know the frequencies of each integer.
We are asked to count certain arrays with bounded elements that satisfy a combinatorial property. Specifically, consider all arrays of length n where each element is between 0 and k.
We are asked to count subsegments of length m in an array a that are “good” relative to another array b of length m. A subsegment is considered good if, after rearranging its elements, at least k of them match elements from b.
Comprehensive guide to HSK 7 grammar: academic research language, classical grammar in modern use, specialized register patterns, and C1+ mastery structures.
The city is a rectangular grid. Every hotel and every restaurant is located at an intersection with coordinates $(x,y)$.
We have a line of cows, each with a unique Cowdeforces rating, and they compete in a sequential tournament. The tournament begins with the first two cows, and each subsequent match is between the winner of the previous match and the next cow in line.
We are given two binary strings of equal length. The first string, call it the reference string, defines a constraint on how a valid target string must behave. The second string is the one we want to stay as close as possible to after we adjust it into a valid configuration.
We are given an array where each position contains a value in the range $1$ to $m$, and a second array that defines a deterministic transformation on values: every value $x$ has a fixed replacement $bx$.
We are given a line of monsters, each with some initial health. One operation consists of choosing a single monster as the starting point of a “chain lightning”.
We are given a permutation, which is just an ordering of the numbers from 1 to n. We repeatedly apply a transformation that removes elements which are strictly smaller than at least one of their immediate neighbors.
We are given a multiset that contains almost all subarray sums of an unknown array a, where a has two special properties: every element is strictly positive and the array reads the same forwards and backwards.
We are given a circle of n monsters, each with an initial energy level ai. They are numbered from 1 to n, and each monster attacks its clockwise neighbor simultaneously in a single round.
Codeforces 1975D: Paint the Tree
We need to construct an array of length n such that exactly k of its cyclic shifts are sorted in nondecreasing order. A cyclic shift chooses some position as the new beginning of the array and wraps the remaining elements around.
We are given a string and we are allowed to cut it into contiguous pieces. The goal is to decide whether we can cut it so that every resulting piece is not a palindrome. If it is possible, we must also construct one such cut.
Codeforces 1974F: Cutting Game
Comprehensive guide to HSK 9 grammar: native-level classical Chinese, literary production, oral defense mastery, and full C2+ control of written and spoken registers.
We are given a binary string of length $n$ where the first $c$ characters are ones and the remaining $n - c$ characters are zeros. We are allowed to perform up to $k$ operations, where each operation flips a zero into a one.
Each song has two attributes, a genre and a writer. After removing some songs, we are allowed to reorder the remaining songs arbitrarily.
Maxim wants to buy exactly n yogurts from a store where a single yogurt costs a burles, but there is a promotion offering two yogurts for b burles. For each test case, we must calculate the minimum amount he can spend to buy exactly n yogurts.
We are given an array of integers that is guaranteed to be "beautiful," which means that through a specific operation, all elements can eventually become the same.
We are given an increasing list of positions, and a process that repeatedly deletes players from a line. In each round, we look at the current lineup and try to remove the players standing at positions $a1, a2, ldots, ak$.
Two firework machines start at time zero and then keep launching fireworks periodically. The first machine fires at times that are multiples of a, and the second fires at multiples of b.
We are given a collection of balls, each assigned one of n distinct colors, where color i has ai balls. We are allowed to group these balls, but each group can have at most two balls, and no two balls in the same group can have the same color.
We are given times expressed in the 24-hour clock format, for example 00:00 for midnight, 13:45 for one forty-five in the afternoon, or 23:59 for one minute before midnight. Our task is to convert each time into the 12-hour clock format, which uses the familiar AM and PM labels.
Codeforces 1976A: Verify Password
We are looking at arrays of length n, where each position can hold an integer between 0 and k. Every such array is considered a candidate, so the total universe is (k+1)^n. The notion of “good” is defined through an operation that subtracts 1 from a contiguous segment.
The elevator always displays a two-digit floor number from 00 to 99. Each digit is drawn using a seven-segment display. A segment can be broken. When a segment is broken, it cannot light up even if it should.
We are given an array of integers, and two players split the array into two groups. Kirill is allowed to choose a subset that is neither too small nor too large, specifically at least two elements and at most $n-2$ elements. Those chosen elements form the red group.
We are given an array a of length n, constructed from some unknown permutation p of the integers 0 through n-1. Each element of a satisfies the relation a[i] = MEX(p[1..i]) - p[i]. The task is to reconstruct any valid permutation p that produces this a.
We are working on a very constrained grid: only two rows and a large number of columns. The start is the top-left cell, and the goal is the bottom-right cell.
We are given a fixed starting height $b0$ and we imagine building an integer path $b0, b1, ldots, bn$ where each step moves by exactly $+1$ or $-1$, but the path is never allowed to go below zero. This is a standard “walk on the non-negative integers” with unit steps.
Each building has two independent pieces of information. The first string describes what class is held there. A building may need a mathematics professor, a computer science professor, or no professor at all. The second string describes which professor is initially located there.
We are given a circle of monsters, each with an energy level. The monsters attack their neighbor in a fixed clockwise order: monster 1 attacks monster 2, monster 2 attacks monster 3, and so on, with the last monster attacking the first.
The input to this problem is a single integer $n$, with $0 le n le 12$. Despite how small this looks, the task is not about iterating or simulating anything directly from this number in a naive arithmetic sense.
We are given a line of ships, each with some durability, and a fixed attack pattern that always targets the current leftmost surviving ship, then the current rightmost surviving ship, and repeats this alternation until a total of $k$ attacks have been made or all ships sink.
Codeforces 1973C: Cat, Fox and Double Maximum
Codeforces 1975E: Chain Queries
Codeforces 1974E: Money Buys Happiness
We are asked to build a square city on a 2D Cartesian map such that it encloses all given mines, represented as points with integer coordinates. The sides of the square must remain parallel to the axes, and our goal is to minimize the area of the square.
We are standing at an integer floor number in a very large tower that extends far below zero and far above zero. From our current floor $a$, we are only allowed to move upward, meaning we repeatedly add positive integers.
We are given a set of cards, each labeled with a number from 1 to n. For each number i, we have ai cards of that type.
We are asked to construct a rooted tree with a specific number of vertices having 0, 1, or 2 children. The input gives three numbers: a vertices with 2 children, b vertices with 1 child, and c vertices that are leaves.
We are given a list of strings, each consisting of lowercase English letters, and for each string, we are asked to answer either "YES" or "NO" based on a hidden pattern.
The task is to reconstruct a set of four integers representing candy counts in boxes such that three properties are equal: the arithmetic mean, the median, and the range. We are given some subset of these four numbers (0 to 4) in arbitrary order.
We are given the names of the home and away teams, followed by a chronological list of card events during a football match. Each event specifies the minute, which team the player belongs to, the player's jersey number, and whether the referee gives a yellow card or a red card.
We are given a square matrix of size $n times n$ initially filled with zeroes. Nene can perform two types of operations: either set an entire row to a permutation of $1$ through $n$ or set an entire column to such a permutation.
Codeforces 1976B: Increase/Decrease/Copy
Codeforces 1975F: Set
Every tree is planted at an integer lattice point. Around that point we place a disk of radius r, representing the root system. Two conditions must hold. The entire disk must stay inside the square lawn.
Codeforces 1974B: Symmetric Encoding
Codeforces 495B: Modular Equations
We are asked to construct a permutation q of size n such that the sum of inversions of q and the composition q ∘ p equals a given target k. The input permutation p is fixed, and inversions count how many pairs of indices are out of order.
We are given a grid where some cells form a fixed path from the top-left corner to the bottom-right corner. An enemy walks along this path one cell per second.
Monocarp has a single log of wood that weighs exactly $2^n$ grams. He needs to split this log into pieces such that he can assemble exactly $k$ grams of wood for today's fireplace, leaving the remaining $2^n-k$ grams for tomorrow.
We have a regular polygon with n vertices arranged on a circle. Some x vertices are already available for use. We may additionally choose at most y more vertices.
The input describes a single arithmetic-style expression consisting of integers combined with the + operator. The key difference from standard arithmetic is that + does not mean numeric addition.
We are given a binary string and an operation that flips a block of fixed length $k$, turning every 0 into 1 and every 1 into 0. We may apply this operation as many times as we want, but the chosen length $k$ is fixed for the entire process.
We are given a buyer who starts with a fixed number of coins. A shop is not fixed in advance; instead, we are allowed to design up to 60 sequential stalls. Each stall has an unlimited supply of jewels, and a fixed integer price per jewel.
We are asked to maximize the number of games Bob can win in a repeated XOR game against Alice. The game is played on a multiset of integers containing only ones, twos, threes, and fours. Alice wins if the XOR of all remaining numbers is non-zero; otherwise, Bob wins.
Codeforces 1974A: Phone Desktop
We are given a multiset of positive integers and three required group sizes. Every number must belong to exactly one of the three groups, and each group must contain exactly the requested number of elements. After splitting the numbers, we look only at the three group sums.
Complete Sindarin number system: cardinals 1–1000, ordinals 1st–10th, number compounds, duodecimal counting, and number words in place names.
Codeforces 1975G: Zimpha Fan Club
Codeforces 1973A: Chess For Three
We are given three digits, a, b, and c, and must classify their relationship. A sequence is called a stair when the values strictly increase from left to right, meaning a < b < c.
The clock is not a normal continuous display, it behaves like a repeating cycle of three states. Every cycle has length $3k$ seconds.
Codeforces 491A: Up the hill
Codeforces 1976C: Job Interview
We are asked to generate a checkerboard pattern that is made of larger $2 times 2$ tiles. Each tile is either fully filled with the character or fully filled with .. The size of the grid is determined by an input integer $n$, and the final grid has dimensions $2n times 2n.
We are given a circle of baskets numbered from 1 to $m$, and $n$ balls initially placed in distinct baskets. Alice repeatedly chooses one of the balls uniformly at random and moves it clockwise to the next basket.
We are simulating a very specific combat process on a fixed line of monsters, and answering many independent queries on subsegments of that line.
Codeforces 1975B: 378QAQ and Mocha's Array
We are given a sequence of basketball players, each with a passing range expressed as an interval $[li, ri]$. The players are numbered from 1 to $n$.
We are given a row of lamps, all initially off. We can perform one type of operation any number of times: choose two lamps that are currently off and are not next to each other, and turn them both on simultaneously.
We are asked to distribute a fixed number of skill points between two attributes: damage per hit and hits per second, in order to minimize the total time to kill a sequence of monsters.
We are given a line of staircase steps, each step either needing repair or already fine. If a step is fine, it behaves like a zero in the input. If it is broken, it carries a positive cost value that represents its repair difficulty. The repair process is constrained by days.
We are given a multiset of integers, but instead of listing it explicitly, we receive frequencies of each value from 0 up to some maximum m. Alice and Bob remove elements from this multiset until nothing remains.
We are given a regular polygon with $n$ vertices representing a cake. Some vertices are already selected by Bessie as potential endpoints for drawing diagonals.
We are given a collection of sticks, each with an integer length. The goal is to build as many regular polygons as possible using these sticks, with the restriction that each side of a polygon must be exactly one stick, and no stick can be reused.
We are given a queue of n people waiting to ask Seraphim the Owl a question. Kirill arrives at the end of the line and wants to move forward so that he is among the first m people.