brain
tamnd's digital brain — notes, problems, research
43815 notes
The maze is a network drawn on several concentric circular rings. Each ring contains up to 360 distinguished angular positions, called principal points, and these are the only places where the crystal can ever be located at the end of a phase.
The input gives a single prime number $P$, which represents the position of the final asteroid, called Silver Star, on a one-dimensional line starting from Mars.
Each input line describes a wine bottle volume written as a decimal number followed by the letter L. Different lines may describe exactly the same quantity even if they look different syntactically, for example 1.0L and 1L represent the same value.
We are given a collection of small polyomino pieces that can be rotated freely and placed on a grid that is exactly 2 cells tall and infinitely long to the right, but in practice we only care about forming a finite 2 × n rectangle.
Two players each control a single combat unit. Each unit repeatedly fires missiles at a fixed interval. A shot does not apply damage instantly, it lands half a second after being fired. Once a unit has fired, it must wait its reload time before it can fire again.
We are given a directed graph where each task is a vertex and each dependency is a directed edge. An edge a - b means task a must be executed before task b.
We are given two rigid structures in the plane: a plug and a socket. Each structure consists of three circular pins or holes. Each circle has a center and a radius, and within each structure the three circles are pairwise disjoint.
We are given a long sequence of integers representing an “urban development index” over time. This array is not static. Two types of operations happen online.
We are given a circular playlist consisting of n songs, each with a fixed duration. Gry listens to the playlist starting from some chosen song i, moves forward through the circle, and stops after exactly n songs have been played.
We are given a set of symbols, each symbol appearing exactly once in a string. From these symbols we choose a subset, and the order of chosen symbols is irrelevant, only which ones are included matters.
We are given a company with $n$ couriers, where $n$ is guaranteed to be divisible by three. Each courier has a strength value, and we must partition all couriers into exactly $k = n/3$ groups, each group containing exactly three people.
We are given a set of fixed positions on the boundary of a unit circular clearing, where each position is described by an angle in degrees. Think of these positions as allowed anchor points where fence posts may be installed.
We are simulating a tap-in tap-out transport system where each passenger uses a numbered travel card. Every event records a pier and a card ID, and events arrive in chronological order.
We are given a tree with (N) nodes. John wants to select disjoint pairs of nodes, with the restriction that a pair is valid only if the distance between the two nodes along the tree is even.
We are given a permutation of size $n$, meaning every integer from 1 to $n$ appears exactly once. For every pair of indices $(l, r)$, we look at the segment of the array from $l$ to $r$.
We are given a rooted tree with root fixed at vertex 1. Every vertex initially contains exactly one biscuit. We will perform exactly k operations. In one operation we pick a vertex x and immediately eat every biscuit that still exists on the simple path from x up to the root.
We are simulating two entities moving along a one-dimensional line of integer points from 1 to N. One of them, Olaf, moves deterministically: every minute he shifts one step to the right.
We are given two arrays of integers, each of length $n$. Every value in both arrays is small, at most $10^3$, but the arrays themselves can be large, up to $2 cdot 10^5$ elements.
We are given a sequence of days, where each day has a base cost for buying a coffee. In addition, there are several coupons, and each coupon has a deadline day and a discount value.
We start with a tree on n vertices. Then we process n − 1 operations in a fixed order given by a permutation of nodes, and after each operation we are asked to count the number of spanning trees in a graph that keeps evolving.
We are given a permutation of size $n$, meaning it contains each number from 1 to $n$ exactly once. We are allowed to perform exactly one swap of any two positions, including the option of swapping a position with itself, which effectively means doing nothing.
We are given an $n times n$ grid, and each cell must be assigned an integer from the range $[0, 4n^2 - 1]$. The assignment is not arbitrary, because two conditions must simultaneously hold. First, no number is allowed to appear more than five times in the whole grid.
We are given a collection of words, but the only property that matters about each word is its length. Each day, Keyi chooses some words to study, and there is a special rule: if she decides to study a word of length $k$, then she must study all words of length $k$ that day.
We maintain a multiset of integers that changes over time, and we must support two kinds of operations efficiently.
We are given a rooted tree whose nodes are labeled from 1 to n, and every node except the root stores a pointer to its parent. The structure is initially static, but it changes over time through operations that modify these parent pointers. Two types of operations occur.
We are given a sequence of positive integers and we are allowed to change values in it. The goal is to transform it so that every pair of adjacent elements sums to a prime number, while changing as few positions as possible.
We are given a grid with a small height but potentially long width. The grid has n rows and m columns. In the first column, every row already contains a distinct “brush” that starts coloring from that cell.
We are given two large integers, $A$ and $B$, which determine a binary string built by a deterministic greedy process. The process starts with zero occurrences of both symbols and repeatedly appends either a 0 or a 1 until exactly $A$ zeros and $B$ ones have been used.
We are given a perfect binary tree whose leaves are numbered in the usual heap style, so the leftmost leaf is 1 and every internal node corresponds to a contiguous segment of leaves. Each query specifies a segment of leaves $[l, r]$.
The process in this problem can be seen as a dynamic race between people and positions on a line of pizza pieces.
We are given a repeating schedule that alternates between work days and rest days. One full pattern consists of a block of x work days followed by y rest days, and then it repeats forever. This means the entire timeline is periodic with period x + y.
We are given an unknown grid of size $n times n$, where each cell contains a distinct integer height. The grid is not visible directly. Instead, we can only query individual coordinates and receive the height at that location.
We are given a collection of rooms connected by doors. Each door can be traversed in both directions, so physically the layout is an undirected connected graph.
We are given a rooted tree with $n$ vertices, numbered from $0$ to $n-1$. Each edge connects a node to its parent, so the input implicitly defines a rooted structure.
We are given a finite rectangular pattern made of four colors, but this pattern is repeated infinitely in both horizontal and vertical directions, forming an infinite tiling of the plane.
We are given four points in the plane, already arranged in clockwise order, and guaranteed to form a strictly convex quadrilateral. Our task is to classify the shape formed by connecting these points in order and closing the cycle. The classification is hierarchical.
There is a queueing system in front of a funicular that runs for a fixed number of minutes during the day. Each minute, a known number of people arrive and join the queue, and immediately after those arrivals are processed, a carriage departs and removes up to a fixed number…
We are given a collection of software packages, each with a known download size. At some moment during an upgrade process, we observe that exactly some number of packages have already fully completed downloading, while up to a fixed number of packages can be downloading at the…
We are given several absolute file paths in a Unix-like filesystem. We are allowed to choose a single working directory anywhere in the tree, but not inside a file.
Codeforces 104791C: Robot
We are simulating a line of people using a water dispenser that is fed by identical buckets, each containing a fixed amount of water. Every person in the queue wants a certain number of liters. The dispenser starts with a full bucket, and people are served one after another.
We are counting binary sequences of length $n$, where each position represents either a win or a loss in a sequence of games. A 1 means a win, a 0 means a loss.
Codeforces 104797B: Building on the Moon
We are given a set of points on a plane, each representing a city. The salesman must produce a single path that visits every city exactly once. He is allowed to start anywhere and finish anywhere, so the result is simply a permutation of all cities.
We are given a linear railway consisting of stations connected in a chain. Between each pair of neighboring stations there is a travel time. Two trains depart simultaneously: one starts at station 1 and moves right, the other starts at station n and moves left.
We are given a long string made only of lowercase letters and a small number of queries over substrings of this string. Each query focuses on a contiguous segment of the string, and asks us to find a very specific pattern inside that segment.
We are given a directed graph of villages connected by roads. Each road connects two villages and comes with a prescribed direction in the input, but we are free to assign a final flow of merchants on each road either in the given direction or in the reverse direction.
We are given an integer grid formed by all lattice points $(i, j)$ where both coordinates range from $0$ to $n-1$. From this set of points, we consider all straight lines in the plane and we want to count how many distinct lines pass through at least two of these grid points.
We are given a radar system that produces a finite set of scanned points in the plane. Each scanned point is formed by choosing a direction and a distance from the origin, then going that distance along that direction.
We are given a rectangular grid that contains lowercase letters and empty cells. Over time, gravity acts on this grid, but not in a fixed direction.
We are given a line of speakers, each speaker has an initial volume and a cost factor that tells us how much energy is needed to change its volume by one unit. Two kinds of operations are performed on contiguous segments of this line.
We are given a sparse grid of
We are given an undirected connected graph that has a restricted structure: every edge belongs to at most one simple cycle, so cycles can overlap only at vertices, not through shared edges. This is the standard definition of a cactus graph.
We are given an undirected graph that is already a tree, meaning there are exactly n nodes and n−1 edges and there is exactly one simple path between any two nodes. The distance between two nodes is the number of edges on this unique path.
We are given a printing shop that splits paper lengths into a sequence of contiguous segments. Each segment represents a range of page counts, and every range has a fixed cost per page.
We are given a string made of Latin uppercase letters and a parameter $k$. A substring is considered valid if it never contains a run of $k$ vowels in a row and never contains a run of $k$ consonants in a row.
We are simulating a very structured drafting process among four players sitting in a fixed cycle. Each round, every player takes exactly one knight token from a common pool until the pool is exhausted.
We are simulating a very simple earning process over a sequence of items called sailors. There are $n$ sailors available in total, and in each of $k$ rounds Igor takes exactly one sailor from what remains.
Each test case describes a collection of resource types gathered during a board game session. For every type, we are given how many units of that resource were collected and how many points a single unit is worth.
We are given a small dictionary of words that Veronica knows, and then a single long string that represents what Igor wrote down as her spoken monologue.
We are given four collections of names. Igor has a list of names he likes and a list of names he dislikes. Ira also has a list of names she likes and a list of names she dislikes. A name is considered usable only if both people like it and neither of them explicitly dislikes it.
We are given a sequence of tower heights placed in a row. Each tower has a numeric height, and we are allowed to pick some of them while preserving their left-to-right order.
We are given a small collection of integers, each between 2 and 15. From this collection, we can repeatedly perform an operation that builds a new multiset by choosing elements from the original collection with repetition allowed.
We are given a rectangular grid that represents a crawling mat. Each cell is either free space, an obstacle, a toy, or Veronica’s starting position. Veronica occupies exactly one cell and also has an initial facing direction indicated by the symbol at that cell.
We are given a diary of how Veronica sleeps during a day. Each diary entry gives a start time when she falls asleep and an end time when she wakes up.
We are given a single integer $n$, and we must decide whether it is possible to construct a square painting of some side length $k$, where $k le n$, under a very specific interpretation of “painting”. The painting is not just a uniform grid of cells.
We are given a connected network of cities that forms a tree. Each road connects two cities and has a weight. For any two cities, there is exactly one simple path between them because there are no cycles.
We are given a single addition written in an unknown numeral system. Three strings represent two addends and their sum, but the base is not provided.
We are working on an infinite 2D integer grid where every lattice point initially has the same default character ".". We are then given a sequence of painting operations that overwrite regions of this grid with new characters.
We are given two permutations of the numbers from 1 to n. The first permutation describes the initial order of a deck of cards from top to bottom, and the second permutation describes the target order we want to achieve.
We are given a large pool of cards split into a small number of types. Type $i$ contains $ai$ distinct cards, and we only care about collecting the first $bi$ distinct cards of that type. A single “refresh” draws one card uniformly from the entire pool.
We are given a graph that is a forest, so every connected component is a tree. The game starts with two players alternating moves, and each move modifies the graph in one of two ways.
I can’t write a correct Codeforces editorial for “104813K - Omniscia Spares None” without the actual problem statement.
We are given a very large $n times m$ grid, but most of it is empty except for a set of $k$ “walls”. Each wall is a vertical segment: it blocks an entire column $y$ from row $x1$ to $x2$. All blocked cells are impassable, and the rest are free cells.
We are given a small weighted undirected graph with up to ten vertices. The weights describe how strongly each pair of planets interacts.
We are given a set of cities, each carrying three independent parameters: Alice can collect some amount of material when visiting, Bob can also collect material when visiting, and each city has a selling value multiplier.
We are given a graph where every positive integer is a node, and for any two nodes $x$ and $y$, the cost of connecting them is determined by the number of distinct prime factors of their least common multiple.
We are given a grid where some cells are open and some are blocked. From a starting open cell, George can attempt to move in the four cardinal directions, but a move only succeeds if the adjacent cell exists and is open; otherwise he stays in place.
We are given two strings of equal length. One string, call it the reference string, defines a collection of patterns: every prefix of this string is a pattern, and each pattern has an associated weight.
We are given a sequence of values representing the happiness gained from a series of contests. After each contest, we want to compute a “memory-weighted mood” that depends on all past contests, but with exponentially decreasing influence for older events.
We are given an initial collection of “knowledge points”, each associated with a positive integer cost representing how many brain cells are required to maintain it. This collection is treated as a multiset, so only the frequencies of equal values matter, not their order.
We are given a large rectangular grid whose height is $2^N$ and width is $2^N - 1$. The grid is not arbitrary: it is built recursively by repeatedly splitting rectangular regions into smaller ones.
We are given a fixed integer $x$, which represents the length of one leg of a right triangle. The task is to count how many distinct right-angled triangles with integer side lengths exist such that one of the legs is exactly $x$.
We are given a line of positions from 1 to n, each position having a required minimum brightness. We also have several lamps, each lamp covering a contiguous segment of positions.
We are given a short string over lowercase English letters and a deterministic transformation that modifies it in two stages. First, the string is extended by inserting exactly one extra character.
We are given three positive lengths, which represent the sides of a triangle made from rigid wires. After that, an operation is repeated multiple times: every side is shortened by exactly one unit per operation.
We are asked to look at all possible labelled trees on $n$ vertices and compute a single numeric value for each tree: the sum of distances over all unordered pairs of vertices. This value is often called the Wiener index of the tree.
We are given a positive integer $a$. We want to construct a function $f$ on positive integers such that applying it twice behaves like multiplication by $a$, meaning that starting from any value $x$, if we apply $f$ once and then again, we land exactly on $a cdot x$.
We are given several independent games. Each game consists of a number of piles of stones. Two players alternate turns, starting with Mandy.
We are given a permutation of length $n$, and for any contiguous subarray we look at its maximum element. For a fixed permutation, we compute a global value $G(S)$, which is the sum of these maxima over all $n(n+1)/2$ subarrays.
We are given a sequence of integers, and this sequence is being modified through point updates. After each modification, we need to compute a value that comes from a rather unusual counting process involving polynomials.
We are given a collection of stick lengths and asked whether it is possible to pick exactly k of them so that they can serve as sides of a simple polygon.
We are given an undirected simple graph and asked to count how many subgraphs are exactly isomorphic to a fixed six-vertex pattern called “Four K3”. Although the diagram is not written in text, the structure is describable in words.
We are given a linear chain of islands from 1 to n. Consecutive islands are connected by directed edges from i to i+1, and each such edge has a fixed cost.
We are given a directed acyclic graph where each node represents a city and each city has a numeric charm value. The traveler must go from city 1 to city n along directed roads. The graph structure guarantees there are no cycles, so every valid route is a simple path in a DAG.
We are given a rooted tree with vertex 1 as the root. Each vertex has a depth, defined as how many vertices lie on the path from the root to that vertex.
We are given a collection of identical right triangles with side lengths 3, 4, and 5. Each triangle is a rigid tile, and we are allowed to place multiple copies on a plane without overlap.
We are given a single lowercase string and asked to count how many of its substrings contain the pattern "sysu" as a subsequence. A substring is defined by choosing a contiguous segment of the string, while a subsequence allows skipping characters without changing order.
We are working with a point on a number line from 1 to n. A frog starts at position 1 and wants to reach position n. At each move, it can jump forward by exactly 1 or exactly 2 steps.
We are asked to count how many binary $n times n$ grids exist under a local restriction: each cell is either 0 or 1, and we are forbidden from placing two 1s in adjacent cells that share a side. Diagonal adjacency does not matter, only up, down, left, and right.