brain
tamnd's digital brain — notes, problems, research
43815 notes
We are given an undirected graph where each edge carries a positive integer weight. The task is to assign a value to every vertex so that for every edge, the larger of the two endpoint values is exactly equal to the edge’s weight.
We are simulating a rotating duty assignment over a sequence of days. There is a fixed group of students, initially all present in an active pool. Over time, some students may be added to the pool and others may be removed, with these changes scheduled to happen on specific days.
We are working with a dynamic array of integers where two kinds of operations are supported. One operation changes the value at a single position, and the other asks for information about a contiguous segment of the array.
The problem models a graph where traveling between cities is not only expensive in terms of edge weights, but also changes a secondary state called reputation. Each state of the system is described by a pair consisting of a node and a reputation value.
The task presents a single number written in text form rather than as a native integer type. The number may be extremely large, beyond what standard integer types in most programming languages can store, so it must be processed as a raw string.
The task is about locating all real roots of a real-valued polynomial within a fixed interval, specifically from −30 to 30, with high precision.
We are working on a grid-based shortest path problem where movement happens through a rectangular map. Each cell is either free or blocked by walls, and there are special cells: a starting point, a destination exit, and a badge location.
We are working with an undirected graph. The task is to determine whether a very specific structure exists: a cycle of length four, and in addition to that cycle, a short “branch” of length two that starts from one vertex of the cycle but does not reuse the other vertices of…
We are given a collection of integer values representing IQs of individuals. The task is to count or characterize subsets of these values based on their total sum, where the direct interpretation is that every subset contributes a combined IQ equal to the sum of its elements.
We are working with multiple queries over a range of integers, and for each query we need to compute the sum of all prime numbers that lie inside a given interval.
We are given a machine model where memory is arranged as several cachelines, and each cacheline contains many 8-bit variables. Every variable holds a value from 0 to 255, and all arithmetic is performed modulo 256, so values wrap around after 255. Two operations are available.
We are given a 3 by 3 board. Each cell is either a digit from 1 to 9 or a wildcard symbol. The board participates in a scoring system based on five special lines: the three rows and the two diagonals.
We are given a set of problems, each described by two numbers. The first number is a threshold requirement: Beraldo can only solve that problem if his current aura is at least that value. The second number is a reward: if he solves the problem, his aura increases by that amount.
We are given a sequence of snapshots of a queue. Each snapshot is a full ordered list of all students currently in the queue at some moment in time, and these snapshots are shown in chronological order.
The task is about detecting which words in a long transcript have been corrupted by a transformation process. You are given a single line containing thousands of space-separated words.
We are given a single pile of stones and two players who alternate turns, starting with Yvens. On each turn, the current player must remove either one stone or two stones from the pile.
We are given a long string S with no spaces, which is a noisy transcription of some original text. The transcription process may have corrupted up to K individual characters, meaning at most K positions in the original text were replaced by different characters.
We are given an $N times N$ binary matrix. We are allowed to freely reorder rows and columns any number of times, independently. After these permutations, we want to find the largest possible “C-shaped” pattern consisting only of ones.
We are given four points in the plane in a fixed order, A, B, C, D. The task is to determine whether connecting them in that order, including the edge from D back to A, forms a geometric square. This is not a “set of four points” problem where we can reorder arbitrarily.
We are given a rooted structure that evolves over a sequence of operations driven by a binary string. Initially, there are two “states” of the story, each represented by a numeric value: one main value and one auxiliary value.
We are given a string composed only of the characters a, b, and c. The task is to look at every contiguous substring and assign it a score based on how uneven the character distribution is inside that substring.
We are given a tree with labeled nodes and a fixed permutation that determines an order of processing. The construction builds a rooted tree by repeatedly selecting, from the currently remaining nodes, the one that appears earliest in the permutation among those still present.
We are given a tree, and every node carries a single uppercase letter. A query asks us to count how many simple paths in this tree contain exactly five nodes, and if we read the letters along the path in order, they must form the fixed pattern “S C C P C”.
We are given several strings, and we conceptually take every suffix from every string. A suffix is any substring that starts at some position and continues to the end. For example, in a string like “abc”, its suffixes are “abc”, “bc”, and “c”.
We are given a complete directed graph on $n$ labeled vertices where every pair of vertices has exactly one directed edge between them, forming a tournament. Among all such tournaments, we need to count how many contain at least one directed simple cycle of length exactly $k$.
We are given a sequence of numbers that we can think of as defining a polynomial-like transformation over a modular field.
We are given a binary sequence where every position is supposed to end up as either 0 or 1, but some positions are currently unknown. The unknown positions can be filled freely with 0 or 1.
We are given a directed graph where every edge carries two small positive weights. A path from node 1 to node N accumulates these weights separately: one sum is formed by adding all first components along the path, and another sum is formed by adding all second components.
We are given a permutation $q$ of length $n$. We need to count how many permutations $p$ of the same length satisfy two conditions. First, $p$ must be lexicographically larger than $q$.
We are given a hidden “encryption system” that works digit by digit on base-3 numbers of length $n$. At each position $i$, there is a fixed permutation $fi$ of the digits ${0,1,2}$.
We are given a mutable string over lowercase letters. The core quantity we track is defined over a fixed ordered pair of characters, specifically pairs where the first character is 'e' and the second is 'f'.
We are given a function defined on positive integers through their prime factorization. For a number $x$, we decompose it into prime powers $x = prod pi^{alphai}$.
We are given an array of positive integers of length up to 50. For every subset size $k$ from 2 up to $n$, we look at all subsequences of that size, chosen uniformly at random.
We are given a square grid whose side length is $2n$. Inside this grid, there is a fixed procedure described in a previous part of the problem (迷宫 I) that allows us to add edges between cells according to certain local rules.
We are given a graph where each vertex represents a planet and each vertex has a numeric value called its habitability. The graph is undirected, and edges represent bidirectional travel routes between planets.
We are given a rooted tree with root fixed at node 1. Each node carries a non-negative integer value. The only operation allowed is to choose a node u and an integer x ≥ 0, then XOR every node in u’s subtree with a value equal to a fixed bit pattern depending on x…
We are given two collections: horses with stamina values and carts with weights. Each horse must be assigned exactly one cart, and each cart can be used at most once. If a horse with stamina $Ei$ pulls a cart with weight $Wj$, its movement contribution is $max(Ei - Wj, 0)$.
We are given a list of files, where each file has a name and a permission string. The permission string encodes whether the file can be read, written, or executed using the familiar three-character format.
We are simulating a constrained survival process where time and oxygen are the same currency in different forms. Each second spent anywhere, digging or operating machinery, reduces the oxygen tank by one.
We are given a square arena with side length $r$, and a set of $n$ points representing heroes placed inside it. A random infinite line is generated in two stages: first a random point inside the square is chosen, then a random direction is chosen uniformly over all angles in…
We are asked to construct several different integer polynomials. Each polynomial must satisfy three structural constraints at the same time. First, it must be monic, so its highest-degree coefficient is exactly 1.
We are given a connected, simple undirected graph with $n$ districts and $m$ existing roads. District 1 is the starting point for every citizen.
We are given multiple independent scenarios involving three fixed participants: Alice, Bob, and Cindy. Each person is either a truth-teller or a liar.
We are given the first $N = 2 cdot 10^5$ terms of a sequence that is mostly generated by a fixed linear recurrence of order $k le 69$, but with occasional corruption. For the first $k$ positions, the values are arbitrary.
We are given a single block of gold with total mass $G$, and a group of $n$ people who contributed different amounts of effort.
Each cell of an n by n grid contains a fan that may or may not be active, and every active fan pushes wind only downward. A fan at position (i, j) with strength f influences a triangular region starting from itself and expanding as we go to lower rows.
Each test case describes a household where a group of servants must complete a set of chores. Every chore has a required amount of work, and every hour each servant contributes work depending on how they are assigned.
We are given an array and many operations on subarrays. Each query asks for a value derived from a randomized “absorption” process, and updates replace a whole segment with a fixed pattern.
The program described here takes an integer array and performs a simple filtering step before turning it into a vertical bar chart. All non-positive values are discarded, and the remaining values keep their original order.
We are given a directed graph where each node represents a puzzle. Every node starts with zero “energy”, and each node has a threshold value. A node becomes unlocked as soon as the total energy it has accumulated reaches or exceeds its threshold.
We are given $n$ people, and each person has a “name” made of three integers, which we can think of as a length-3 vector. We want to choose three distinct people $i, j, k$.
We are given a string that we want to reproduce using a peculiar typewriter mechanism. Instead of directly writing characters into the output, the machine reads from a template tape and copies into an output tape.
We are given a string and asked to count how many different non-empty subsequences we can form under a spacing restriction on positions.
A contest has already ended, and the scoreboard is frozen. You know your own team’s final result completely: how many problems you solved and your total penalty time.
We are given a grid with exactly two rows and $n$ columns. Some cells already contain a color label, while the rest are empty. We must assign colors to the empty cells so that every cell is colored, and the precolored cells remain unchanged.
We are given a multiset of integers, but duplicates do not exist initially. Each number is a 30-bit mask. We are allowed to repeatedly pick any two currently available numbers and apply exactly one of three bitwise operations between them, XOR, AND, or OR, and then insert the…
We are given a binary matrix with up to a million rows but only up to ten columns. Each cell initially contains either zero or one. We are allowed to repeatedly flip entire rows or entire columns, where flipping means toggling every bit in that row or column.
We are given a very simple device that can generate a string of a required length, but it has two ways of operating, each consuming time. The first operation is a single tap. Each tap takes one second and produces exactly one unit of output length.
We are given a set of points on a 2D plane. We must pick three points, allowing reuse of the same point, and designate them as A, B, and C. From A, we form two vectors pointing to B and to C, and we want to minimize the dot product of those two vectors.
We are given a sequence of length $n$, where each element is an integer in the range $[0, m-1]$. The key operation allowed is a global cyclic shift: we choose a single integer $k$, and every element $ai$ is replaced by $(ai + k) bmod m$.
We are given a string consisting only of uppercase English letters. We are allowed to apply a single global Caesar shift: pick an integer shift $k$, then every character is rotated forward by $k$ positions in the alphabet modulo 26.
We are given a system of players, each initially belonging to some faction. During the hidden part of the process, players repeatedly fight.
We are given a rule that builds an infinite undirected graph over positive integers. Each integer is a node. For a node $n$, we define a value $f(n) = n(n+1)$.
We are asked to construct a tree on $n$ vertices so that two quantities become equal: the size of a maximum independent set and the diameter length of the tree. A maximum independent set is a largest possible set of vertices where no two chosen vertices share an edge.
We are given 2n strings made of lowercase letters. We must split them into two groups of equal size, think of one group as “prefix side” strings and the other as “suffix side” strings. After that, we pair the two groups arbitrarily in a one-to-one matching.
We are given several test cases. Each test case provides an array of length $n$, where every element is an integer between $1$ and $n$.
We are given a sequence of operations on a multiset that starts empty. Each operation is either inserting a value or removing one element chosen uniformly at random from the current multiset.
We are given a single integer representing a year, and we need to decide whether it satisfies a very specific numeric property. The year is valid if two conditions hold simultaneously.
We are given a permutation of numbers from 1 to n, meaning every integer in this range appears exactly once and is arranged in some order along a line. Each operation gives us a segment [l, r] of this line.
Each game describes a set of timed targets on a line. Every target is a pair consisting of a time moment and a position on the line. Starting at time zero, Awa can choose any initial position and then move along the line with a fixed maximum speed.
We are given three integers $a$, $c$, and a prime modulus $p$. The task is to construct a large integer $b$ such that a specific congruence holds between two expressions built from these values.
We are working with a rooted tree whose structure is fixed, but whose root can change over time. Each node stores a weight, initially zero. On top of this tree, we are given a sequence of pre-defined path updates.
We are given a tree, meaning a connected acyclic graph. Each vertex represents a “core”, and edges represent allowed moves between cores. We are allowed to construct a walk on this tree, where revisiting vertices is permitted.
We are given a simple polygon described by its vertices in counterclockwise order. The polygon is non-degenerate, so edges only meet at endpoints, no three consecutive vertices are collinear, and it forms a proper closed shape.
We are given a collection of $N$ points in a 3-dimensional integer space. Each point represents a partner with three attributes $(S, F, E)$. The goal is to apply operations so that all points become identical, meaning every partner ends with exactly the same triple.
We are given a line of $n$ cups. Each cup starts in one of three states: empty, half full, or full. A full cup immediately overflows and effectively becomes empty, so after initialization only empty and half-full cups matter.
We are given two very small binary grids, each of size 3 by 3. Think of the first grid as configuration A and the second as configuration B. Every cell is either 0 or 1. We are allowed to perform three kinds of operations.
We are given a rectangular board of size $N times M$. Each cell is either already black or white. We are allowed to paint additional white cells black, but we are never allowed to repaint a black cell back to white.
We are given a quantum system consisting of $n$ qubits, and instead of a classical state like a bitstring, the system is described as a complex-valued vector of size $2^n$. Each index of this vector corresponds to one basis state, i.e., one binary string of length $n$.
We are given a single round of a very simple card game where exactly three cards are drawn. Each card has an integer value between 1 and 13. The score for the round is normally just the sum of the three values.
We start with a one-dimensional array, but instead of working with it directly, we use it to generate an $n times n$ matrix where every row is just a cyclic shift of the original array.
We are given two binary strings of equal length, which we can think of as two rows aligned vertically. On each query, we take a substring interval and are allowed to apply two local transformation rules inside that interval.
We are given a permutation of length $n$, meaning an arrangement of the numbers from $1$ to $n$ without repetition. For any position $i$, the contribution of that position is the distance between the value placed there and the index itself, taken in absolute value.
The university is enrolling up to n students in total. Every student must fall into one of two categories. If a student pays tuition, they contribute a fixed amount a to the university. If a student receives a scholarship, their funding comes from a sponsor.
We are given a circle with $n$ equally spaced points. Think of them as vertices placed around a round table in clockwise order, but their labels are unknown.
We are given a connected undirected weighted graph. On top of the existing edges, we are allowed to add up to k extra edges.
We are given a permutation of size $n$ and a target value $k$. We imagine running a binary search algorithm on this permutation, treating it as if it were a sorted array even though it may be completely arbitrary.
Each employee comes with two attributes: a rank value and a personal tolerance. The rank determines who they consider “higher” than themselves, and the tolerance specifies how many higher-ranked colleagues they are willing to tolerate in the same project team.
We are given a string and we want to find a substring that has a very rigid internal structure. Inside such a substring, we must be able to choose a length p and a starting position for a middle block so that the substring can be conceptually split into five consecutive parts.
We are given a system with n worker nodes arranged in a circle, indexed from 0 to n-1. Each task does not go to a single node, but instead generates a contiguous sequence of sub-tasks. A task is described by two values: a and b.
Two players are dealt full information about a bridge-like game. For every suit, each player already knows exactly how many tricks they would win if they became the declarer and chose that suit.
We are given a large rectangular chessboard and a single starting square. A piece called a knight can move in a generalized way: from any square it can jump either k steps in one axis and 1 step in the other, or the reverse, with all sign variations as long as the destination…
We are given two sequences of length $n$, each of which is a permutation of the numbers from $1$ to $n$. We are asked whether it is possible to construct a rooted tree on these $n$ labeled nodes such that one of the permutations can be obtained as a valid depth-first search…
We are maintaining a dynamic array where elements can change over time, and we must answer range queries about a multiplicative structure derived from those elements. Each query either updates a single position or asks about a segment of the array.
We are given a sequence that defines an ordering constraint between positions and another sequence that assigns a weight to each position.
A particle starts at position 1 on an infinite number line. A fixed parameter $Y$ is given. The particle evolves in discrete steps.
We are given a circular arrangement of N filters. Each filter has a threshold value, and particles move through these filters in a fixed direction. A particle starts at filter i with an initial phase equal to the threshold of that filter.
We are given a quantum circuit described as a sequence of reversible logic gates acting on an N-qubit system. Each gate is either a CNOT or a CCNOT.
We are given an $n times m$ grid where each column contains a vertical stack of colored blocks. There is also an extra “floating” block $d$, initially colorless.
We are given a system with two interacting sides: cities and groups of people. There are $n$ cities, each with a cost parameter $ci$, and $n$ groups of residents, where group $i$ contains $bi$ people.