brain
tamnd's digital brain — notes, problems, research
43815 notes
We are asked to analyze a two-player game played on a row of lilypads numbered from 1 to $n$. Alice starts on lilypad $a$ and Bob on lilypad $b$, and they take turns jumping either one step left or right. A frog loses if it cannot jump to a valid, unoccupied lilypad.
We are asked to work with sequences of integers of length $n$, where each element lies between 0 and $m-1$. A sequence is considered good if the counts of numbers follow a strict non-decreasing property: whenever two numbers $i < j$ both appear in the sequence, the number of…
We are asked to consider sequences of length $n$, where each element is an integer between $0$ and $m-1$. A sequence is deemed "good" if the counts of the elements are non-decreasing with respect to their values: for any pair of numbers $i < j$ that both appear in the sequence…
The condition states that all subset sums of the chosen set are distinct.
We are given a set of integer segments over the range [1, n]. Each segment is a closed interval [l, r]. The initial set of segments, S, is "good", meaning that for any two distinct segments in the set, either they do not overlap at all, or one is fully contained in the other.
We are given an undirected graph whose structure is secretly generated from a hidden permutation of the vertices.
We are asked to count subarrays of a given array where the median is uniquely defined. In practice, this means a subarray is good if, after sorting, the middle element (or the two middle elements, if the length is even) are equal.
We are asked to construct an integer sequence of length $n$ where each element lies between $1$ and $n$, and the sequence has the property that the number of longest palindromic subsequences exceeds $n$.
We are given a square stamp of size $m times m$ placed on an infinite grid. We repeatedly move this stamp up and right, and each time we place a full copy of the square on the paper. Each placement paints all unit cells inside that square.
We are given a sequence of coffee machines aligned along a corridor. Each machine initially has a certain number of students around it, and we can manipulate student positions using a simple operation: turning off the lights in a room.
We are given an undirected weighted graph and a large number of queries. Each query picks two vertices and an integer k, and asks us to consider all possible paths between those vertices.
The problem gives a rectangular grid where some cells are already blocked and cannot be used. The free cells, marked with "", form a figure on the grid.
We are asked to maximize the height of pupils in a line under two rules. First, the line is initially comfortable: for every pupil, the height of the next pupil is at most double the height of the current pupil.
We are given a connected undirected graph with up to 400 vertices and up to 400 edges. Every edge has a positive weight. For each query, we are given two vertices a and b, and a number k.
We are given an array of integers representing sweater sizes. From any contiguous segment of this array, we define a score that depends on how spread out the values are and how long the segment is.
Let $N$ be a natural number and let its divisors be $d \mid N$.
We are asked to fill a table with n rows and m columns using each integer from 0 to nm - 1 exactly once. After filling, we compute the MEX (minimum excluded non-negative integer) for each row and each column and sum all these values. The task is to maximize this sum.
We are asked to pick three distinct students from a consecutive range of independence levels, such that a team metric is maximized. The team metric is the sum of all pairwise XORs of the three chosen levels.
We are asked to help a gorilla efficiently clear an array using a particular deletion operation. The operation works on any contiguous subarray: you choose the minimum value in that subarray, then remove every occurrence of that minimum from the chosen segment.
We are given multiple arrays of equal length and we are asked to transform them into a target configuration using a very specific operation.
We are given two connected, undirected graphs that share the same set of vertices. Each graph has a token placed on one vertex initially: in the first graph at vertex s1 and in the second at vertex s2. We can repeatedly move each token along one edge in its respective graph.
The problem presents a scenario where there are n queues, initially empty, and a sequence of n discrete moments. At each moment, every queue receives a certain number of new customers.
We are given a sequence of arrays, each of length $m$, and we need to transform them into another target sequence of arrays using a special operation.
We are given an array and asked to cut it into exactly k consecutive non-empty segments. Since every element must belong to exactly one segment, this is purely a partition of the array into contiguous blocks.
We are given two arrays, a and b, of length n, where each array is "good" - meaning every value in the array occurs at least twice. Milya can rearrange a in any order, then she will compute a new array c where each element is the sum of the corresponding elements from a and b.
Model the city as a finite directed graph $G=(V,E)$ in which vertices are squares and directed edges are one-way streets.
We are given an array of integers written on a board. The game repeatedly removes two numbers per round, but the order matters: Alice removes one number first with the intent of making Bob fail to form a good pair later, while Bob responds by removing another number to try to…
We are asked to determine the minimum time Kevin must invest to win at least a given number of matches against Nivek, for all possible counts from 0 to $n$.
We are given an undirected graph where each vertex may or may not contain a stone. Initially, some vertices are marked with stones, and we are also given a target configuration with the same number of stones.
Kevin has a graph where each vertex may initially contain a stone or be empty. He also has a target configuration indicating where the stones need to end up.
We are given a binary string s consisting of 0s and 1s, and a target string t of the same length that can contain 0, 1, or the wildcard character ?. The operation allowed is to pick two adjacent blocks of identical characters in s and swap them.
We are given a set of $n$ people where every pair is either connected by a hidden binary relation, friendship or non-friendship. The relation is not known in advance, and in the interactive version it may even react to queries.
We are given two binary strings, s and t, of the same length. The string s can be modified using a single type of operation: swapping two adjacent blocks of identical characters.
We are given several independent test cases. In each test case, we start with a running sum equal to zero and we are allowed to reorder the given list of numbers freely. After choosing an order, we process the numbers one by one.
Consider first the simplest nontrivial convex polygon, a triangle $A_1A_2A_3$, with a point $O$ inside.
We are given a list of integers a of length n and a list of magic integers b of length m. Kevin can choose up to k operations where each operation selects an element ai and a magic bj and replaces ai with ai & bj, the bitwise AND of the two numbers.
We are given two sequences of integers: the initial sequence a of length n and the target sequence b of length m. Kevin can repeatedly take any two numbers from a whose difference is at most one, remove them, and insert their sum back into the sequence.
We have a line of classmates, each of whom claims a certain number of liars standing to their left. Each person is either honest, in which case their claim is exactly true, or a liar, in which case their claim may be arbitrary. Additionally, liars cannot stand next to each other.
We are given a multiset of stick lengths, and we must choose exactly four sticks that can form an isosceles trapezoid with non-zero area.
Let $M$ be the midpoint of $AC$.
We are given a set of cities, each described by two integers $ai$ and $bi$. Roads exist between every pair of cities, and the cost of traveling from city $i$ to city $j$ is defined as $max(ai + bj, bi + aj)$.
We are given a two-dimensional grid of size $n times n$ representing stars. A star is present at cell $(x, y)$ if the corresponding grid entry is 1.
We are given two permutations of length $n$, $p$ and $q$, and our goal is to transform $p$ into $q$ using a sequence of swap operations.
The operation in every part is a conditional transposition: two entries are swapped exactly when the larger stands to the left.
We are given a tree with n nodes rooted at node 1, and each node has an associated integer weight. Cirno and Daiyousei play a sequential game on this tree.
We are given a rooted tree where each node has a range of allowable values [li, ri]. Initially, each node can be assigned any value within its range. The goal is to make the tree balanced, meaning all nodes have the same final value.
We are given a rooted tree where each node has a weight. Two players play a turn-based game. On each move, a player chooses a node whose weight is strictly larger than the weight chosen in the previous move and deletes its entire subtree.
Let the hats be $x_1,x_2,x_3,x_4$, placed on sages $1,2,3,4$ respectively, with all values distinct in ${1,\dots,100}$.
We are asked to determine if we can indefinitely avoid letting any clock hit zero in a sequence of clocks. Each clock has an initial time ai. Every second, all clocks decrease by one. We can move to an adjacent clock and immediately reset its time back to ai.
We are given an array and allowed to repeatedly transform it using two operations: reversing it, or replacing it by its difference array, which shrinks the array by one element where each new value is the difference between consecutive elements.
We are given a binary string consisting of characters 0 and 1. The goal is to convert every character in the string to 0.
Let $\ell$ be a line through $C$.
We are given a hidden balanced bracket sequence of length $2n$. The structure of the sequence is not arbitrary: it can be fully described by a set of $n$ disjoint “matching events”, where each event connects an opening bracket at position $l$ with a closing bracket at…
We are asked whether Vasya can determine the total sum of 60 real numbers written on cards if he is allowed to ask about sums of 17-card subsets.
We are given a rooted tree with root at vertex 1. For every unordered pair of vertices (u, v), we only care about pairs where neither vertex is an ancestor of the other.
The problem asks us to count balanced bracket sequences under incremental constraints. We are given a balanced sequence of 2n brackets, but we do not know its content.
We are given two horizontal layers of points. One layer lies on the line $y=0$, the other lies on $y=2$. Each layer contains distinct x-coordinates.
The problem asks us to consider a tree of n vertices and determine the maximum number of connected components that can result after removing exactly two vertices.
We are given an integer segment $[l,r]$. A segment $[a,b]$ is called coprime when the two endpoints $a$ and $b$ have greatest common divisor equal to $1$. Among all coprime segments, we only care about those that are minimal.
We are given an array and a target segment $[l, r]$. We compute the sum of elements inside this segment, but we are allowed to perform exactly one global operation before measuring it. The operation is not a standard reversal of a subarray.
We are given an array of integers a of length n and a target value k. Our task is to count all contiguous subarrays of a that are epic.
After gravity sort, the shape of the sand is completely determined by the permutation. Since $p$ is a permutation of $1 ldots n$, the final shape is always the same staircase: the first column contains $n$ blocks, the second contains $n-1$, and so on.
We are given a word that is already in its singular form in a very constrained toy language. Every word is constructed from a root string, and the singular form is always created by appending the suffix “us” to that root.
We are given a line of slimes, each with a weight, and a special operation: a slime can eat the slime immediately to its left if its weight is at least as large, and after eating, its weight becomes the bitwise XOR of its current weight and the eaten slime's weight.
We start with a binary string s and an empty string t. A move allows us to take any suffix of one string and append it to the other string. Since only suffixes may be moved, the relative order of characters never changes. Characters can only cross the boundary between s and t.
We are given an array of non-zero integers. At each step, we can pick any element, gain coins equal to its absolute value, and then either remove everything to its right if it is negative or everything to its left if it is positive.
The problem asks us to work with a binary string and queries that flip individual bits. For a string $t$, define $f(t)$ as the minimum number of contiguous blocks of identical characters that partition the string.
We are asked to count pairs of numbers in an array where the least common multiple of the pair is a semi-prime. A semi-prime is any number that can be expressed as the product of exactly two primes, which could be the same.
Consider the game on small chessboards to observe patterns.
We are given a word that is already in its singular form in a very constrained toy language. Every word is constructed from a root string, and the singular form is always created by appending the suffix “us” to that root.
The problem asks us to analyze a tree where each vertex has a number assigned to it, and for every number from 1 to n, we must decide if there exists a simple path in the tree where that number is the majority.
The task asks us to construct a binary string of a specified length containing a fixed number of 0s and 1s such that the maximum difference between the counts of 0s and 1s in any substring is exactly k.
We are given multiple arrays of equal length, and we want to merge them in some order to maximize a special score. The score of a single array is computed by summing all its prefix sums. For example, if an array is [a, b, c], its score is a + (a+b) + (a+b+c) = 3a + 2b + c.
We are given an array a and another array b. For every position in a, we have a binary-like choice: we can either leave a[i] unchanged or replace it with a transformed value obtained by picking some element b[j] and computing b[j] - a[i].
We are given a string composed of lowercase letters. Skibidus can repeatedly perform an operation on any pair of consecutive identical letters: he replaces the first letter with any letter and deletes the second.
We are given an array where each position initially contains a fixed value. For every position, we are allowed one optional transformation: we can replace the value at that position with the result of subtracting it from a single fixed number.
The problem asks whether space can be tessellated by congruent tetrahedra of three types: general, equifacial, and non-equifacial.
We are asked to determine whether there exists an integer n such that the sum of its digits equals a given number x, and the sum of the digits of n + 1 equals another given number y.
The problem gives us a positive integer n, and allows us to perform an operation where we add any number that consists entirely of the digit 9 repeated one or more times. Our goal is to make n contain at least one digit 7 using the minimum number of such operations.
We are given a row of $2n$ wine bottles, exactly half white and half red. Gabriella wants to divide these bottles into two groups of $n$ each and then swap the bottles pairwise between the groups.
We are asked to schedule three friends to ride every attraction in an amusement park exactly once, where each ride has a periodic schedule. Each attraction operates at multiples of its own interval ai.
We are asked to model movement across an infinite, periodic two-dimensional terrain. The park is defined by an $n times n$ matrix of altitudes that repeats infinitely in both directions.
We are asked to place n statues on a 2D integer grid, starting at (0, 0) and ending at (a, b), such that the Manhattan distance between consecutive statues exactly matches a given sequence d1, ..., d{n-1}.
I can't reliably write a complete editorial and correct reference solution for Codeforces 2068I from the problem statement alone. This is a 3500-rated problem whose solution depends on several nontrivial graph and shortest-path transformations.
I can't reliably write a complete accepted editorial for Codeforces 2068F from the statement alone. This problem's accepted solution is quite non-trivial.
We are given a set of symbols, each used with a known probability. We must assign each symbol a binary code made of two characters, dot and dash, under the restriction that no code can be a prefix of another.
We are given a large undirected, unweighted graph representing a road network. One vertex is the starting point (Lisbon, vertex 1) and another is the destination (Porto, vertex n).
We are given a triangle with sides $a$, $b$, $c$ and the relation
Working
The task is to design a city represented as a rectangular grid of cells, each being either a park or a built-up area.
We are given a directed relationship between candidates, where an input pair “a defeats b” is not a vote but a constraint on the final outcome we must simulate.
We are given a string consisting only of A and B. We must partition the entire string into pieces of length one or two. Single-character pieces are allowed to be "A" or "B". Two-character pieces are allowed only to be "AB" or "BA". Pieces "AA" and "BB" are forbidden.
We are given two undirected graphs, $A$ and $B$, on the same set of $n$ vertices. Initially, both graphs have no edges. Queries arrive one by one; each query either toggles an edge in $A$ or $B$.
We are given a string of even length, consisting only of lowercase letters. The allowed operation is to select any contiguous substring of the string and shuffle its characters arbitrarily.
We are asked to count the number of "beautiful" subsequences in an array where every element is either 1, 2, or 3.
We are given a rectangular grid of size $n times m$ where each cell has a color represented by an integer. We can perform painting operations where in a single step we choose a set of cells that are strangers-that is, no two of them share a side-and all have the same color…
We are given an array of 0s and 1s representing a “local equality” pattern for some unknown array of integers.
We are asked to compute, for every possible number of slices k that Monocarp can eat, the number of ways to select exactly two friends such that the friends do not quarrel over any pizza and Monocarp ends up eating exactly k slices.
We are given a binary string and we look at every contiguous substring. For each substring, a two-player game is played on the characters of that substring, where each move removes exactly two adjacent characters.