brain

tamnd's digital brain — notes, problems, research

43815 notes

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 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
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
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 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
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
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
IMO 1979 Problem 3

Let the two circles intersect at $A$ and another point $B$.

imomathematicsolympiad
CF 105267J - 简单的指数运算

We are given two numbers: a positive integer $N$ and a prime $P$. The task is to compute a double sum over all ordered pairs $(i, j)$ where both indices run from $1$ to $N$.

codeforcescompetitive-programming
CF 105267I - 黄金树

We are given a rooted tree where every node starts with an initial positive integer value. Time evolves in discrete steps, and each node carries a value that changes every day according to a local rule involving its parent. At day zero, each node i has a value a[i].

codeforcescompetitive-programming
CF 105267H - Duel on the Chessboard

We are given a small grid with obstacles and two special cells containing pieces A and B. Initially these two pieces occupy adjacent cells.

codeforcescompetitive-programming
CF 105267G - Candidate Master of Both (VI)

We are given an array of length $n$, and for every pair of indices $(l, r)$ with $l le r$, we define a value that depends on whether the greatest common divisor of the two endpoints equals a chosen parameter $k$.

codeforcescompetitive-programming
CF 105267F - 静流的路径

We are given a number $N$ that is fully described by its prime factorization. Every prime $pi$ appears with the same exponent $m$, so $N = p1^m p2^m cdots pk^m$.

codeforcescompetitive-programming
CF 105267E - Rolling for the Destination

We start at position zero on an infinite number line and repeatedly roll a fair four-sided die, which produces one of the values 1, 2, 3, or 4 with equal probability. After each roll we move forward by the rolled amount.

codeforcescompetitive-programming
CF 105267A - 2026美加墨世界杯

We are simulating the final round of a four-team football group. Three matches are already known: China has already played two matches against Thailand, and now only the last round remains, consisting of China versus Korea and Thailand versus Singapore.

codeforcescompetitive-programming
CF 105267B - Stop! High School Maths Please No More

We are given an array of positive integers and we are allowed to overwrite elements arbitrarily. Each overwrite picks an index and assigns it any positive integer value. The goal is to transform the array into a geometric progression whose common ratio is a positive integer.

codeforcescompetitive-programming
IMO 1979 Problem 2

A direct attempt to force a contradiction from mixed colors on a single pentagon typically fails because cross edges can absorb local inconsistencies without producing a monochromatic triangle.

imomathematicsolympiad
CF 105351A - Ancient Berland Roads

We are given a graph of towns connected by roads, and each town carries a population value. A “region” is simply any connected component formed using the roads that are currently usable.

codeforcescompetitive-programming
CF 105482A - Acoustic String

We are given a binary string and a deterministic transformation that repeatedly shrinks it. Each transformation step replaces the string with a new one formed by taking XOR of adjacent characters.

codeforcescompetitive-programming
IMO 1979 Problem 1

The alternating sum is examined for small truncations to detect structure.

imomathematicsolympiad
IMO 1978 Problem 6

The previous argument attempted to manufacture a recurrence for Schur numbers by deleting minimal elements of color classes.

imomathematicsolympiad
CF 105536A - Подготовка к олимпиаде

We are asked to distribute a fixed number of problems across a fixed number of days. Each day we choose how many problems to solve, and the sequence of daily counts must be non-decreasing.

codeforcescompetitive-programming
CF 105535K - Know Your Duration of Stay

We are given a calendar that is no longer the standard one year structure, but instead consists of a sequence of months, each with its own number of days. A date is represented as a pair of integers: a day inside a month and the month index.

codeforcescompetitive-programming
CF 105535I - Imperial Decree

We are given an $n times m$ grid where each cell has a non-negative weight. A random process picks two points in the grid, and those two points define a rectangle whose sides are parallel to the grid. The task is to compute the expected area of that rectangle.

codeforcescompetitive-programming
CF 105535A - Arithmetics and That's It

We are given a sequence of integers and allowed to delete at most k of them. After deletions, the remaining numbers must form an arithmetic progression when read in their original order.

codeforcescompetitive-programming
CF 105535D - Desired Distance

We are given a set of points in the plane, except one point is missing. There are already $n-1$ fixed points, and we are allowed to choose the coordinates of the final $n$-th point.

codeforcescompetitive-programming
CF 105530I - Delete the String

We are given a string, and we repeatedly perform an operation where we delete a contiguous segment. Each deletion removes a substring, and after deletions, the remaining characters collapse together as if the string is reindexed.

codeforcescompetitive-programming
CF 105530H - Break the Walls

We are given a grid where movement is restricted to only two directions: right and down. Some cells contain obstacles, and normally stepping into an obstacle would block movement.

codeforcescompetitive-programming
CF 105530G - I am Tired of Xor Problems

The task revolves around a multiset of values that are interpreted as exponents in a polynomial-like structure where addition is replaced by XOR.

codeforcescompetitive-programming
CF 105530E - Nice (Medium Version)

We are looking at numbers formed using only two digits, 6 and 9. Any valid number is “nice” if every position is one of these two digits.

codeforcescompetitive-programming
CF 105530B - Modular MEX

We are looking at all remainders produced by fixing a number $n$ and dividing it by every integer $i$ from $1$ to $n$. This gives a set of values of the form $n bmod i$.

codeforcescompetitive-programming
CF 105530C - Too Much Walking

We are given a collection of points on a 2D grid, where each point can be thought of as a cell with integer coordinates. For every point, we want to determine how far it is from the farthest other point, where distance is measured using Manhattan distance.

codeforcescompetitive-programming
IMO 1978 Problem 5

The expression involves a weighted sum of distinct positive integers $f(1),\dots,f(n)$ with weights $1/k^2$, which decrease strictly with $k$.

imomathematicsolympiad