brain
tamnd's digital brain — notes, problems, research
41641 notes
We are given a pile of stones and two players who alternate turns, with GG moving first. On each move, a player removes either one or two stones from the pile. The player who cannot make a move loses.
We are given a static array of integers. For each query, we are also given two numbers $a$ and $b$, which define a function on any value $x$: $$f(x) = (a oplus x) - b$$ where $oplus$ is bitwise XOR.
We are given a grid where each cell contains a symbol describing how it participates in a tiling made of L-shaped triominoes. Each L-shape consists of a center cell marked C and three adjacent arms extending in the four cardinal directions, labeled U, D, L, and R.
We are given five types of spirits, indexed from 1 to 5, and we have a certain number of copies of each type. Each spirit of type i has a fixed intrinsic value i. A single operation, called a “summon”, chooses some subset of available spirits.
We are given a 3D grid of cells with coordinates $(i, j, k)$. Each cell initially has a color, either black or white, and we are allowed to flip its color at a given cost.
We are given a permutation of size $n$, and we look at every inversion pair in it. An inversion is a pair of positions $i < j$ where the value at $i$ is larger than the value at $j$.
Codeforces 105223N: Larger but smaller!
Codeforces 105223M: Minimize Sum
We are asked to decide whether we can place $n$ distinct lattice points in the plane and connect them in a cycle so that all edges have equal Euclidean length, the polygon is simple (no self-intersections), and no three consecutive vertices lie on a single straight line.
Substituting special values is the first constraint.
Codeforces 105223F: Fire Kings
Codeforces 105223E: Lazy Fouad
We are given a rooted tree where each node represents a one-liter tank. Water can be poured into any chosen tank, but the filling does not stay local.
We are given an axis-aligned square and inside it several straight segments, each of which is either horizontal or vertical. The segments are strictly inside the square, but they may overlap or even coincide.
We are given several independent strings, and for each one we must decide whether it contains a specific pattern, the word “bitset”, as a contiguous block inside it.
We are given several independent test cases. Each test case describes a game state consisting of several piles of stones.
We are given an array that changes over time. After each update, we are asked to compute a global quantity built in two layers. First, take any non-empty subsequence of the current array.
We are given several test cases. In each test case, we receive an array of integers. Our task is to count how many pairs of positions $(i, j)$ with $i < j$ satisfy a very specific algebraic relationship between the values $ai$ and $aj$.
We start with an existing tree on $n$ vertices. We are allowed to add new vertices and connect them with edges, but we are not allowed to create cycles, so the final structure must still be a tree. After these additions, the resulting tree must satisfy two structural conditions.
We are given an array and for every position $i$, we want to count how many segments $[l, r]$ that include $i$ have a special property tied to bitwise AND.
We are given a line of students, each with a fixed initial height. The school is unhappy with any student who is strictly shorter than both of their immediate neighbors. The first and last students are exempt because they only have one neighbor.
We are given a tree, and only some nodes matter as “items to distribute”: the leaves. Every leaf must be assigned to exactly one of K groups.
We are given a one-dimensional board of positions from 1 to n. Each position i contains a jump length t[i]. If a ball is dropped at position i, it repeatedly performs deterministic jumps: from i it moves to i + t[i], then from that new position j it moves to j + t[j], and so…
We are maintaining an array that changes over time, and after each change we may be asked to compute an optimal score based on splitting the array into contiguous parts.
We are given a number of cards and asked to repeatedly construct the tallest possible “card pyramid”, remove the cards used, and continue until no further pyramid can be built. The final answer is how many pyramids were constructed across all iterations.
We are given a single string made of lowercase letters. From this string we may delete characters while preserving order, producing any subsequence.
We are given an array and we want to understand how “stable” each value is across fixed-length windows. For a chosen window size $k$, we slide a segment of length $k$ across the array. A number is considered good for this $k$ if it appears in every single such segment.
A direct Euclidean angle chase in the original configuration quickly becomes entangled because four different circles interact in a non-symmetric way: the circumcircle $G$, two internally tangent circ…
Each query gives a segment of integers and asks how many numbers in that segment share a specific value under a transformation function g. The function g takes a number and repeatedly replaces it with the product of its digits until the value becomes a single digit.
We are simulating a dynamic chat sidebar that always shows recent conversations first. Every time Polycarp sends a message to a friend, that friend’s chat becomes the most recently active and is moved to the very top of the list.
We are given a video of length c seconds. Each second of watching requires consuming a units of data, while the internet connection can download b units of data per second continuously.
We are given multiple independent queries. Each query describes a triangle in the plane using three points. A vertical light source shines from above, and every point of the triangle casts a vertical projection downwards onto the ground.
We are looking at a sequential game played by people sitting in a circle. Each player has a fixed “favorite number”. A single die with faces from 1 to m is rolled repeatedly, but the rolls are not globally shared.
We are given a fixed set of dictionary words, each very short, and then a large number of queries. Each query provides a word and a rank. For a query word, we compare it against every dictionary word using suffix matching.
We are given an array where each element is a large integer up to 10^18, and we need to support two operations. One operation updates a single position in the array.
We are given a collection of pigeon species, where each species has a limited supply of pigeons available for purchase. The goal is to build as many identical pigeon houses as possible.
We are given several independent scenarios. In each scenario there are $n$ steps, each with a height value, and a frog that moves from the leftmost step to the rightmost step. The frog can rearrange the steps in any order before starting its journey.
Two players stand on a tree, initially anchored at node 1. They take turns moving a token along edges, always stepping to a neighbor of the current node. Once a node has been visited, it is removed from consideration, so the token can never return to it.
The condition states that $n^{p-1}$ divides $(p-1)^n+1$, with $p$ prime and $n \le 2p$.
Codeforces 105229I: 六元组计数
We are given a set of missions, each mission i has a cost of time Ai and a value Bi. A person has a total time budget M and can choose a subset of missions to complete, each at most once, in any order, as long as the total time spent does not exceed M.
We are given a line of $n$ water lilies labeled from left to right. We need to design two independent directed systems of connections on these positions. The first system belongs to a frog.
We are given a rooted tree where each node represents a state in a diffusion process. Starting from the root, a token moves downward until it reaches a leaf.
We are given several independent test cases. Each test case provides an array of positive integers. From this array we consider every contiguous segment and compute its sum.
We are observing a gacha system that produces a sequence of “gold intervals”. Each interval is the number of draws between two consecutive gold pulls, and that interval is a random variable whose distribution depends on a counter that evolves during the same interval.
We are asked to count how many monotone paths exist on an $n times n$ grid from the bottom-left corner $(0,0)$ to the top-right corner $(n,n)$, where each move increases either the x-coordinate or the y-coordinate by exactly one.
Each hero comes with two labels, think of them as two “bond types”. Every bond type appears on at most two heroes in total. A bond becomes active only when both heroes that contain it are selected.
We are given a line of positions, and at every position there are two possible “actions” available. Each action is either an addition of a fixed value or a multiplication by a fixed value.
We are given a long sequence of letters, and we are allowed to freely rearrange any of them after “cutting” them out of the original text.
We are given a set of points on the plane, and we must cover every point using exactly two geometric covering devices. One device is a circle and the other is a square.
We are working on a grid of integer lattice points inside a rectangle from (0, 0) to (n, m). For every lattice point (a, b), we must count how many distinct geometric squares can be formed such that (a, b) is one of the four vertices and all four vertices lie inside the…
We are given a tree where each node stores an integer weight. For any two nodes, we can look at the unique path between them and compute the bitwise XOR of all node weights along that path.
We are given a rectangular grid where each cell represents either a wall, an empty passage, a trap, the starting position, or a cell containing a numeric amount of treasure. From the starting cell, movement is allowed in four directions.
The condition requires a set of marked squares such that every square of an $n\times n$ board is either marked or shares a side with a marked square.
We are given a rectangular grid with $n$ rows and $m$ columns. A piece starts at the top-left cell and moves like a bishop, meaning it always travels diagonally.
We are given a set of ingredients, and some pairs of ingredients are known to taste the same. That relation is not just pairwise, it extends transitively, so if ingredient A matches B and B matches C, then A, B, and C all belong to the same flavor group.
Codeforces 105230F: Franklin is Back
We are maintaining an array where each element is a small positive integer, and we are interested only in its prime factor structure.
We are given a one-dimensional path encoded as a string of + and -. We start at an implicit height of zero before processing the string. Each character moves the current height by exactly one unit: + increases height by one, - decreases it by one.
We are given a single integer $n$, and we want to express it as a product of integers greater than 1. The twist is that among all possible factorizations, we are not optimizing for simplicity or minimal number of terms, but for the opposite: we want to maximize how many…
We are given a list of integers, and for each one we repeatedly apply a transformation: replace the number with the sum of its proper divisors, meaning all divisors strictly smaller than the number itself.
Codeforces 105230A: Areas
We are given a classroom with $n$ students, each independently assigned a birthday uniformly over 365 days. We are asked for the probability of a very specific configuration.
Each of the 60 cards corresponds to a fixed pattern over the positive integers. A number appears on a card exactly when it satisfies a certain binary condition derived from that card’s index.
Let $S=\sum_{1\le i<j\le n} x_i x_j (x_i^2+x_j^2)$ and $T=\sum_{i=1}^n x_i$.
The condition says that for every pair of distinct points $A,B \in S$, the perpendicular bisector of segment $AB$ is a symmetry axis of the entire finite set $S$.
Codeforces 105231A: Maliang Learning Painting
Substituting small values reveals structural rigidity.
The configuration centers on the intouch triangle of $ABC$.
The divisibility condition is $ab^{2}+b+7 \mid a^{2}b+a+b$.
We are given a one-dimensional field of leeks represented by an array. A worker starts at a fixed position and moves along this line for a fixed number of time steps. At every step, all leeks grow uniformly by the same amount.
For each prime exponent $a$ in $n=\prod p_i^{a_i}$ the ratio contributes a factor
For each contestant, the pattern of ratings by the $b$ judges can be encoded by a binary vector of length $b$, where $1$ represents a pass and $0$ represents a fail.
Placing $P$ at the origin is safe because the perpendicular bisector conditions $PA=PB$ and $PC=PD$ become $|a|=|b|$ and $|c|=|d|$.
We are given a weighted undirected graph representing a campus. Each node contains a number of tourists, and certain nodes are designated as gates. Each gate is only active during a specific time interval. Over time from 1 to T, the set of active gates changes.
We are given a graph that is extremely simple in structure: a grid with 2 rows and $m$ columns. Each cell $(i, j)$ is a vertex, and edges exist only between orthogonally adjacent cells.
We are given multiple independent hands of Mahjong, each consisting of 14 tiles encoded as a 28-character string. Each tile is written as a value plus a suit or honor marker, so every tile occupies exactly two characters in the input.
We are given a set of points in the plane, and we should think of every pair of points as being connected by a segment. Each such segment corresponds to one “enemy” that can appear at any position along that segment, but its exact location is not fixed in advance.
We are given a large numeric grid, think of it as a matrix of values. We also fix the size of a smaller rectangular “filter” of size $k times l$.
We are given a very large integer written in base 11, but we never see it as a continuous string. Instead, the number is encoded as a sequence of blocks. Each block says “repeat digit d exactly k times”, and concatenating all blocks gives the full base-11 representation.
We are given a tree of up to two hundred thousand nodes. Each edge is marked with a value 0 or 1, and over time these edge values can flip between broken and working. The structure of the tree itself never changes, only whether an edge is currently usable.
We are given a sequence of positive integers and asked to construct two different subsets of indices such that the sum of values chosen by the first subset equals the sum of values chosen by the second subset.
We are given a sequence of positive integers. We are allowed to repeatedly pick any two positions in the sequence and replace the pair using a deterministic transformation: one position becomes the gcd of the pair, the other becomes the lcm of the pair.
We are given a set of players, each of whom claims to own a certain integer value. However, these claims may or may not be true. The actual values assigned to all players must sum up to a fixed total $s$.
Testing the structure of partitions of $2^n$ into powers of $2$ for small $n$ shows that multiplicities alone do not determine any canonical pairing process.
The equation is
We are given a square grid of size $n times n$. The first row is fixed: it contains the numbers from 1 to $n$ in order. Every cell below is generated deterministically: each entry is the square of the number directly above it in the same column.
The condition states that for every index $i$, every symbol in $S={1,2,\dots,2n-1}$ must appear at least once in the union of row $i$ and column $i$.
The previous argument fails because it attempts to control prefix sums via a greedy choice that is not guaranteed to be feasible at every step, and it incorrectly infers global bounds from stepwise bo…
We are given a sequence of integers, and we are allowed to remove exactly one element from it. After removing that element, the remaining elements keep their original order, forming a shorter sequence. On this modified sequence, we look at all prefixes.
Substituting small configurations clarifies the failure of any approach relying on a relation between $\angle BAU$ and $\angle CAU$.
A black–white checkerboard coloring on $\mathbb{Z}^2$ can be encoded by the function $c(x,y)=(-1)^{x+y}$, where one color corresponds to $+1$ and the other to $-1$.
The sequence $(x_i)_{i=0}^n$ evolves by steps of fixed sizes $p$ or $-q$, with $p,q>0$, and starts and ends at $0$.
We are given a number of candies, called Zingers, initially held by Kaito. Before any distribution happens, a character named Taim is allowed to secretly take up to k Zingers for himself.
We are given an array and allowed to perform a single operation at most once. The operation selects a contiguous segment, computes the mex of that segment, and then overwrites every element inside the segment with that mex value.
We are asked to enumerate sequences of length n where every element is a positive integer and neighboring elements differ by at most one.
The configuration consists of a convex hexagon $ABCDEF$ with three pairs of parallel sides: $AB \parallel DE$, $BD \parallel EF$, and $CD \parallel FA$.
Let
We are given a tree where each node carries two attributes: a weight and a color. From this tree we want to select a subset of vertices with two simultaneous restrictions. First, no two chosen vertices may be adjacent in the tree, so the chosen set must be an independent set.
We are given three integers $R$, $x$, and $y$. We consider all integer segments $[l, r]$ such that both endpoints lie between 1 and $R$. For each such segment, we look at how many numbers inside it are divisible by $y$.