brain

tamnd's digital brain — notes, problems, research

41641 notes

CF 105453D - Deciphering Ancient Symbols

The task is to analyze a string written on an ancient tablet and determine how much of it can be interpreted using a set of known “meaningful fragments”. Each fragment is a short string that is already understood.

codeforcescompetitive-programming
CF 105453A - The Binary Chicken Farm

We are given a directed influence network over N chickens. Each chicken maintains a binary string state of fixed length L, and this state evolves day by day. On day 1, every chicken has an initial binary string.

codeforcescompetitive-programming
CF 105453C - Fair Split of the Golden Tablet

The problem describes a geometric situation involving a circular region and a cut that divides it into two parts. One part is a “green” segment-like region whose area depends on a height parameter $h$, the radius $R$, and the geometry of a circular segment.

codeforcescompetitive-programming
CF 105450I - Can I Find My Candy?

We are given an array of integers of length $n$. Each position stores a number that represents how many candies are in that bag.

codeforcescompetitive-programming
CF 105450G - Treat or Trick

We can view the street as two parallel rows of houses, each row having $n$ positions. From any house at position $i$, Julia can move left or right along the same row, or switch vertically to the other row at the same position.

codeforcescompetitive-programming
CF 105450H - Warhead Games

We are given a rectangular grid where each cell is either usable or blocked. A token starts at the top-left cell and two players alternate moves.

codeforcescompetitive-programming
CF 105450E - Give Me Your Candy

We are given a line of candies, each with a numerical value representing how enjoyable it is to eat that candy. These values can be positive or negative, so taking a candy can either help or hurt the total enjoyment.

codeforcescompetitive-programming
CF 105450D - Trick or Treat

We are given a set of points on a 2D grid, and we start from the origin at coordinate (0, 0). We want to choose a direction and walk in a straight line passing through the origin. While moving along that line, we collect all candies that lie exactly on it.

codeforcescompetitive-programming
CF 105450C - Sour Straws

We are given a collection of integer lengths, each representing a sour straw. From these, we want to choose a subset such that when we sort the chosen lengths in nondecreasing order, every smaller element divides every larger element that comes after it.

codeforcescompetitive-programming
CF 105418C - Reduce or Divide

We start with a number $n$ that is encoded in binary, but the string is given in reverse order, so the least significant bit comes first. The first task is simply to interpret this string correctly as an integer. Two players, Bob and Alice, alternate moves starting from Bob.

codeforcescompetitive-programming
CF 105417J - Egg Placement

We are given several points on a grid, each representing an egg. The “compactness” of the farm at any moment is the sum of Manhattan distances over all unordered pairs of eggs.

codeforcescompetitive-programming
CF 105417G - The Chicken and the Egg

We are given a directed graph where movement along each edge takes different time depending on whether we are simulating a chicken or an egg. There are several designated entrance nodes where the experiment can start, and several exit nodes which represent success states.

codeforcescompetitive-programming
CF 105417F - Incubation Line

We are given positions of eggs placed on a number line, each at a distinct integer coordinate. We are allowed to install at most k heat lamps, and each lamp can also be placed at an integer coordinate on the same line.

codeforcescompetitive-programming
CF 105417D - Scrambled!

We are given a multiset of lowercase letters. These letters were originally arranged into a string with two properties. First, the string was a palindrome, so its left half determines its right half by symmetry.

codeforcescompetitive-programming
CF 105416G - The Chicken and the Egg

We are given a directed graph where moving along each edge has two different costs depending on the traveler: one cost for a “chicken” and another for an “egg”.

codeforcescompetitive-programming
CF 105416E - Yodel Yolk

We are given a one-dimensional landscape where each position has an integer height. Think of it as a sequence of vertical columns of different heights placed side by side.

codeforcescompetitive-programming
CF 105416C - Egg Order

We are asked to arrange the numbers from 1 to n in some order, forming a permutation. Inside this permutation, we look at contiguous segments, and we care about segments where values increase by exactly 1 at every step.

codeforcescompetitive-programming
CF 105416D - Scrambled!

We are given a multiset of lowercase letters. These letters originally came from a string that had a very strong structure: it was a palindrome, and among all possible palindromes that could be formed using exactly these same letters, it was the lexicographically smallest one.

codeforcescompetitive-programming
CF 105408E - Expected Closest Friend

We are given a weighted, undirected, connected graph of cities. Jorge lives at city 0. Each edge represents a road with a positive length, and shortest paths define the distance between any two cities. Jorge has k friends, and each friend independently occupies a distinct city.

codeforcescompetitive-programming
CF 105404D - Coins 3

We are given a multiset of coin values and a target amount $k$. Pedro processes the coins in a very specific way: he sorts them in descending order and scans from largest to smallest. While scanning, he maintains a remaining amount he still needs to pay.

codeforcescompetitive-programming
IMO 1969 Problem 6

The expression involves two triples $(x_i,y_i,z_i)$ constrained by $x_i>0$ and $x_i y_i-z_i^2>0$.

imomathematicsolympiad
CF 105404E - Separated Cells

We are given a tree, meaning a set of nodes connected with exactly one simple path between any two nodes. Each node represents a prison cell that can hold at most one inmate.

codeforcescompetitive-programming
CF 105404A - No More Ties!

We are given several independent scenarios. In each scenario, a contest has a list of participant scores and only the top k participants are supposed to qualify.

codeforcescompetitive-programming
CF 105403A - Pieces

We are given a very short board with only up to three rows and an extremely long number of columns. The task is to cover every cell of this board using rectangular tiles of three possible sizes: single cells, dominoes covering two adjacent cells, and triominoes covering three…

codeforcescompetitive-programming
CF 105403E - Directing the Roads of Grafolandia

We start with a connected undirected graph representing cities and bidirectional roads. The government wants to choose exactly k of these roads and assign a direction to each selected road so that, after this operation, every city can still reach every other city using only…

codeforcescompetitive-programming
CF 105403D - The Route of the 12 Lakes

We are given a circular structure of lakes, where consecutive lakes are connected by weighted roads. If we walk from lake i to i+1 (and from n back to 1), we pay the corresponding edge cost.

codeforcescompetitive-programming
IMO 1969 Problem 5

A convex quadrilateral is determined by four points in convex position, meaning all four lie on the boundary of their convex hull and no one lies in the convex hull of the other three.

imomathematicsolympiad
CF 105401M - White-Black-Tree

We are given a tree where every vertex is initially colored either white or black. The tree structure is fixed, but we are allowed to perform operations that swap the colors of two endpoints of any edge, and each such swap costs one unit.

codeforcescompetitive-programming
CF 105401L - Simple Tree Decomposition Problem

We are given a tree with $N$ vertices. We are allowed to remove any subset of edges. Once those edges are removed, the tree splits into connected components. The requirement is that every resulting connected component must have size either $A$ or $B$.

codeforcescompetitive-programming
CF 105401J - Running in the Plane

We are given a finite set of integer points in the plane, and we want to construct a small collection of allowed step vectors such that we can build a walk starting from the origin that visits every given point. The walk is a sequence of lattice points starting at $(0,0)$.

codeforcescompetitive-programming
CF 105401F - Jenga Game

We are given a vertical Jenga tower made of $N$ horizontal layers, each layer having three possible block positions. Each position is either present or missing.

codeforcescompetitive-programming
CF 105401H - Mosaic

We are given a grid of numbers that is supposed to come from an unknown black and white painting. Each cell of the grid is labeled with how many black cells appear in the 3 by 3 neighborhood centered at that position.

codeforcescompetitive-programming
CF 105401A - Automata Embedding

We are given a string of length $n$ over an alphabet of size $C$, but instead of working with the string directly, we look at its structure through the KMP prefix-function (failure function).

codeforcescompetitive-programming
CF 105401E - Hexagonal Tiling

We are given a regular hexagon of side length $N$, already decomposed into a fixed grid of unit equilateral triangles. The task is to cover the entire region using unit rhombuses, where each rhombus is formed by joining two adjacent unit triangles sharing an edge.

codeforcescompetitive-programming
CF 105401D - Graceful Triangles

We are given a fixed graph structure built from a chain of equilateral triangles. The vertices are laid out in a straight line, labeled from 1 to $n+2$.

codeforcescompetitive-programming
CF 105394K - Kitten of Chaos

We are given a long string composed only of four characters: b, d, p, and q. This string is printed on a rigid glass object.

codeforcescompetitive-programming
CF 105394M - Musical Mending

We are given a sequence of pitch offsets for piano keys relative to the first key. These values describe the current relative tuning, not the absolute frequencies, but they are consistent in the sense that shifting every key by the same constant would represent a valid…

codeforcescompetitive-programming
IMO 1969 Problem 4

Place $AB$ as a horizontal segment with $A,B$ fixed and the semicircle $\gamma$ above $AB$.

imomathematicsolympiad
CF 105394I - Interference

We are given a sequence of operations over a very large one-dimensional line, where positions can go up to 1e9. Two types of operations are performed online. The first type inserts a wave.

codeforcescompetitive-programming
CF 105394G - Geometric Gridlock

We are asked to fill an $h times w$ grid completely with connected pieces of size five cells. Each piece must be one of the classical pentomino shapes, meaning it is a connected set of five unit squares matching one of the twelve allowed geometric forms up to rotation and…

codeforcescompetitive-programming
CF 105394F - Fair Fruitcake Fragmenting

We are given the boundary of a simple polygon that represents a cake. The polygon is described by its vertices in counterclockwise order, and it has a strong structural property: it is invariant under a 180 degree rotation.

codeforcescompetitive-programming
CF 105394C - Copycat Catcher

We are given a reference program written as a sequence of tokens, and then multiple query programs. Each program is already tokenized, so we do not deal with raw characters but with a list of strings.

codeforcescompetitive-programming
CF 105390E - Innocent Students

We are given an array of integers representing answers from students sitting in a line. Each query either changes one student’s answer or asks about a contiguous segment of students together with a hypothetical correct answer value x.

codeforcescompetitive-programming
CF 105390A - Simple Update - I

We are given a binary string, meaning each position is either 0 or 1, and we are allowed to repeatedly apply a very specific local transformation.

codeforcescompetitive-programming
CF 105390F - Red Blue Tree

We are given a tree where each node carries two independent pieces of information: a color, either red or blue, and a positive weight.

codeforcescompetitive-programming
IMO 1969 Problem 3

A tetrahedron has six edges, so for each fixed $k \in {1,2,3,4,5}$ we are distributing edge lengths $a$ and $1$ across the complete graph $K_4$ in a way that can actually arise from a Euclidean embedd…

imomathematicsolympiad
CF 105388B - Square Locator

We are asked to reconstruct a geometric object from partial metric information. There is a square in the plane whose vertices lie on integer coordinates.

codeforcescompetitive-programming
IMO 1969 Problem 2

The expression is a finite linear combination of shifted cosine functions with positive weights decreasing geometrically.

imomathematicsolympiad
CF 105316D - Switching To Windows

We maintain a collection of labeled strings. Each string is introduced by a query, and from that moment it behaves like an object with an identifier equal to the time it was inserted. Alongside each string we store a numeric value.

codeforcescompetitive-programming
IMO 1969 Problem 1

The requirement is to construct infinitely many natural numbers $a$ such that for every natural number $n$, the integer $n^4 + a$ is composite.

imomathematicsolympiad
IMO 1968 Problem 6

The expression is

imomathematicsolympiad
IMO 1968 Problem 5

The functional equation applies a transformation

imomathematicsolympiad
IMO 1968 Problem 4

Assume a tetrahedron with vertices $A,B,C,D$ satisfies the opposite of the claim, meaning that at every vertex the three incident edges fail to form the sides of a triangle.

imomathematicsolympiad
CF 105388L - All-You-Can-Eat

We are interacting with a sequence of meals that arrive one by one, each carrying a non-negative calorie value. At any moment we may either ignore a meal or take it, but taking it adds it permanently to a current “plate set” whose total calorie sum must never exceed 1000.

codeforcescompetitive-programming
CF 105388H - Game Design

We are asked to count how many ways we can wire a system of one-to-one connections between entry portals and exit portals spread across levels 1 to n.

codeforcescompetitive-programming
CF 105388K - String and Nails

We are given a set of points in the plane, called nails. At any moment we imagine wrapping a tight rubber band around all remaining nails, so the band forms the convex hull of the current set.

codeforcescompetitive-programming
CF 105388D - Cycle Game

We are given a rectangular grid of size $n times m$, initially empty. Moves arrive one by one in a fixed order, and each move paints a previously unpainted cell black. After each move, we need to decide whether that move is allowed to be placed or whether it should be skipped.

codeforcescompetitive-programming
CF 105388F - Alternating Cycle

We are given a set of points in the plane, with the guarantee that no three are collinear. From this set, we are allowed to choose a non-empty subset and arrange it in a cyclic order.

codeforcescompetitive-programming
CF 105387N - Entomologist

We are given a partially corrupted description of a sequence that originally came from a simple formula. There is an unknown integer value $k$, and for each index $i$, the intended value is obtained by dividing $k$ by $i$ and rounding to the nearest integer using standard…

codeforcescompetitive-programming
CF 105387M - Cinema

We are given a row of $n$ seats and $n$ students. Each student has a preferred seat number, and each student also has a personal dissatisfaction cost parameter.

codeforcescompetitive-programming
CF 105387I - Line pinball

We are given a line of positions numbered from 0 to n. From each position i there is a fixed “launcher” that sends a ball forward. The distance it moves depends on the ball’s weight x through the expression i + floor(pi / x). A ball always starts at position 0.

codeforcescompetitive-programming
CF 105387G - Cubes

We are asked to count how many sequences of length n can be formed using three colors, red, green, and blue, where each position in the sequence is a cube.

codeforcescompetitive-programming
CF 105387J - There

We are simulating a constrained walk on a grid that represents a shop. The grid has $n$ rows and $m$ columns, where each cell is either empty or blocked. A person starts in the bottom-left corner of the grid and then follows a long sequence of movement commands.

codeforcescompetitive-programming
CF 105387E - Practical numbers

We are given a special class of integers called practical numbers. A number is practical when every integer from 1 up to that number can be formed as a sum of distinct divisors of the number.

codeforcescompetitive-programming
CF 105387C - Martian Meteorology

We are given a sequence of distorted 32-bit integer measurements coming from a Martian temperature sensor. The hardware fault is consistent across time: some fixed subset of bit positions has been flipped in every measurement, meaning that for those positions every recorded…

codeforcescompetitive-programming
CF 105387D - DNA

We are given a single long DNA strand composed of the four characters A, C, G, and T. From this strand, we can derive a second strand by applying a fixed pairing rule character by character: A pairs with T, and C pairs with G, and the pairing is symmetric.

codeforcescompetitive-programming
CF 105386K - Permutation

We are given a hidden permutation p of length n, meaning each number from 1 to n appears exactly once, but we do not know the order. We can ask queries. Each query is another length-n array q, where each entry is also between 1 and n.

codeforcescompetitive-programming
CF 105386L - Trails

We are working on an infinite grid of integer points. From every lattice point, you can move one step right or one step up for free, because there are standard unit edges in those directions.

codeforcescompetitive-programming
CF 105386H - Subarray

We are given an array of integers and we look at all possible contiguous subarrays. For any fixed subarray, we focus on its maximum value and we also count how many times that maximum value appears inside the subarray.

codeforcescompetitive-programming
CF 105386B - Gold Medal

There are several contests running in parallel. Each contest already has some number of participating teams, and you are allowed to distribute an additional pool of teams across these contests however you want.

codeforcescompetitive-programming
CF 105386D - Generated String

We start with a fixed base string $S$. Every operation builds new strings by cutting several substrings from $S$ and concatenating them in order.

codeforcescompetitive-programming
CF 105386E - Relearn through Review

We are given an integer array and a single operation that can be applied at most once. The operation picks a contiguous segment and adds a fixed value $k$ to every element in that segment.

codeforcescompetitive-programming
CF 105385K - Matrix

We are asked to construct an $n times n$ integer matrix using values from $1$ to $2n$, with two simultaneous requirements that interact in a very constrained way. First, every integer in the range $1 dots 2n$ must appear at least once somewhere in the grid.

codeforcescompetitive-programming
CF 105385H - Stop the Castle

We are given a large infinite chessboard, but only a small number of cells are occupied by two types of objects: castles and existing obstacles.

codeforcescompetitive-programming
CF 105385G - Cosmic Travel

We are given a fixed array of integers, and we imagine that every non-negative integer labels a “universe”. In universe j, each original value ai is transformed into ai XOR j, and then we sort these transformed values.

codeforcescompetitive-programming
CF 105385D - Hero of the Kingdom

We are given a trading simulation where a player can repeatedly convert money into flour and then convert flour back into money at a better price. The player starts with some amount of gold and has a limited amount of time.

codeforcescompetitive-programming
CF 105385C - Colorful Segments 2

We are given several independent test cases. Each test case consists of a set of closed segments on a number line, and we must assign each segment one of k colors. The restriction is that if two segments share the same color, they must not intersect at any point on the line.

codeforcescompetitive-programming
IMO 1968 Problem 3

Let $f(x)=ax^2+bx+c$.

imomathematicsolympiad
CF 105384L - Lalo's Lawyer Lost

We are given an undirected graph with a special structure: every edge belongs to at most one simple cycle. This means the graph is a cactus, so cycles do not overlap except possibly at shared vertices, and if you remove cycle edges appropriately the remaining structure becomes…

codeforcescompetitive-programming
CF 105384K - Knocker

We are given an initial array of small positive integers. One operation chooses a positive integer $x$, and then every element of the array is simultaneously replaced by its remainder when divided by $x$.

codeforcescompetitive-programming
CF 105384H - Highway Hoax

We are given a directed tree, meaning there are n nodes and n−1 edges, and if we ignore edge directions the graph is connected and acyclic. Each node is labeled either S or F.

codeforcescompetitive-programming
CF 105384G - Goodman

We are given a permutation $p$ over numbers from $1$ to $n$. We are allowed to choose another permutation $q$, which is simply an ordering of the same $n$ elements.

codeforcescompetitive-programming
CF 105384D - Daily Disinfection

We are given a line of positions representing a shelf. Each position is either empty or occupied by a book. The goal is to make every position “clean”, but there is a restriction: a position containing a book cannot be cleaned directly.

codeforcescompetitive-programming
CF 105384A - Aibohphobia

We are given a string for each test case and are allowed to permute its characters arbitrarily. After choosing a final arrangement, we examine every prefix of length at least two. The requirement is that none of these prefixes is a palindrome.

codeforcescompetitive-programming
CF 105383L - Lexicopolis

We are working on a directed graph where each edge has a weight that should be thought of as a “label” rather than a cost. A path is defined as a sequence of exactly $k$ directed edges starting at a fixed node $s$ and ending at a fixed node $t$.

codeforcescompetitive-programming
CF 105383K - Kingdom's Development Plan

We are given a set of projects, each labeled from 1 to n, together with a list of dependency rules of the form “project a must be finished before project b can start.

codeforcescompetitive-programming
CF 105383I - In Search of the Lost Array

We are given a hidden integer array of length $n$, where every element is between 1 and 100. We do not see the array directly. Instead, we are given the multiset of products formed by every pair of adjacent elements in that array.

codeforcescompetitive-programming
CF 105383H - Harmonious Passage of Magicians

We have two groups of agents starting at opposite ends of a one-dimensional corridor that contains exactly one extra empty cell.

codeforcescompetitive-programming
CF 105383D - Disbursement on Quarantine Policy

We are given a rectangular arrangement of passengers, modeled as an $n times m$ grid. Each cell represents one seat and contains either a definitely infected passenger, a definitely healthy passenger, or an uncertain passenger who is independently infected with probability $1/2$.

codeforcescompetitive-programming
CF 105383F - Fibonacci Lucky Numbers

We are given several test cases. Each test case provides an integer $n$, and from it we construct a very large index based on a power-of-seven expression: the target index is $7^n$.

codeforcescompetitive-programming
CF 105383B - Business Magic

We are given a line of stores, each store having a current profit value, which can be positive or negative. The goal is to maximize the total profit after applying at most one global operation called a blue spell and any number of local operations called green spells, with the…

codeforcescompetitive-programming
CF 105381M - The Tale of Professor Alya and the H-Index

We are given a list of citation counts for a researcher’s papers, already sorted in non-increasing order. Each number represents how many times a particular paper has been cited.

codeforcescompetitive-programming
CF 105381L - The Bag of Forgotten Coins

We are given a sequence of coins laid out in a line, where coin k has a fixed value v[k]. We are allowed to pick a subset of these coins, but there is a strict restriction: we cannot pick two coins whose indices differ by exactly one.

codeforcescompetitive-programming
CF 105381J - Randomized String Matching Algorithm

We are given two strings, a long text s and a pattern t. We scan every starting position in s where t could fit. For each such position, Tony’s algorithm tries to decide whether the substring is equal to t, but instead of checking all characters, it performs k random probes.

codeforcescompetitive-programming
CF 105381I - LIS Decrement

We are given a sequence of integers where each element carries a weight. From this sequence we are allowed to choose any subsequence, meaning we can delete elements while preserving order, and we care about two different quantities computed on that subsequence.

codeforcescompetitive-programming
CF 105381G - Graph Coloring Problem

We are given a connected undirected graph where each edge has a weight. For a fixed threshold value $x$, we conceptually “ignore” all edges whose weight is greater than $x$, and only keep edges with weight at most $x$.

codeforcescompetitive-programming
CF 105381H - Points Separation

We are given a fixed set of points in the plane, and then multiple query points. For each query point, we must choose a line such that the query point lies strictly on one side of the line and every given point lies strictly on the other side.

codeforcescompetitive-programming
CF 105381E - Elimination Game

We start with pebbles labeled from 1 to n, where pebble i has weight i. In each move, two currently available pebbles are selected and passed through one of two devices. One device always returns the lighter of the two inputs, the other always returns the heavier one.

codeforcescompetitive-programming
IMO 1968 Problem 2

The expression on the right side is quadratic in $x$, while the left side is a product of decimal digits, hence grows at most exponentially in the number of digits but remains extremely constrained di…

imomathematicsolympiad
CF 105381B - Trip Counting II

We are given a graph with $n$ nodes where every pair of nodes is potentially connected, but only $m$ of those edges are actually usable. Think of this as a simple undirected graph: each of the $m$ input pairs describes a working two-way road between two countries.

codeforcescompetitive-programming