brain

tamnd's digital brain — notes, problems, research

41641 notes

IMO 1996 Problem 3

The functional equation is

imomathematicsolympiad
IMO 1996 Problem 2

A direct continuation of the previous angle-sum manipulation is unsafe because relations involving three rays at a point were previously used without controlling whether the point lies inside the rele…

imomathematicsolympiad
CF 105236B - Найди отрицательное

We are given two points on the integer grid, each acting as the center of a circular influence. Around each center, every lattice point within a given Euclidean radius has its value flipped by multiplying it by −1.

codeforcescompetitive-programming
IMO 1996 Problem 1

The correction must repair three independent failures: a missing invariant for even $r$, a non-existent construction for $r=73$, and a spurious modular obstruction for $r=97$.

imomathematicsolympiad
IMO 1995 Problem 6

For small primes the structure can be tested directly.

imomathematicsolympiad
IMO 1995 Problem 5

The failure in the previous argument comes from a structural mismatch: the target inequality cannot be reached by first producing an expression for $CF$ and then attempting to “discard” remaining boun…

imomathematicsolympiad
CF 105236E - Гробовая геометрия

We are given a set of points on a 2D integer grid. Among them, there exists a hidden point $(a, b)$. For every given point $(xi, yi)$, we are also given the squared Euclidean distance from that point to $(a, b)$, but the list of these distances is shuffled, so we do not know…

codeforcescompetitive-programming
CF 105236D - Посчитай-ка пути

We are given a weighted tree with up to one hundred thousand vertices. Each edge has an integer weight. For every query, we pick two vertices and look at the unique simple path between them. This path gives us a sequence of edge weights in order.

codeforcescompetitive-programming
CF 105236C - Футбол в Берляндии

We have $n$ football players. Initially, each player $i$ has a shirt numbered $i$, so the labels form the sequence $1,2,dots,n$. After a change, shirt number $1$ is replaced by $n+1$, so the available set of shirt numbers becomes $2,3,dots,n+1$.

codeforcescompetitive-programming
CF 105239D - Da Hong Pao

We are given a sequence of cups arranged in a line. Each cup has a value that represents how relaxing it is to drink. Evgeny repeatedly removes cups until none remain, but each time he is only allowed to take either the leftmost or the rightmost remaining cup.

codeforcescompetitive-programming
IMO 1995 Problem 4

The recurrence is first rewritten correctly by clearing denominators:

imomathematicsolympiad
CF 105239I - Path And k Vertices

We are given a rooted tree where every edge is directed from a child up to its parent, so from any node you can follow a unique chain of parents until you reach the root. Each vertex has a distinct integer value attached to it.

codeforcescompetitive-programming
CF 105239H - These Piles of Stones Again!

We are given a small combinatorial game played on three independent piles of stones. Each move consists of selecting exactly one pile and removing a number of stones from it. The number of stones removed must belong to a fixed allowed set given in the input.

codeforcescompetitive-programming
CF 105239G - Butterball on a Diet

Each store trip gives Butterball two independent supplies: some rice and some chicken breast. Across all trips, he wants to assemble meals of fixed size $k$ grams, but the rules restrict how ingredients can be combined.

codeforcescompetitive-programming
CF 105239F - Large Tiling With Dominoes

We are asked to count how many ways we can completely cover a rectangular grid of height m and extremely large width n using 1×2 dominoes. Each domino covers exactly two adjacent cells either horizontally or vertically, and every cell of the grid must be covered exactly once.

codeforcescompetitive-programming
CF 105239E - Rain

We are given a rectangular grid representing flooded terrain, where each cell has a water depth value. A traveler starts in the top-left cell and wants to reach the bottom-right cell.

codeforcescompetitive-programming
CF 105239B - Let Us Assemble a Portfolio Together

We are given a collection of projects, and for each project there are several mutually exclusive ways to execute it. Each way has a cost and a revenue. For every project we must either pick exactly one of its available ways or skip the project entirely.

codeforcescompetitive-programming
CF 105242C - Powerful String

We are given several independent test cases. Each test case describes a tree, meaning a connected acyclic graph. The task is to decide whether there exists a walk on this tree that visits every node at least once and never more than twice.

codeforcescompetitive-programming
IMO 1995 Problem 3

Testing the condition for small values of $n$ starts with rewriting the requirement as a linear system in the unknowns $r_i$.

imomathematicsolympiad
IMO 1994 Problem 6

For any infinite set $S$ of primes, the objects under consideration are integers of the form $p_1p_2\cdots p_k$, where $p_i\in S$ are distinct primes and $k\ge 2$.

imomathematicsolympiad
CF 105242L - Median of the Array

We are given several test cases, and in each one we start with a list of integers. The task is to split this list into two non-empty groups so that every element belongs to exactly one of the groups.

codeforcescompetitive-programming
CF 105242K - 2.. 3.. 4.. Colorful! Colorful! Colorful!

We are given multiple test cases. Each test case consists of a set of points on a 2D plane. Every point has integer coordinates and also a color label.

codeforcescompetitive-programming
CF 105242J - The Square Game

We are given a single odd integer n that represents the number of chess games played between two players, both named Ahmad. Every game produces a decisive result, so there are no draws, and each game contributes exactly one win to one of the two players.

codeforcescompetitive-programming
IMO 1994 Problem 5

Testing small structures suggests that the expression $x+f(y)+xf(y)$ behaves like a deformed product since it equals $(1+x)(1+f(y))-1$.

imomathematicsolympiad
CF 105242I - Minimum XOR

We are given an array of integers and then asked many independent queries. Each query provides a value x, and we must consider all pairs of distinct indices (i, j) such that the bitwise OR of the two array values is “compatible” with x, in the sense that every bit that…

codeforcescompetitive-programming
CF 105242H - Banis Hotel

We are given a hotel with floors numbered from bottom to top. Each floor has a structural limit that restricts how many guests can be on that floor or any floors above it.

codeforcescompetitive-programming
CF 105242G - Lexicographically Maximum

We are given a string of lowercase English letters. We are allowed to perform an operation any number of times, where each operation picks a contiguous substring and compresses it into a single repeated letter determined by how many distinct characters were inside that substring.

codeforcescompetitive-programming
CF 105242F - Queries on Distincts

We are given a string of lowercase English letters and many queries, each query focusing on a substring defined by indices $l$ and $r$. For each such range, we first look at which distinct characters appear inside it. Suppose the substring $s[l..

codeforcescompetitive-programming
CF 105242B - Tree Tour

We are given a string made of lowercase English letters and a large number of queries, each query specifying a segment of this string. For each segment, we are allowed to choose two positions inside it and swap their characters exactly once.

codeforcescompetitive-programming
IMO 1995 Problem 2

The corrected target inequality is equivalent to proving a lower bound for a cyclic sum of fractions with denominators $a^3(b+c)$.

imomathematicsolympiad
IMO 1994 Problem 4

The condition is

imomathematicsolympiad
IMO 1995 Problem 1

Let $A,B,C,D$ be distinct collinear points in this order.

imomathematicsolympiad
IMO 1994 Problem 3

The previous argument fails because it treats binary “blocks” inside $k$ as if they evolve independently under both the inequality $k<n\le 2k$ and the structure of numbers with three ones.

imomathematicsolympiad
IMO 1994 Problem 2

Place the isosceles triangle $ABC$ with $AB=AC$ so that $A$ is symmetric above the midpoint of $BC$, and interpret $M$ as the midpoint of $BC$.

imomathematicsolympiad
IMO 1994 Problem 1

Small cases suggest that whenever two selected elements are both “far from the top”, their sum, if it stays within ${1,\dots,n}$, must also be selected, which tends to force new larger elements into t…

imomathematicsolympiad
IMO 1993 Problem 6

A configuration of lamps can be encoded as a vector $x(t) = (x_0(t), \ldots, x_{n-1}(t)) \in \mathbb{F}_2^n$, where $x_i(t)=1$ means $L_i$ is on at time $t$ and $0$ means off.

imomathematicsolympiad
IMO 1993 Problem 5

The functional equation $f(f(n)) = f(n) + n$ forces a strong coupling between values at $n$ and at $f(n)$.

imomathematicsolympiad
IMO 1993 Problem 4

The expression $m(PQR)$ is a geometric quantity defined as the minimum of the three altitudes of triangle $PQR$.

imomathematicsolympiad
IMO 1993 Problem 3

A move replaces two adjacent orthogonally neighboring pieces and one piece two steps away in the same row or column by removing the middle piece and relocating the jumping piece.

imomathematicsolympiad
IMO 1993 Problem 2

The two conditions suggest a strong metric and angle rigidity.

imomathematicsolympiad
IMO 1993 Problem 1

The polynomial $f(x)=x^n+5x^{n-1}+3$ has integer coefficients and leading coefficient $1$.

imomathematicsolympiad
IMO 1992 Problem 6

The quantity $S(n)$ measures how far one can guarantee representations of $n^2$ as sums of positive squares once representations exist up to some length.

imomathematicsolympiad
IMO 1992 Problem 5

Let $S \subset \mathbb{R}^3$ be finite, and write each point as $(x,y,z)$.

imomathematicsolympiad
IMO 1992 Problem 4

The circle $C$ is tangent to a fixed line $l$ at $M$, so the radius $OM$ is perpendicular to $l$, where $O$ denotes the center of $C$.

imomathematicsolympiad
IMO 1992 Problem 3

A direct search for the maximum number of colored edges reduces the problem to maximizing $e(R)+e(B)$ over two edge-disjoint triangle-free graphs $R$ and $B$ on $K_9$.

imomathematicsolympiad
IMO 1992 Problem 2

Substituting $y=0$ transforms the equation into $f(x^2+f(0)) = (f(x))^2$.

imomathematicsolympiad
IMO 1992 Problem 1

The original reduction to

imomathematicsolympiad
IMO 1991 Problem 6

The condition requires a uniform lower bound on pairwise differences after rescaling by a polynomial factor in the index gap.

imomathematicsolympiad
IMO 1991 Problem 5

Let $ABC$ be a triangle with an interior point $P$.

imomathematicsolympiad
IMO 1991 Problem 4

The earlier attempt failed because it tried to control gcd conditions via prime avoidance without a stable invariant.

imomathematicsolympiad
IMO 1991 Problem 3

The problem asks for the smallest integer $n$ such that every $n$-element subset of $S={1,2,\dots,280}$ contains five integers that are pairwise coprime.

imomathematicsolympiad
IMO 1991 Problem 2

Let $a_1<a_2<\cdots<a_k$ be all positive integers less than $n$ that are coprime to $n$.

imomathematicsolympiad
IMO 1991 Problem 1

The earlier failure comes from an incorrect algebraic detour: introducing a complicated symmetric rational function that is not actually the natural simplification of the geometric ratio.

imomathematicsolympiad
IMO 1990 Problem 6

The earlier approach fails because cyclicity was incorrectly used as a substitute for equal angles.

imomathematicsolympiad
IMO 1990 Problem 5

The game is defined on positive integers with two alternating moves.

imomathematicsolympiad
IMO 1990 Problem 4

The functional equation is

imomathematicsolympiad
IMO 1990 Problem 3

Checking small values gives $n=2,3,4,5$ producing $\frac{5}{4},1,\frac{17}{16},\frac{33}{25}$, so only $n=3$ works in this range.

imomathematicsolympiad
IMO 1990 Problem 2

The structure is circular and symmetric, so the key parameter is the number of points on each arc between chosen black points.

imomathematicsolympiad
CF 105244C - Space Expedition

A space explorer visits a fixed sequence of celestial objects. Each object offers some scientific value if studied, but also consumes two limited resources: energy and time.

codeforcescompetitive-programming
IMO 1990 Problem 1

The configuration contains two independent cyclic structures sharing the point $E$.

imomathematicsolympiad
IMO 1989 Problem 6

Write $A_i={i,i+n}$ for $1\le i\le n$.

imomathematicsolympiad
IMO 1989 Problem 4

Direct substitutions collapse the problem to a single relation:

imomathematicsolympiad
CF 105244I - Sum of Path Lengths

The input describes a tree with vertices numbered from 1 to n. Every vertex except the first has exactly one parent given, which implicitly defines an undirected edge between each node i and its parent pi.

codeforcescompetitive-programming
IMO 1989 Problem 3

The condition imposes a strong local symmetry constraint: every point $P$ in a finite planar set $S$ has at least $k$ other points at the same distance from it.

imomathematicsolympiad
CF 105244H - Subsequence With Specified Differences

We are given a sequence of distinct integers, and we want to extract a subsequence that is strictly increasing. On top of the usual increasing constraint, there is an additional rule that restricts how consecutive elements in the subsequence can differ: if two consecutive…

codeforcescompetitive-programming
CF 105244G - Evolutionary Tree Weights

We are given several small evolutionary scenarios, each describing a rooted tree of species and a partial mapping between some leaves and known genome strings. Every genome string has the same length and consists of four possible nucleotides.

codeforcescompetitive-programming
CF 105244F - Lottery

We are given a starting lottery ticket of length $n$. Every position initially contains the number 1. For each position $i$, there is a required target value $bi$. If we manage to make the $i$-th position equal to $bi$, we earn $ci$ coins.

codeforcescompetitive-programming
CF 105244E - Petya and Dice

We start with a row of n dice, each die showing a single lowercase letter. So at any moment the whole configuration is just a string of length n. The goal is to transform an initial string into a fixed target string using exactly m moves.

codeforcescompetitive-programming
CF 105244D - A Giraffe Travels and Munches

We are given an $m times n$ grid, where each cell contains a non-negative number representing how many trees grow there. A giraffe starts at the top-left cell $(1,1)$ and wants to reach the bottom-right cell $(m,n)$. The movement rules are constrained and unusual.

codeforcescompetitive-programming
CF 105244B - Choosing a Vertex To Remove

We are given a tree with n vertices, and every vertex carries a numeric value. If we take any connected component of this tree, its cost is defined in a slightly unusual way: we multiply the number of vertices in that component by the sum of values stored on those vertices.

codeforcescompetitive-programming
CF 105244A - New Adventures of the Wolf of Wall Street

We are asked to fill an $N times m$ grid with two types of pieces. One is a $1 times 1$ coin tile, and the other is a $1 times 2$ dollar bill that can be placed either horizontally or vertically.

codeforcescompetitive-programming
IMO 1989 Problem 2

The configuration is governed by three recurring geometric objects: the points $A_1,B_1,C_1$ on the circumcircle determined by internal angle bisectors, the external angle bisectors meeting at the thr…

imomathematicsolympiad
IMO 1989 Problem 1

The previous construction failed because it broke the fixed requirement that exactly 17 column permutations must be defined on the same index set ${0,\dots,16}$.

imomathematicsolympiad
CF 105245C - Super Pair

We are given a tree with $n$ nodes. The task is to consider every unordered pair of distinct nodes $(u, v)$ that is not already connected by an edge in the input tree, and decide whether adding a direct edge between them preserves a very strong structural property: after…

codeforcescompetitive-programming
IMO 1988 Problem 6

Testing small cases gives $k=1$ for $(a,b)=(1,1)$.

imomathematicsolympiad
IMO 1988 Problem 5

Coordinates are placed with the right angle at $A$, taking $A=(0,0)$, $B=(b,0)$, $C=(0,c)$ with $b,c>0$.

imomathematicsolympiad
CF 105245G - Multiple Game

Two players play on a pair of positive integers, and each move consists of choosing one number and reducing the other by any positive multiple of it, as long as the result stays non-negative.

codeforcescompetitive-programming
CF 105245F - Count via Construct

We are asked to count how many binary matrices of size $n times n$ satisfy two global constraints that are imposed in a very asymmetric way across rows and columns. Each row has a condition on the AND of all its entries.

codeforcescompetitive-programming
CF 105245E - XOR Priority

We are given an array and every adjacent pair can be connected either by addition or XOR. Each choice produces one expression, so there are $2^{n-1}$ expressions. However, the value of an expression is not computed in the usual left-to-right manner.

codeforcescompetitive-programming
CF 105245D - Permutational Mex

We are given a desired value of a function computed from a permutation of numbers from 0 to n-1. For any permutation, we look at every prefix and compute the MEX of that prefix, then sum all those MEX values.

codeforcescompetitive-programming
IMO 1988 Problem 4

The expression

imomathematicsolympiad
CF 105245A - King Supremacy

We are given an $n times m$ grid where each cell behaves like a chessboard square colored by parity: a cell is white when the sum of its coordinates is even and black otherwise.

codeforcescompetitive-programming
CF 105245B - Circular Cone

We are given a circular arrangement of $n$ sectors, and initially each sector contains exactly one cone. The goal is to move all cones so that they end up stacked in a single chosen sector.

codeforcescompetitive-programming
IMO 1988 Problem 3

Testing the recursion directly shows that fixed points are sparse but structured.

imomathematicsolympiad
IMO 1988 Problem 2

The structure describes $n+1$ finite sets, each of size $n$, with the property that any two sets intersect in exactly one element, and every element lies in at least two sets.

imomathematicsolympiad
CF 105255B - Schedule

We are scheduling activities over a fixed number of weeks, and each team contributes exactly one representative per week. So every week is represented by a binary string of length n, where the i-th character tells whether member 1 or member 2 of team i is present.

codeforcescompetitive-programming
IMO 1988 Problem 1

Something went wrong.

imomathematicsolympiad
IMO 1987 Problem 6

Let $f(k)=k^2+k+n$ and assume there exists a smallest integer $k_0\in[0,n-2]$ such that $f(k_0)$ is composite.

imomathematicsolympiad
CF 105255K - Alea Iacta Est

We are given up to six dice, each die showing one symbol on its top face after a roll, but internally each die has six possible symbols it can show, all equally likely.

codeforcescompetitive-programming
CF 105255J - Bridging the Gap

A group of people needs to cross a bridge at night, but only a limited number of them can be on the bridge at once. Each person has a fixed crossing time, and when multiple people cross together, the group moves at the speed of the slowest member.

codeforcescompetitive-programming
CF 105255H - Jet Lag

We are given a timeline starting at minute zero and a set of disjoint activity intervals, sorted in increasing order and not overlapping. During each activity interval, we must remain fully awake. Outside these intervals, we are free to choose when to sleep.

codeforcescompetitive-programming
CF 105255I - Waterworld

The problem describes a planet whose surface is observed in a very structured way. Instead of looking at the whole sphere at once, the measurement process slices the planet in two directions. First, the planet is split vertically into n horizontal bands from pole to pole.

codeforcescompetitive-programming
CF 105255G - Turning Red

We are given a set of lights, each initially colored red, green, or blue, and a set of buttons. Each button is connected to a subset of lights.

codeforcescompetitive-programming
CF 105255F - Tilting Tiles

We are given two configurations of a rectangular board filled with obstacles and colored tiles. Empty cells exist, and tiles occupy some of them. Tiles are indistinguishable except for their color, and multiple tiles of the same color cannot be told apart individually.

codeforcescompetitive-programming
CF 105255D - Carl's Vacation

We are given two identical geometric objects: right square pyramids standing on the same horizontal ground plane. Each pyramid is described by one directed edge of its square base and a height.

codeforcescompetitive-programming
CF 105255E - A Recurring Problem

We are asked to enumerate a very large collection of integer sequences, where each sequence is generated by a positive linear recurrence.

codeforcescompetitive-programming
CF 105255C - Three Kinds of Dice

We are given two dice, each described by a multiset of face values. When two dice are rolled against each other, we pick one face uniformly from each die and compare the numbers. The higher number wins the round, and ties are split evenly.

codeforcescompetitive-programming
CF 105255A - Riddle of the Sphinx

We are trying to recover three hidden integers, each representing the number of legs of a mythical creature. We cannot observe them directly.

codeforcescompetitive-programming
IMO 1987 Problem 5

A configuration with rational areas for every triangle suggests that all coordinates should lie in a lattice with a controlled determinant structure, since triangle area is given by a determinant expr…

imomathematicsolympiad
IMO 1987 Problem 4

Assume there exists a function $f : \mathbb{Z}_{\ge 0} \to \mathbb{Z}_{\ge 0}$ satisfying

imomathematicsolympiad