brain

tamnd's digital brain — notes, problems, research

41641 notes

IMO 1987 Problem 3

Consider the family of all integer vectors $a=(a_1,\dots,a_n)$ with each $a_i$ in ${0,1,\dots,k-1}$.

imomathematicsolympiad
IMO 1987 Problem 2

A direct decomposition of the quadrilateral into triangles along a guessed diagonal is unreliable because the cyclic order of the constructed points is not controlled a priori.

imomathematicsolympiad
CF 105257C - Seats

We are given $n$ people and a fixed initial seating arrangement where person $i$ starts at seat $i$. Each seat is unique and every person occupies exactly one seat. Each person also has a preferred seat $ai$, which lies somewhere in a larger pool of seats $1 ldots 2n$.

codeforcescompetitive-programming
IMO 1987 Problem 1

For each permutation of ${1,\ldots,n}$, a fixed point is an index $i$ with $f(i)=i$.

imomathematicsolympiad
IMO 1986 Problem 6

A first attempt to force balance by treating each vertical or horizontal line independently fails because every point influences two constraints simultaneously, one vertical and one horizontal.

imomathematicsolympiad
IMO 1986 Problem 5

Substituting $y=2$ into the functional equation yields

imomathematicsolympiad
IMO 1986 Problem 4

A quick sanity check is to look at what the statement is really forcing on $X$.

imomathematicsolympiad
CF 105257M - Window Decoration

We are given up to ten thousand identical decorations placed inside a 100 by 100 square window. Each decoration is centered at an integer coordinate strictly inside the boundary, and each one is a rotated square whose diagonals align with the coordinate axes and have total…

codeforcescompetitive-programming
CF 105257L - Chess

We are given a game that depends on a chosen base $k$. For each test, there are $x$ coins on the table. Before the game starts, the first player selects an integer base $k ge 2$. After that, two players alternate moves.

codeforcescompetitive-programming
CF 105257K - Lethal Company

We are standing at a junction that connects multiple independent corridors. Each corridor is an infinite line extending away from us, and threats appear over time on these corridors.

codeforcescompetitive-programming
CF 105257J - Prime Guess II

We are given an array of integers $a1, a2, ldots, an$. For each query, we are also given a value $u$ and a starting position $l$.

codeforcescompetitive-programming
CF 105257I - Prime Guess I

We are interacting with a hidden prime power value. In each test case, the judge fixes an unknown prime $p$ and an exponent $k$, forming $q = p^k$. We are allowed to query powers of this hidden number: for any exponent $a$ we choose, we receive a transformed value $g(q^a)$.

codeforcescompetitive-programming
CF 105257H - Maximum Flow

We are given a directed acyclic graph where every edge can carry at most one unit of flow. From the source node 1, we are interested in every other node i and want to know how many edge-disjoint paths exist from 1 to i.

codeforcescompetitive-programming
CF 105257G - Disappearing Number

We are working with the natural numbers in increasing order, but one digit has been completely erased from existence. Any number that contains this forbidden digit is removed from the sequence.

codeforcescompetitive-programming
CF 105257F - Try a try, AC is OK

We are given several independent test cases. In each one, there is a list of integers representing scores of different code submissions. The player must submit code twice, and the final score is not a sum or maximum, but a bitwise AND of the two chosen submissions’ scores.

codeforcescompetitive-programming
CF 105257D - Double Subsequence

We are given a long string S and two short patterns s1 and s2. For every substring T of S, we look at how many times s1 appears in T as a subsequence and how many times s2 appears in T as a subsequence.

codeforcescompetitive-programming
CF 105257E - Trade Road

We are given a circle split into $K$ equally spaced positions, and a subset of $n$ of these positions contain markets. Each market sits at a fixed point on the circle, so we can think of the input as an increasing sequence of indices on a circular array.

codeforcescompetitive-programming
CF 105257B - Expression Matrix

We are asked to construct an $n times m$ grid filled with only three symbols: 1, +, and . The grid is not just a static object, it defines expressions in two directions. Every row, read left to right, becomes a valid arithmetic expression.

codeforcescompetitive-programming
CF 105257A - chmod

Each input line describes a Unix-like permission configuration encoded in a compact numeric form. Instead of directly giving permissions for a file, the system uses a three-digit number, where each digit independently describes the access rights for one of three user classes…

codeforcescompetitive-programming
IMO 1986 Problem 3

A direct attempt to repair the previous quadratic potential must first survive explicit consistency checks.

imomathematicsolympiad
IMO 1986 Problem 2

The construction applies successive $120^\circ$ clockwise rotations about the vertices $A_1,A_2,A_3$ in a periodic pattern.

imomathematicsolympiad
IMO 1986 Problem 1

Assume, for contradiction, that all six expressions

imomathematicsolympiad
CF 105259B - Mazes

The task asks us to construct a grid-based maze where movement is restricted to only going right or down, starting from the top-left cell and ending at the bottom-right cell. Some cells are empty and usable, while others contain hedges that block passage.

codeforcescompetitive-programming
IMO 1985 Problem 6

Testing small initial values clarifies the mechanism.

imomathematicsolympiad
IMO 1985 Problem 5

The configuration involves two circumcircles sharing the point $B$: the circumcircle of $ABC$ and the circumcircle of $KBN$.

imomathematicsolympiad
IMO 1985 Problem 4

The original approach fails because it tries to force a 4-term zero sum inside a single parity class, where no additive structure is guaranteed.

imomathematicsolympiad
CF 105259D - Double Agents

We are given a tree representing an organization. Each node is an employee, and edges represent direct communication links. We need to choose a non-empty subset of nodes such that no two chosen nodes are allowed to have another chosen node on the unique simple path between them.

codeforcescompetitive-programming
CF 105259C - Parcel Post

The network is a tree of routing stations, so between any two stations there is exactly one simple path. A parcel must always move along that unique path when going from a source to a destination, but at every station it can be moved in two different ways.

codeforcescompetitive-programming
CF 105259A - Make All Equal

We are given a hidden configuration of $N$ piles of stones arranged in a line, where $N$ is a power of two. Each pile has a height, and these heights are initially sorted in non-decreasing order.

codeforcescompetitive-programming
IMO 1984 Problem 5

Testing small cases gives a sanity check on the claimed structure.

imomathematicsolympiad
IMO 1984 Problem 4

The configuration contains two circles defined by diameters, hence both circles are determined by midpoints of $AB$ and $CD$.

imomathematicsolympiad
IMO 1984 Problem 3

Fix $O$ and $A$.

imomathematicsolympiad
CF 105262D - The FFT Problem

We are trying to choose a numeric base for representing a given integer so that its representation contains the digit 4 at least once. Among all such bases in a given range, we want the largest one. Concretely, for each test case we receive a number $n$.

codeforcescompetitive-programming
IMO 1984 Problem 2

The expression

imomathematicsolympiad
IMO 1984 Problem 1

The expression is

imomathematicsolympiad
IMO 1983 Problem 6

The reviewer’s critique isolates a structural mistake: any proof must avoid importing missing reverse-direction terms.

imomathematicsolympiad
CF 105262M - Maximum Subarray Alternating Sum

We are given an array of integers and asked to choose a contiguous segment and compute a modified sum over it. Inside the chosen segment, the first element is added, the second is subtracted, the third is added again, and this alternation continues until the end of the segment.

codeforcescompetitive-programming
CF 105262L - Growing Letters

We start with a construction that behaves like a recursively expanding string. Each number in the input array does not represent a single character directly; instead it defines a small string built from a fixed recursive rule.

codeforcescompetitive-programming
CF 105262K - The Red Tomato

We are given several independent experiments. In each experiment there is a fixed positive integer threshold $w$, which is unknown but consistent across all experiments in the same test case.

codeforcescompetitive-programming
CF 105262J - Just One More Bro, I Swear

The task describes a situation where a contest organizer decides how many problems are “hard” in a contest, and we are asked to determine the expected number of such hard problems when the total number of problems is fixed.

codeforcescompetitive-programming
CF 105262I - The Vampire Partner

We are given several independent scenarios where a row of cups contains some hidden original amounts of cappuccino.

codeforcescompetitive-programming
CF 105262H - Hot Cappuccino

We are given a grid representing a city split into n by m blocks. Each block may contain a coffee shop that offers cappuccino, hot chocolate, both drinks, or nothing.

codeforcescompetitive-programming
CF 105262G - Symmetric Subarrays

We are given an integer array and we look at every possible contiguous subarray. For each subarray, we assign it a value based on a simple symmetry condition. If the subarray reads the same from left to right and right to left, we take the sum of its elements as its value.

codeforcescompetitive-programming
CF 105262E - Tim Game

We are given a rooted tree with node 1 fixed as the root. Two players alternate moves, starting with the Secret Partner. A move consists of selecting any node other than the root and deleting that node together with every node in its subtree.

codeforcescompetitive-programming
CF 105262F - Fibonacci Strings

We are given two base strings, call them $F1$ and $F2$, and we define a sequence of strings where every later string is formed by concatenating the previous two in order. So $F3 = F2 + F1$, $F4 = F3 + F2$, and so on.

codeforcescompetitive-programming
CF 105262A - The Problems Problem

Each contestant faces a small set of at most 12 problems and has a fixed amount of time. They interact with the problems in a randomized way: instead of choosing an order in advance, they repeatedly pick uniformly among the remaining unused problems.

codeforcescompetitive-programming
CF 105262C - The Rectangular City

The grid describes a city where every cell has a letter label representing its type. Moving inside the city is constrained in a peculiar way: direct movement is not allowed between arbitrary cells. Instead, movement is always split into two phases.

codeforcescompetitive-programming
CF 105262B - Re-Indexing

We are given a book where each chapter has two attributes: a unique title and a unique starting page number. In a correct book, the chapters would be ordered by increasing starting page number, since that represents the actual reading order.

codeforcescompetitive-programming
CF 105263E - Painting Stones 2

We are given a line of $n$ stones, and each stone must be painted using one of $c$ available colors. The only restriction is about runs of identical colors: we are not allowed to have any block of length $k$ or more where all stones share the same color.

codeforcescompetitive-programming
CF 105263D - Pokémon Tazos

We are given a directed functional graph over friends. Each friend starts with a pile of identical items, and each item has a type equal to its owner. So friend $i$ initially holds $ni$ copies of type $i$. The process runs in rounds.

codeforcescompetitive-programming
CF 105263A - DDoS Attacks

We are processing a live stream of network events. Each event is either a configuration update or a packet arrival. A packet carries three pieces of information: the sender IP address, a timestamp, and the number of bytes in the packet.

codeforcescompetitive-programming
CF 105263B - Covering Holes

We are given several disjoint segments on a number line, where each segment represents a hole that must be covered by wood. Each hole is already separated from the next one, so there is no overlap between any two segments and also no touching endpoints.

codeforcescompetitive-programming
CF 105263C - VonitA Sequences

We are given several sequences of integers, and for each one we want to minimally modify elements so that the resulting sequence has a single “turning point” in a very specific sense.

codeforcescompetitive-programming
IMO 1983 Problem 5

A set containing no three terms of an arithmetic progression is constrained by the absence of configurations of the form $a-d, a, a+d$ with $d \neq 0$.

imomathematicsolympiad
IMO 1983 Problem 4

The set $\mathcal{E}$ is the union of the three closed segments $AB$, $BC$, and $CA$, so it is the boundary of the equilateral triangle $ABC$.

imomathematicsolympiad
IMO 1983 Problem 3

The expression $xbc+yca+zab$ is a non-negative integer linear combination of the three pairwise products $ab$, $bc$, and $ca$.

imomathematicsolympiad
IMO 1983 Problem 2

Two circles intersect at two points, so the segment joining their centers is a radical axis configuration with two distinct intersection points.

imomathematicsolympiad
IMO 1983 Problem 1

Fixing $x=1$ in the functional equation yields $f(f(y))=y f(1)$, so the behavior of $f$ is controlled by its value at $1$.

imomathematicsolympiad
CF 105264B - Depth Range Update

We are given a rooted tree with node 1 as the root, and each node carries a value. The depth of a node is its distance from the root in edges. Two operations are performed.

codeforcescompetitive-programming
IMO 1982 Problem 6

A direct attempt to localize the curve via strips or coordinate pigeonhole fails because Euclidean proximity is not controlled by being in the same horizontal or vertical region, and opposite sides of…

imomathematicsolympiad
IMO 1982 Problem 5

A regular hexagon admits a convenient coordinate realization in which opposite vertices lie on coordinate axes and successive vertices differ by rotations of $60^\circ$.

imomathematicsolympiad
CF 105264M - Kaaa

We are given a single short string representing what Mohanad hears at 8am. The task is to decide whether this exact sound matches a very specific pattern associated with the crow: the string must be exactly three repetitions of the substring “Kaaa”, with no extra characters…

codeforcescompetitive-programming
CF 105264K - Minimum Sum

We are given a list of $n$ very large integers, each written as an $n$-digit string (leading zeros are allowed, so we treat them as fixed-length numbers rather than variable-length integers). We process indices from $1$ to $n$ in increasing order.

codeforcescompetitive-programming
CF 105264L - The Shrine of the Father of Forces

We are asked to count how many permutations of the numbers from 1 to n satisfy a structured constraint involving the positions of elements. The array is indexed from 0, and n is always odd. The positions are split into odd and even indices.

codeforcescompetitive-programming
IMO 1982 Problem 4

Write $\omega = e^{2\pi i/3}$.

imomathematicsolympiad
CF 105264J - Game of Primes

We are given a multiset of integers. There is a second multiset that starts empty. Two players alternately remove an element from the first multiset.

codeforcescompetitive-programming
CF 105264I - Homies and Not Homies

Each test case gives a number $n$, and we conceptually build rows numbered from $1$ to $n$. Row $i$ is the binary representation of $i$, written without leading zeros, and each bit corresponds to a bulb that is either on (1) or off (0).

codeforcescompetitive-programming
CF 105264H - Good Array

We are given an array of positive integers. We are allowed to repeatedly perform a special operation that redistributes powers of two between elements: pick an index whose value is even, reduce it by half, and simultaneously double another element.

codeforcescompetitive-programming
CF 105264F - Tree XOR

We are given a tree where each vertex carries a small integer value (at most 63). The task is to select some vertices that form a connected subgraph and make the bitwise XOR of their values equal to a target number $k$.

codeforcescompetitive-programming
CF 105264G - The Elden Program

We are given a row of monsters, each with a fixed power value. For each test case, we are asked to imagine a scenario where we choose one monster as a “target” that is frozen in place.

codeforcescompetitive-programming
CF 105264E - Changes in Antwanland

We are given a tree with n vertices. We are allowed to keep exactly k vertices and consider the subgraph they induce. Since the chosen vertices must still form a connected tree, the selection is effectively constrained to a connected k-node subtree of the original tree.

codeforcescompetitive-programming
CF 105264D - Make It Minimum

We are given a string of digits. From it, every adjacent pair of characters forms a two-digit number, and the sum of all such pair values defines a score. For a string s = s1 s2 ...

codeforcescompetitive-programming
IMO 1982 Problem 3

The expression

imomathematicsolympiad
CF 105264C - Variety Hater

We are given an array of integers, and we are allowed to perform a limited number of unit adjustments. Each operation picks a single position and increases or decreases that value by exactly one.

codeforcescompetitive-programming
CF 105264A - Goals, Goals! Everywhere

We are given a team where each player reports a number of “contributions”. A contribution is either a goal scored or an assist that helped another player score a goal. Every goal has exactly one scorer, and it may optionally have one assistant.

codeforcescompetitive-programming
IMO 1982 Problem 2

The reviewer’s first objection shows that the original construction of $S_i$ was based on an incorrect invariance claim about reflection across an angle bisector.

imomathematicsolympiad
CF 105266C - 重量II

We are given several test cases. In each case, there are several types of weights, and each type has an unlimited supply. However, there is a restriction in how we use them: all chosen weights must be placed on the same side of a balance scale.

codeforcescompetitive-programming
IMO 1982 Problem 1

The previous approach failed because it attempted to propagate “local errors” globally without any invariant controlling how the defect $f(m+n)-f(m)-f(n)\in{0,1}$ behaves under different decomposition…

imomathematicsolympiad
IMO 1981 Problem 6

The defining relations suggest a two-dimensional recursion where increasing the first argument modifies the entire dependence on the second argument, while the second argument evolves through repeated…

imomathematicsolympiad
IMO 1981 Problem 5

The configuration involves three congruent circles inside a triangle, each tangent to two sides, and all passing through a common point $O$.

imomathematicsolympiad
CF 105266F - 首发阵容

There are five fixed roles that must be filled by exactly five distinct players. Each player comes with a constraint encoded as a length-5 binary string, where a 1 indicates that the player is capable of playing the corresponding role.

codeforcescompetitive-programming
CF 105266D - 子串

We are given a string consisting of lowercase English letters. For each test case, we must choose two substrings that do not overlap in the original string.

codeforcescompetitive-programming
CF 105266E - 翻转

We are given two arrays of equal length. We start with array a, and we are allowed to optionally choose a single contiguous segment and reverse it. After performing this operation at most once, we compare the resulting array with a fixed array b of the same length.

codeforcescompetitive-programming
CF 105266B - 按位或

We are given several test cases. In each test case there is an array of integers, and we are allowed to reorder it arbitrarily. After choosing a permutation, we look at all split points of the permuted array.

codeforcescompetitive-programming
CF 105266A - 最大公约数与和

We are given a sequence of positive integers and asked to count how many contiguous subarrays satisfy a simple-looking inequality involving two classical range functions: the greatest common divisor of all elements in the subarray and the sum of all elements in the same subarray.

codeforcescompetitive-programming
IMO 1981 Problem 4

Let the $n$ consecutive integers be

imomathematicsolympiad
IMO 1981 Problem 3

The condition

imomathematicsolympiad
CF 105535G - Gorgeous Summation

We are given a sequence and asked to consider every contiguous subarray whose length is even. For each such subarray, we pair elements from the ends inward: first with last, second with second-last, and so on.

codeforcescompetitive-programming
CF 105530D - Nice (Easy Version)

The task is about choosing the smallest number from a very small fixed set that is not smaller than a given integer. The “nice numbers” are already known and limited to six specific values: 6, 9, 66, 69, 96, and 99.

codeforcescompetitive-programming
IMO 1981 Problem 2

Fix integers $1 \le r \le n$.

imomathematicsolympiad
CF 105507D - Преобразование строки

We are given two strings of equal length, both consisting of lowercase Latin letters. The only allowed operation takes the first character of the current string, removes it, and reinserts it anywhere in the string, including back to the front or the end.

codeforcescompetitive-programming
CF 105505C - Cindy's Christmas Challenge

We are given a fixed target composition: a sequence that consists of exactly R red balls followed by B blue balls. Think of it as a rigid template of length R + B. We also have a long string S made of three types of balls, red, blue, and green.

codeforcescompetitive-programming
CF 105505E - Evereth Expedition

We are given a sequence of length $N$ that is supposed to represent a complete visit order of all stations numbered from $1$ to $N$. Some entries are missing, shown as zeros, while the others are fixed and already distinct.

codeforcescompetitive-programming
CF 105498B - The Fortune Dice

We are given a single integer that represents a desired total score from rolling a standard six-sided die twice. Each roll produces a value between 1 and 6 inclusive, and the final outcome is the sum of the two results.

codeforcescompetitive-programming
IMO 1981 Problem 1

Let $a=BC$, $b=CA$, $c=AB$.

imomathematicsolympiad
CF 105267C - Diamond

We are given a set of points in the plane and need to count how many distinct selections of five points can form a very specific geometric configuration called a “diamond”. A valid diamond is not just any 5-tuple.

codeforcescompetitive-programming
CF 105267D - A xor B problem

We are working in a very unusual “programming model” where we do not directly compute expressions like XOR, but instead manipulate 32-bit variables through a small instruction set.

codeforcescompetitive-programming
IMO 1979 Problem 6

The octagon is a cycle graph on eight vertices with two distinguished opposite vertices $A$ and $E$.

imomathematicsolympiad
IMO 1979 Problem 5

The system involves three weighted power sums over the set ${1,2,3,4,5}$ with nonnegative weights $x_1,\dots,x_5$.

imomathematicsolympiad
IMO 1979 Problem 4

Fix the plane $p$ and points $P \in p$ and $Q \notin p$.

imomathematicsolympiad