brain
tamnd's digital brain — notes, problems, research
41650 notes
We start with a fully valid Sudoku grid. Every row, every column, and every 3 by 3 subgrid contains the digits 1 through 9 exactly once.
We are asked to construct a walk in a complete directed graph on vertices labeled from 1 to n, where every ordered pair of distinct vertices forms a directed edge. This means between any two different vertices u and v, both directions u → v and v → u exist.
We are given a ring of monsters. Each monster has an initial health value, and also a fixed explosion damage value that is applied to its next neighbor when it dies.
We are given two integer arrays of the same length. The first array starts with very restricted values, each position being either negative one, zero, or positive one. The second array can contain arbitrary integers, potentially very large in magnitude.
We are given a sequence of integers and asked to count how many contiguous segments of this sequence are “robust” in a very specific sense. A segment is considered valid if every one of its nonempty contiguous subsegments has a sum that is not zero.
We are given an array of numbers and many queries over subsegments. For each query interval $[L, R]$, we must pick a subsequence of indices inside this interval, in increasing order, with length at least 3, such that the chosen values contain no triple of indices $i < j < k$…
We are given a rectangular grid with $n times m$ cells, and each cell starts with some integer height $a{i,j}$. The game allows two types of moves that increase heights: either we add one cube to two adjacent cells at the same time, or we add two cubes to a single cell.
We are given a short program written in a heavily stylized “Roman-like” pseudocode language. The program reads a sequence of integers from standard input, and for each integer it computes a numeric function and prints either a formatted value or a special overflow message.
We are given a single 7-character number written in a mixed numeral system. The first character is always the letter A, which should be interpreted as the value 10. The remaining six characters are digits from 0 to 9. Together, they form a base-11 number of fixed length 7.
We are given a very long binary string consisting only of the characters A and B, with the guarantee that the first and last characters are always A. In addition to these fixed endpoints, we are given the positions of some other A characters inside the string.
We are given a string that evolves under a deletion game. In one move, we are allowed to pick a contiguous substring, but only if that substring is “locally alternating”, meaning no two adjacent characters inside it are equal.
We are asked to count how many strictly increasing sequences of integers we can choose from the range $[1, d]$, with an extra constraint that depends on cumulative XORs of the chosen values.
Codeforces 1329C: Drazil Likes Heap
We are given a row of cells initially all unpainted. We will perform a sequence of painting operations, where each operation paints a contiguous segment of fixed length, but we are free to choose the starting position of that segment.
Codeforces 1328F: Make k Equal
We are given a circular arrangement of positions, each holding an animal type. The positions are connected in a cycle, so after the last position comes the first again. We must assign a color to each position.
We are given a ternary string x, meaning each position is a digit among 0, 1, or 2. The task is to split this single number into two ternary numbers a and b, both of the same length as x, such that if we add them digit by digit modulo 3, we recover x.
We are given a grid of size $n times m$ with several chips placed on cells. Each chip can be moved simultaneously with all others by applying a single global move in one of four directions: up, down, left, or right.
We are building an array of length $n$, where each position stores an integer with at most $k$ bits. On top of that, we are given several constraints, each describing a segment $[l, r]$ and a required value for the bitwise AND of all elements in that segment.
We are given a permutation p, which we can think of as values arriving in a fixed order from position 1 to n. While processing this order, we maintain a multiset A. Each time we process position i, we insert p[i] into A.
We are given a string and we want to build the longest possible palindrome that can be formed by taking a prefix of the string, a suffix of the string, or both, and concatenating them in that order.
We are given a geometric tree: each vertex is a point in the plane and edges form a non-crossing tree. This already means the embedding is fixed, so geometric notions like convex hull are meaningful relative to the given drawing.
We are given a sequence of integers, and we want to select a subsequence whose product becomes a perfect square. Among all such subsequences, we need the minimum possible length.
We are given an array and we construct a much larger array by repeating it end-to-end many times. The repetition count is equal to the original length of the array, so the final sequence has size $n cdot n$.
We are given a sequence of column heights representing a vertical terrain. Each column has some initial number of blocks stacked on it. The only operation available is to repeatedly choose a column and place a fixed vertical piece that increases that column’s height by 2.
We are given a list of topics, each topic carrying two different scores. One score measures how interesting the topic is for the teacher, and the other measures how interesting it is for students.
We are given several independent arrays of positive integers. For each array, we must select a non-empty group of positions such that the sum of the chosen values is even. If no such group exists, we report failure.
We are given a tree with $n$ stations and $n-1$ tunnels, so between any two stations there is exactly one simple path. On this tree, we are also given $m$ special routes.
We are given a string consisting only of parentheses, and we are allowed to modify it using an operation that picks any contiguous segment and permutes its characters arbitrarily. The cost of such an operation equals the length of the chosen segment.
We are given a string of lowercase letters. We repeatedly remove characters under a local rule: a character can be deleted only if at least one of its current neighbors is exactly one letter earlier in the alphabet than itself.
We are given a fixed binary string, and we repeatedly consider two kinds of local transformations on any contiguous segment of length three: swapping 011 into 110, or the reverse swap 110 into 011.
We are given a directed graph where intersections are nodes and roads are one-way edges. We also know a fixed simple route Polycarp actually drives from his home to his work.
We are given a list of officers, each with a numerical power. From these officers, a battalion is formed by choosing any subset uniformly at random, including the empty set.
We are given a sequence of values that are meant to represent the smaller element in each of several disjoint pairs. In the final construction, we must build an array of length 2n using every number from 1 to 2n exactly once, and then split it into n consecutive pairs.
We are given a one-dimensional town represented as a line of crossroads indexed from 1 to n. Each position has exactly one type of transport station: either type A (bus-compatible segment marker) or type B (tram-compatible segment marker). The string s encodes this layout.
We are given three independent supplies: dumplings, juice, and pancakes. Each visitor receives a subset of these three items, with two constraints. First, a visitor cannot receive more than one of each item type. Second, no two visitors may receive the exact same subset.
We are given an array of integers and are allowed to permute it arbitrarily. After rearranging, we assign each value to a position starting from 1. The array is considered valid if no two positions share the same value of the expression i - a[i].
We are asked to build a rooted tree on vertices labeled from 1 to n, where vertex 1 is the root. Every vertex except the root has exactly one parent, and each vertex is allowed to have at most two children, so the structure must be a binary tree in the rooted sense.
We are given a complete directed graph of cities where every ordered pair of distinct cities has a travel cost. Starting from city 1, we must perform exactly $k$ moves, and end again at city 1. Each move is just choosing a directed edge and paying its cost.
We are given a full double elimination tournament with $2^n$ teams, where the bracket structure is completely fixed.
We are given a directed weighted graph with up to 50 vertices, representing fields connected by roads. A cow starts at node 1 and wants to reach node n, and the time it takes is determined by the shortest path in this graph. Now the twist: we are allowed to “slow down” edges.
A rabbit starts at the origin in the plane and wants to land exactly at the point $(x, 0)$. He moves by making a sequence of jumps, and each jump can have any direction, but its length must match one of the allowed values given in the input.
We are given an undirected, connected graph representing fields connected by roads. A traveler starts at node 1 and wants to reach node n using the shortest possible route.
We are asked to construct a strictly increasing sequence of integers $a1 < a2 < dots < an$, all between 1 and $10^9$, such that a specific combinatorial condition on triples is satisfied.
We are given an exam with a fixed number of questions, where each question contributes either 0 or 1 point to each student.
We are given a fixed tree with up to 1000 vertices. Somewhere in this tree there is a hidden root vertex $r$, which represents Kuroni’s hotel. The structure of the tree is known, but the root is not.
We are given a grid of values over time. Each row represents a day, and each column represents a spatial segment of a forest. The value in a cell tells how many animals can be observed in that segment on that day.
We are given a collection of distinct strings, all of the same length, and we are allowed to pick any subset of them and arrange the chosen strings in some order. After concatenation, the goal is to obtain a palindrome with maximum possible total length.
We are given a grid that evolves over time. Each day produces a full array of animal counts across a line of forest sections. We want to place two cameras repeatedly over a sequence of days, where each camera always covers a contiguous segment of exactly $k$ forest sections.
We are given a pattern of strict comparisons between consecutive positions in a permutation of size n. Each position tells whether the next value must be larger or smaller than the current one. From this constraint, many permutations are possible.
We are given a target amount of space, and a collection of available blocks whose sizes are powers of two. The task is to decide whether we can exactly compose the target size using these blocks, and if not, report impossibility.
We are given a tree where each node stores a positive integer. For any simple path between two vertices, we read the values along that path in order and then compute a special score: we first form all prefix sums of that sequence and then sum those prefix sums together.
We are working on a grid that starts completely empty in the sense that every cell contains the same value, zero. Over time, we perform a sequence of updates.
We are building a road of length $n$, where each unit of road must eventually be asphalted exactly once. The construction proceeds day by day, and on each day we may either work on exactly one unit or do nothing. The weather is periodic.
We are given a string consisting of lowercase letters, and we want to decide whether it is possible to arrange all 26 letters of the alphabet in a single line such that every consecutive pair of characters appearing in the string are also adjacent in this line layout.
We are given a lock described by a sequence of exactly 100 decimal digits. Think of it as a row of 100 small wheels, each showing a digit from 0 to 9.
We are given a fixed 5-digit lock state. Each digit can be incremented cyclically, so 9 wraps back to 0. Starting from an initial 5-digit configuration, we must apply a long, fixed sequence of conditional rules.
We are given a binary string of length $n$, but instead of being fixed, each position is generated independently as a random bit: it becomes $1$ with probability $p = frac{a}{b}$ and $0$ with probability $1 - p$.
We are given a 5-digit lock state. Each digit behaves like a circular counter from 0 to 9, so increasing a digit by 1 means moving to the next digit and wrapping 9 back to 0. The process consists of a fixed sequence of 20 deterministic instructions.
We are working with a rectangular grid of numbers. Each cell behaves like a player in a two-dimensional game: it is compared vertically against its column and horizontally against its row.
We are given a colored grid where each cell is one of four colors. Inside this grid, we are asked many independent queries.
The grid in this problem can be viewed as a directed version of the standard rectangular lattice where every pair of horizontally or vertically adjacent cells is connected by two opposite directed edges.
We are given an array of length $n$ where some positions contain fixed integers and some positions are marked as missing. All missing positions will be filled with a single chosen value $k$.
We are given three strings of equal length. Think of them as three rows of characters aligned in columns. At each column position, we are allowed to perform exactly one operation: we pick either the character in the third string and swap it with the character in the first…
We are given a hidden permutation of numbers from $1$ to $n$, where $n$ is even. We cannot directly see it, but we can query any subset of indices. For a chosen subset, the judge tells us only whether the average value of the selected positions is an integer.
We are given a sequence of water volumes arranged in a line. One operation allows us to pick any contiguous segment and replace every value in that segment with their average. This operation can be repeated any number of times on any segments.
We are given a sequence of horizontal segments that arrive one after another on a 1D board of length $d$. Each segment represents a block that falls vertically until it either touches the ground or touches the top of some previously placed block.
We are given a string and must assign each character to one of two groups, which we can think of as placing each character into either a red bucket or a blue bucket while preserving their original order inside each bucket.
We are given a target value $m$ and asked to consider all positive integers whose digits multiply exactly to $m$. These integers form an infinite set in general, and we are asked to sort this set in increasing numerical order and return the $k$-th element.
We are given several movies, each movie has a time window during which it can be watched in the cinema. If a movie is watched inside its window, it is considered “on time”.
Each employee has a fixed base salary, and we are allowed to distribute an additional integer bonus so that the total bonus across all employees is exactly k. After adding bonuses, each employee’s final salary becomes their original salary plus their assigned bonus.
We are given a tree of cities. From this tree we must choose a subset of cities $S$ such that two conditions hold simultaneously.
We are given an array of integers for each test case, where each value represents the contribution of a developer. We want to pick a subset of indices to form a team, and the value of the team is simply the sum of the chosen elements.
We are given a connected network of $n$ stations connected by $n-1$ railway segments, which means the structure is a tree. Each edge in this tree has an unknown integer weight in the range from 1 to $10^6$. We are also given several observations from passengers.
We are given a sequence of monsters standing in a fixed order. Each monster has a certain amount of health, and they must be defeated one after another from left to right.
We are given a string and we are allowed to assign a color label to each character position. After coloring, we gain a very specific operation: we may swap two adjacent characters only if their colors are different. Swaps can be repeated arbitrarily many times.
We are given an initial amount of money, and we repeatedly perform a very specific type of purchase operation. In each operation, we choose some amount $x$ that we can afford at that moment, spend it, and immediately receive back $lfloor x/10 rfloor$.
We are given a permutation where every value from 1 to n appears exactly once, but the order is arbitrary. Each position also has a cost associated with its element, and that cost is what we pay whenever we move that element between two groups.
We are working with a fixed number $a$ and a modulus-like bound $m$. For every integer shift $x$ in the range $[0, m-1]$, we look at the number $a + x$ and compare its greatest common divisor with $m$ against the original value $gcd(a, m)$.
We are working with a tree, which means there is exactly one simple path between any two vertices. From this tree we must choose three distinct vertices, call them $a$, $b$, and $c$.
The game can be seen as a process where we start with n opponents and repeatedly trigger rounds that remove some of them.
The graph in this problem is not given explicitly, but fully determined by the structure of integers. Every positive integer is a node, and each number $x 1$ has a directed edge to $x / f(x)$, where $f(x)$ is the smallest prime factor of $x$.
We are trying to reconstruct a hidden string of length up to 50. The string is guaranteed to use only three symbols: C, H, and O.
We are given a tree with $n$ nodes and $n-1$ edges. Each edge is assigned a distinct label from $0$ to $n-2$, so every label appears exactly once. For any pair of nodes $u, v$, we look at the unique path between them and collect all edge labels on that path.
We are given an array of non-negative integers. We are allowed to repeatedly decrease any element by 1 as long as it stays non-negative.
We are given a digit string and we are allowed to delete some of its digits while keeping the remaining digits in the same relative order.
We are given a hidden sequence of café types, where each café produces exactly one integer “coffee variety”. We do not know the sequence itself, but we can probe cafés one by one. The interaction tool behaves like a sliding-window memory system.
We are given a small set of integer vectors in the plane. Each vector can be used repeatedly as a step, and we form a closed polygonal walk by starting at the origin, repeatedly adding chosen vectors head-to-tail, and eventually returning to the origin.
We are given an array of numbers and a line of people who will remove elements from the array one by one. Each person, when it becomes their turn, sees the current array and takes either the leftmost or rightmost element.
We are building a sequence one element at a time, where after inserting the first i values, we take the current array and construct its Cartesian tree.
We are given a hidden array of length $n$, where each position represents a café and each café produces exactly one type of coffee. The value at position $i$ is the coffee variety label $ai$, but we never see it directly.
We are maintaining a dynamic “recent chat list” of friends, represented as a permutation of the numbers from 1 to n. The list is ordered from most recent to least recent interaction.
We are given a bipartite graph where every edge can optionally be assigned one of two colors, red or blue, or left unused. Coloring an edge is not free: red costs r, blue costs b, and leaving it unused costs nothing.
A hidden string of length $n$ is fixed before the game starts. The player’s goal is to recover this exact string. Instead of being given it directly, the only way to gain information is by querying substrings of ranges.
We are given a rooted tree where every node has a hidden integer value. What we do know is the tree structure and, for each node, a number ci.
We are dealing with a hidden string of length $n$, made of lowercase English letters. We cannot see the string directly. Instead, we can query any segment $s[l..
We are given a list of integers, and we are allowed to choose a single integer $X$. Once $X$ is fixed, every array value is transformed by XOR with $X$, and we care about the largest transformed value. The goal is to pick $X$ so that this maximum value is as small as possible.
We are given several intervals on a number line. Each interval represents a continuous segment of covered points. If multiple intervals overlap or touch, their combined covered region merges into a single continuous piece when we take the union.
We are given a list of positive integers and we want to choose two different positions in the list such that the least common multiple of the chosen values is as large as possible.
The task is to take a small grid with blocked and open cells and construct a special “maze representation” on a refined grid. Each input cell becomes a node in a graph, and adjacency exists between orthogonally neighboring open cells.