brain

tamnd's digital brain — notes, problems, research

43815 notes

CF 105505J - Jigsaw of Shadows

We are given a line, which we can think of as the x-axis. On this line there are several vertical people standing at distinct x-coordinates. Each person has a height, so you can think of each one as a vertical segment anchored on the line.

codeforcescompetitive-programming
CF 105505D - Diverse T-Shirts

We are given a set of N items, where each item represents a T-shirt model. Two models are considered incompatible if they share either the same text color or the same background color.

codeforcescompetitive-programming
CF 105505G - Grand Glory Race

We are given a weighted tree representing villages connected by roads. Every leaf village contains exactly one runner.

codeforcescompetitive-programming
IMO 1978 Problem 4

The configuration involves a triangle with $AB = AC$, a circle tangent to both equal sides at $P$ and $Q$, and also tangent internally to the circumcircle.

imomathematicsolympiad
IMO 1978 Problem 3

The sequence $f(1)<f(2)<f(3)<\cdots$ is strictly increasing and consists of positive integers, hence it defines an increasing subset $S\subset \mathbb{N}$.

imomathematicsolympiad
IMO 1978 Problem 2

The configuration consists of three mutually perpendicular segments $PA$, $PB$, $PC$ with common endpoint $P$, where $A,B,C$ lie on a fixed sphere centered at some point $O$.

imomathematicsolympiad
IMO 1978 Problem 1

The original failure comes entirely from an unverified claim about the multiplicative order of $978 \bmod 125$.

imomathematicsolympiad
IMO 1977 Problem 6

Testing small indices does not reveal any oscillatory behavior compatible with the condition $f(n+1) > f(f(n))$.

imomathematicsolympiad
CF 105507K - Раскраска матрицы

We are working with an $n times m$ grid that starts completely white. One operation chooses a single cell $(x,y)$ and a color among white, red, or blue, but the effect is not local: the whole row $x$ and the whole column $y$ are repainted in that color, overwriting anything…

codeforcescompetitive-programming
CF 105507L - Идеальная фотография

We are given a set of players, each with a distinct height. We want to place all existing players in a single line and possibly add new players so that the final lineup forms a perfectly consecutive sequence of heights.

codeforcescompetitive-programming
CF 105507J - Поиск и замена

We are given an array of integers. Each operation modifies this array in a very specific way: we locate two special positions, one containing a maximum value and one containing a minimum value.

codeforcescompetitive-programming
CF 105507I - Этажи, этажи...

A high-rise building is described where apartments are numbered continuously starting from 1, beginning on the first floor, and every floor contains the same number of apartments.

codeforcescompetitive-programming
CF 105507H - Вычитание

We are given a very large positive integer written in decimal form. From this number we want to subtract another positive integer $b$, chosen by us, under two constraints. First, $b$ must be strictly smaller than the given number.

codeforcescompetitive-programming
CF 105507G - Задача про сортировку

We are given a permutation of length $n$, and the task is to transform it into the identity permutation $[1,2,dots,n]$. The only allowed operation is reversing any subarray of length at least two. However, the transformation is constrained in two additional ways.

codeforcescompetitive-programming
CF 105507F - Бильярд

We are given a triangular arrangement of balls, where row 1 has 1 ball, row 2 has 2 balls, and so on up to row n. The balls are numbered consecutively row by row from top to bottom, and within each row from left to right.

codeforcescompetitive-programming
CF 105507E - Рассадка на экзамене

We are given a single row of seats in an exam hall, represented as a string of length $n$. Each position is either occupied by a student or empty. Our task is to reorganize students by moving some of them from their current seats into empty ones.

codeforcescompetitive-programming
CF 105507C - Дерево обхода в глубину

We are given a connected undirected graph $G$ with up to $n$ vertices and $m$ edges, and inside this graph we are also given a spanning tree $T$ on the same set of vertices. Every edge of $T$ is guaranteed to exist in $G$, but $G$ may contain additional edges.

codeforcescompetitive-programming
CF 105507B - Голы

We are given several independent seasons of a football team. For each season, we know how many matches were won and lost, and we also know the total number of goals scored and conceded across all matches. No draws exist, so every match is strictly either a win or a loss.

codeforcescompetitive-programming
IMO 1977 Problem 5

The division condition is written as $a^2+b^2 = q(a+b) + r$ with $0 \le r < a+b$, and the constraint $q^2 + r = 1977$ forces $r = 1977 - q^2$.

imomathematicsolympiad
CF 105505L - Latin Squares

We are given a sequence of operations applied to an unknown Latin square. A Latin square is an $N times N$ grid filled with numbers from $1$ to $N$, where each number appears exactly once in every row and in every column.

codeforcescompetitive-programming
IMO 1977 Problem 4

The expression is a trigonometric polynomial containing first and second harmonics.

imomathematicsolympiad
CF 105505H - Heraclosures

The program is a directed acyclic graph of function calls. Each function has a base cost, and whenever it calls another function, that callee’s full execution cost is added immediately, and this effect propagates recursively through all further calls.

codeforcescompetitive-programming
CF 105505I - Inversion Insight

We are asked to reconstruct a permutation of the numbers from 1 to N given its position in a very specific ordering of all permutations. The ordering is not the usual lexicographic order.

codeforcescompetitive-programming
CF 105505B - Biketopia's Cyclic Track

We are given an undirected connected graph where every city has degree at least three and there is at most one road between any pair of cities.

codeforcescompetitive-programming
IMO 1977 Problem 3

The set $V_n$ consists of integers congruent to $1 \pmod n$, namely numbers of the form $1+kn$ with $k \ge 1$.

imomathematicsolympiad
CF 105498H - Optimizing Weekend Days

We are given a long continuous period defined by a start date and an end date, and inside this period we also receive a list of public holidays. Each holiday either repeats every year on a fixed month and day, or occurs only once in a specific year.

codeforcescompetitive-programming
CF 105498G - User Registration System

We are maintaining a live database of usernames under two operations: insertion and deletion. Each username is a short string, and every operation either tries to add it or remove it. When inserting a username, the system behaves like a reservation mechanism.

codeforcescompetitive-programming
CF 105498E - Cyclic Inversion

We are given an array and asked to reason about its inversion count under a restricted but flexible operation. The operation is a cyclic shift applied to the prefix of length k: we can take the first k elements, rotate them left any number of times, and append them back to the…

codeforcescompetitive-programming
CF 105498D - Maximum AND

We are given an array of integers. For each value of a parameter $k$, we are allowed to repeatedly perform an operation that takes two positions $i$ and $j$ that are at least $k$ apart and copies the bitwise OR of $aj$ into $ai$.

codeforcescompetitive-programming
CF 105498A - Optimal Point

We are given a set of points in four-dimensional Euclidean space. Each point has coordinates $(xi, yi, zi, wi)$. We are allowed to choose a single point $o = (ox, oy, oz, ow)$, and we measure its distance to every input point using standard Euclidean distance in 4D.

codeforcescompetitive-programming
CF 105494B - Ant Hill

We are given a sequence of changes applied over time, where each element describes how the number of ants in an anthill changes after an observation. Positive values mean ants are added, negative values mean ants leave. We do not know the initial number of ants in the anthill.

codeforcescompetitive-programming
IMO 1977 Problem 2

The inequality system is local with two window lengths, $7$ and $11$, so every term participates in multiple overlapping constraints.

imomathematicsolympiad
IMO 1977 Problem 1

A square suggests a $90^\circ$ rotational symmetry about its center, and the repeated construction of equilateral triangles on each side introduces a $60^\circ$ rotational component locally.

imomathematicsolympiad
IMO 1976 Problem 6

The recurrence couples each term with the previous two terms in a nonlinear way, and the conclusion concerns the integer part of a logarithm, suggesting that the central structure is a hidden power of…

imomathematicsolympiad
CF 105494I - Study Day

We are given a sequence of lectures, each lecture providing some amount of knowledge represented by an integer value. For every lecture, you make a decision in two layers: whether you attend it, and whether you apply a special “meditation” effect right before attending it.

codeforcescompetitive-programming
CF 105494H - Hierarchy

We are given a collection of employees where each employee belongs to exactly one company, and each company is structured as a hierarchy rooted at a CEO.

codeforcescompetitive-programming
CF 105494G - Need More Gold

We are given a collection of monsters, each described by two numbers. One value represents how much gold you need to have before you can defeat that monster, and the other represents how much gold you gain after defeating it.

codeforcescompetitive-programming
CF 105494E - Mountain Ranges

We are given a sequence of mountain heights arranged in a line. A parameter $k$ defines when two neighboring mountains are considered “compatible”: if the height difference between adjacent positions exceeds $k$, then that adjacency is broken.

codeforcescompetitive-programming
CF 105494D - Grouping

We are given an array of integers and we are asked to split it into several groups. The cost of a solution is the number of groups, and every element must belong to exactly one group.

codeforcescompetitive-programming
CF 105494A - Problem Statement

We are given a very simple process that starts from a single object, called a part. Every time we press Enter, the number of parts increases by exactly one. After performing some number of presses, the system ends with exactly $n$ parts.

codeforcescompetitive-programming
IMO 1976 Problem 5

Each equation is a homogeneous linear relation in $q=2p$ integer variables with coefficients in ${-1,0,1}$.

imomathematicsolympiad
CF 105493C - Tomorrow Will Be Better Than Yesterday

We are given a sequence of points in the plane, and we look at the displacement vectors between consecutive points. Each such vector captures how we move from one point to the next.

codeforcescompetitive-programming
IMO 1976 Problem 4

A product of positive integers with fixed sum increases when the summands are replaced by a partition that favors factors close to the maximizer of the function $x \mapsto x^{1/x}$.

imomathematicsolympiad
IMO 1976 Problem 3

Let the box be a parallelepiped with side lengths $a,b,c>0$.

imomathematicsolympiad
IMO 1976 Problem 2

The polynomials are defined by iteration of $P_1(x)=x^2-2$, so that $P_n$ is the $n$-fold composition of $x^2-2$ with itself.

imomathematicsolympiad
IMO 1976 Problem 1

Let a convex quadrilateral $ABCD$ be given.

imomathematicsolympiad
IMO 1975 Problem 6

Condition (i) says that $P$ is a homogeneous polynomial of degree $n$.

imomathematicsolympiad
IMO 1975 Problem 5

The flawed argument tried to force a cyclotomic structure via Mann’s theorem.

imomathematicsolympiad
CF 105493H - Tiring Wait

We are simulating a traveler who moves back and forth between two stops, A and B, using two fixed timetables. One timetable lists departure times from A to B, and the other lists departure times from B to A.

codeforcescompetitive-programming
CF 105493I - Fair Diversity

Each establishment receives some number of visits over a fixed number of days. From this history we compute a frequency array $ci$, where each value represents how many times establishment $i$ was visited.

codeforcescompetitive-programming
CF 105493E - Training Camps

We are given a directed acyclic graph where two special vertices act as starting points. From each of these starting vertices, we must construct a path that follows directed edges forward.

codeforcescompetitive-programming
CF 105493G - Exhausting Training

We are modeling a training schedule that improves two independent skills over a number of days. Each skill has an initial level, a target level, and two ways to train it: a normal training mode that increases the skill slowly, and an intensive mode that boosts progress more…

codeforcescompetitive-programming
IMO 1975 Problem 4

We are given the number

imomathematicsolympiad
CF 105493D - Conspiracy Theory

We are given a sequence of positive integers. After removing duplicates, we are interested in building a directed structure over their positions in increasing index order.

codeforcescompetitive-programming
CF 105493A - New Functionality

The process described in the problem behaves like a two-dimensional counter that advances in a very regular pattern. We start from a current position identified by a pair of values, and each “press” moves this position forward.

codeforcescompetitive-programming
CF 105492C - Concurrent Contests

There are several programming contests happening at the same time, and a set of participants must be distributed among them. Each contest has a single prize that only its winner receives.

codeforcescompetitive-programming
IMO 1975 Problem 3

Directed-angle accumulation across a multi-centered chain fails unless every angle is expressed as a single consistent invariant, because each construction triangle induces relations at two vertices r…

imomathematicsolympiad
IMO 1975 Problem 2

The statement concerns an arbitrary strictly increasing sequence of positive integers.

imomathematicsolympiad
IMO 1975 Problem 1

The expression to be minimized is

imomathematicsolympiad
CF 105492M - Museum Visit

We are given a timeline of days, each day having a known “discomfort cost” if we choose to visit the museum on that day. Alongside this, there are multiple exhibitions, and each exhibition is active over a contiguous range of days.

codeforcescompetitive-programming
IMO 1974 Problem 6

The earlier approach fails because it invents a hierarchy of sets based on “sign changes” without defining a meaningful invariant that survives passage to finite differences.

imomathematicsolympiad
CF 105492K - Karaoke Compression

We are given a single string representing a sequence of lyrics. We are allowed to perform exactly one compression operation.

codeforcescompetitive-programming
CF 105492J - Jumbled Scoreboards

We receive a sequence of snapshots from a game scoreboard, where each snapshot contains two integers representing the scores of two competing teams at that moment.

codeforcescompetitive-programming
CF 105492I - Interrail Pass

We are given a fixed itinerary consisting of n travel days, each occurring on a specific calendar day. For each of these days, there is a cost if we decide to buy a single ticket independently. These days are already sorted by time, and no two days share the same timestamp.

codeforcescompetitive-programming
CF 105492G - Grocery Greed

Each item has a price given with exactly two decimal places. You are allowed to split the set of items into groups, and each group can be paid for either in cash or by card. Card payment charges the exact sum of the items in the group.

codeforcescompetitive-programming
CF 105492F - Failing Factory

We are given a factory modeled as a directed graph where each node represents a processing step. Every step independently fails with a given probability.

codeforcescompetitive-programming
CF 105492E - Extraterrestrial Exploration

We are given an array of $n$ hidden integers, revealed only through queries. Each position corresponds to a canister of fuel, and querying index $i$ returns its value $ai$. The array is sorted in non-decreasing order.

codeforcescompetitive-programming
CF 105492D - Disgruntled Diner

We are given a log of orders where each order is a pair consisting of a menu item and a table number. Think of each order as an edge connecting a letter node (the dish) to a digit node (the table). The central computer knows all such edges.

codeforcescompetitive-programming
CF 105492A - ``Aaawww...'' or ``Aaayyy!!!''

We are given a frozen contest scoreboard with several teams already ordered from best to worst. Each team has a row describing its submission status per problem: accepted, rejected, pending, or no submission at all.

codeforcescompetitive-programming
CF 105487A - Box

A rectangular box is placed in 3D space with its bottom face lying flat on a known horizontal plane. The height of the box is given, so the top face is just a vertical translation of the bottom face.

codeforcescompetitive-programming
IMO 1974 Problem 5

Direct computation of extremal configurations shows that the expression approaches $2$ when two opposite variables are small and the other two are large, and approaches $1$ when two adjacent variables…

imomathematicsolympiad
IMO 1974 Problem 4

Small cases were checked to understand what truly restricts the number of rectangles.

imomathematicsolympiad
IMO 1974 Problem 3

Let

imomathematicsolympiad
CF 105487M - Covering a Tree

A tree is given in parent representation, so every node except the root has a single parent and the edges are implicitly directed upward toward that root. We are asked to cover every tree edge exactly once using several directed segments.

codeforcescompetitive-programming
CF 105487K - Xiao Kai's Dream of Provincial Scholarship

Each student in the class has two separate sets of attributes: one for each semester. For each semester, we care about three scores: intelligence, morality, and sports. The sum of these three defines that semester’s “comprehensive score”.

codeforcescompetitive-programming
CF 105487J - Sum of Squares of GCDs

We are given two permutations of the integers from 1 to n, but they are stored as arrays indexed by positions. Each query selects a contiguous segment of indices in the first permutation and another contiguous segment in the second permutation.

codeforcescompetitive-programming
CF 105487I - String Duplication

We are given a base string s and we construct a much longer string T by concatenating m copies of s back to back. So T = s + s + ... + s. The task is to compute how many distinct substrings appear anywhere inside T.

codeforcescompetitive-programming
CF 105487H - Square Root

We are given a binary string, and we interpret it as a sequence where only the 1 characters matter. Every maximal contiguous block of 1s forms a segment, while 0s act as separators that break the string into independent segments.

codeforcescompetitive-programming
CF 105487G - Increasing Sequence

We are given an array of non-negative integers. We are allowed to choose a single integer x in the range from 0 to k, and we apply XOR with x to every element of the array. After this transformation, we require the resulting array to be non-decreasing.

codeforcescompetitive-programming
CF 105487E - Centroid Tree

We are given a rooted tree on $n$ labeled nodes where every node except the root has exactly one parent, and parents always have smaller indices than children.

codeforcescompetitive-programming
CF 105487B - Aho-Corasick Automaton

We are asked to count how many different Aho-Corasick automata could have produced a certain final shape, under very limited structural information. An Aho-Corasick automaton in this setting is built from two intertwined objects.

codeforcescompetitive-programming
CF 105487D - Excellent Splitting

We are given a permutation, and we are allowed to split its elements into two subsequences while preserving original order inside each subsequence. One subsequence is called A, the other is B.

codeforcescompetitive-programming
CF 105486G - Expanding Array

We start with a list of integers, and we are allowed to repeatedly expand it by taking any neighboring pair and inserting a value derived from them using bitwise operations: AND, OR, or XOR.

codeforcescompetitive-programming
CF 105477D - Girona Flower Time

The city can be modeled as a directed complete graph where every location is a node and every ordered pair of nodes has a travel time. Each node also has a non-negative value representing how many tourists stand there.

codeforcescompetitive-programming
IMO 1974 Problem 2

In triangle $ABC$, we seek a point $D$ on the side $AB$ such that

imomathematicsolympiad
IMO 1974 Problem 1

The corrected argument begins by rechecking the structure of the process itself rather than inheriting any assumption from the flawed solution.

imomathematicsolympiad
IMO 1970 Problem 6

A direct “vertex–angle ≥ 60°” charging argument cannot be repaired by any local bound of the form “at most a fixed fraction of pairs at a point subtend angle ≥ 60°”, since configurations can be made e…

imomathematicsolympiad
CF 105486L - Recover Statistics

We are given three target order statistics extracted from an unknown multiset of integers: a value that is supposed to act as the median position at 50 percent, another that corresponds to the 95 percent cutoff, and a final one for the 99 percent cutoff.

codeforcescompetitive-programming
CF 105486K - Magical Set

We are given a collection of distinct integers. You can repeatedly perform an operation where you pick a number larger than 1 from the current collection, remove it, and replace it with one of its proper divisors.

codeforcescompetitive-programming
CF 105486J - Grand Prix of Ballance

The system is simulating a live competition that produces a stream of server logs while a contest is running. There are several levels, and at any moment only one level is “active”, determined by the most recent log of type 1.

codeforcescompetitive-programming
CF 105486I - Good Partitions

We are given a sequence and we want to understand, for each possible block size $k$, whether a very specific partitioning of the array behaves nicely. The array is cut into consecutive segments of length $k$, except possibly the last segment which may be shorter.

codeforcescompetitive-programming
CF 105486H - Friendship is Magic

We are given a large integer written in decimal form. For each such number, we consider all ways to cut its decimal representation into two non-empty parts. Each cut produces two strings, which we interpret again as integers by reading them in base 10.

codeforcescompetitive-programming
CF 105486E - Disrupting Communications

We are given a tree, so every pair of nodes is connected by exactly one simple path. Alongside this structure, we consider many possible connected subgraphs, meaning we choose some set of nodes and edges from the tree such that everything stays connected.

codeforcescompetitive-programming
CF 105486A - Arrow a Row

We are given a binary string consisting of two symbols, and -. We start from a blank canvas of the same length filled with , and we are allowed to perform painting operations.

codeforcescompetitive-programming
CF 105486C - Chinese Chess

We are given a 10×9 chessboard and a hidden piece that belongs to one of six movement types inspired by Chinese chess. We do not know its type or its position.

codeforcescompetitive-programming
CF 105486D - Closest Derangement

We are given a permutation p of size n. The task is to construct another permutation q of the same numbers such that no position keeps its original value, meaning for every index i, the value q[i] must differ from p[i].

codeforcescompetitive-programming
CF 105485M - 猜猜看

We are interacting with a hidden number $x0$, but we never see it directly. Instead, there is a second evolving value $x$ that starts equal to $x0$. We can issue three kinds of interactive commands. One asks whether the current $x$ is divisible by a chosen number $a$.

codeforcescompetitive-programming
CF 105485K - 冰红茶

We are given a rectangular grid with n rows and m columns, and a collection of k bottles of iced tea, each with a fixed price. The task is to place some or all of these bottles into distinct grid cells, with at most one bottle per cell.

codeforcescompetitive-programming
CF 105485J - 星穹列车

The train moves along a fixed horizontal ray that starts at a given point and continues infinitely to the right. Every danger zone is a circle on the plane, and whenever the train’s path passes through a circle, we count only the portion of the train’s path that lies inside…

codeforcescompetitive-programming
CF 105485G - 奥运会

We are asked to count how many Olympic events happen inside a year interval. The key detail is that there are two independent sequences of events: Summer Olympics and Winter Olympics. Each follows a strict periodic pattern.

codeforcescompetitive-programming