brain

tamnd's digital brain — notes, problems, research

41641 notes

CF 105271J - Star Union and Cyber-viruses

We are given a tree with $n$ vertices, and a collection of $m$ distinct “virus types”. Each virus type behaves like a multi-source spreading process on the tree: once a virus is inserted at a vertex, it spreads outward along edges in unit time per edge, effectively forming…

codeforcescompetitive-programming
CF 105271I - topoLogical problem

We are building a closed walk on an infinite grid starting from the origin, initially facing east. The walk consists of exactly $n$ straight moves.

codeforcescompetitive-programming
CF 105271H - Railgun and anime-like points

We are given a fixed set of points on the plane. From this set, we are allowed to pick some points and mark them as special.

codeforcescompetitive-programming
IMO 1964 Problem 4

Something went wrong.

imomathematicsolympiad
CF 105271E - Blasted hedgehogs!

We are given a sequence of hedgehogs, each arriving at a known time and staying in a clearing for a fixed duration $T$. While a hedgehog is present, it can be removed by an action called “throwing food”.

codeforcescompetitive-programming
CF 105271G - Leba Non and meals

We are given a directed structure over $n$ cages where each cage has exactly one outgoing tunnel leading to another cage.

codeforcescompetitive-programming
CF 105271D - Beautiful triplets

We are given an array of length n where each position stores a small positive integer. A valid structure is a triple of indices i, j, k with i < j < k such that the values form a strict decreasing divisibility chain: a[i] is divisible by a[j], and a[j] is divisible by a[k]…

codeforcescompetitive-programming
CF 105271B - Guess an array

We are dealing with a hidden array that is already sorted in non-decreasing order. Every element lies between 1 and n, and we are allowed to ask targeted questions about individual positions.

codeforcescompetitive-programming
CF 105270A - Short Query

We are given an array of integers. In one move, we are allowed to pick two different elements. If their sum is even, we remove both and append their sum back into the array, so the array size decreases by exactly one.

codeforcescompetitive-programming
IMO 1964 Problem 3

Let $\triangle ABC$ have semiperimeter $s$ and area $\Delta$, with inradius $r$.

imomathematicsolympiad
CF 105270E - Not a Segment Tree

We are given a circular array and a second target array of the same length. One operation lets us pick an index and overwrite that position with the sum of a symmetric window around it, extending k steps to both sides on the circle.

codeforcescompetitive-programming
CF 105270D - Eleven

We are given a binary string and we are allowed to modify it using a second binary string that has exactly $m$ ones. Each position where this second string has a 1 flips the corresponding bit of the original string. After all flips, we obtain a new string $T$.

codeforcescompetitive-programming
CF 105270B - Minimum MEX

We are given an array and we are allowed to look at any contiguous segment of it. For every such segment we compute its MEX, the smallest non-negative integer that does not appear inside the segment. Among all segments, we first care about those whose MEX is as large as possible.

codeforcescompetitive-programming
IMO 1964 Problem 2

The expression is symmetric and homogeneous of degree three, suggesting a normalization or a classical symmetric inequality.

imomathematicsolympiad
CF 105066C - Alternet is Cheating

We are given a knockout tournament with $N$ players, where $N$ is a power of two. Matches are fixed: adjacent players in the current list play, and winners move forward in order to the next round. This continues until a single champion remains.

codeforcescompetitive-programming
IMO 1964 Problem 1

The problem concerns divisibility of powers of $2$ by $7$, so the natural setting is arithmetic modulo $7$.

imomathematicsolympiad
IMO 1963 Problem 6

A complete resolution requires controlling two independent structures at once.

imomathematicsolympiad
CF 105066G - Sleepy Pandas

We are given an array of integers, where each value is a label written on a panda. For every ordered pair of distinct indices $(i, j)$, we imagine taking the two numbers $xi$ and $xj$ and concatenating them in that order to form a new integer.

codeforcescompetitive-programming
IMO 1963 Problem 5

Direct substitution with high-precision numerical evaluation confirms that

imomathematicsolympiad
CF 105066E - Richard Lore

We are given an array of values and a fixed sequence of index swaps that Jinshi repeatedly applies whenever he “tests” whether the array can be sorted. Importantly, after every test he restores the array, so the swap sequence always runs on a fresh copy.

codeforcescompetitive-programming
CF 105066D - Haagendaz is Justice

Two people take turns eating from an infinite sequence of numbered items, starting from 1 and going upward without gaps. The key rule is that each person does not eat a fixed amount: instead, on their turn they eat as many items as their current “capacity” allows.

codeforcescompetitive-programming
CF 105066B - A Bit of Monkeying

We are given an array of integers and two independent processes that try to transform it. Each process receives its own copy of the same array.

codeforcescompetitive-programming
CF 105066A - It's Time to Submit

The task is intentionally minimal: we are given a single integer T and must decide whether it is possible to obtain the string "YES" by simply printing the sample output provided in the problem statement.

codeforcescompetitive-programming
CF 105064B - SGPA Calculation

We are asked to construct any valid set of marks for Bob’s $n$ courses, each mark being an integer between 0 and 2047, with one extra constraint: the bitwise XOR of all marks must equal a given value $x$.

codeforcescompetitive-programming
CF 105062C - The Other Half

Each test case gives two large integers, but the formatting in the input suggests they should be read as independent values rather than interpreted as arithmetic expressions.

codeforcescompetitive-programming
CF 105062B - TheForces ORZ

We are given a single small integer $n$, with $1 le n le 8$, and we must output a specific integer that depends only on this value. There are no additional structures, no hidden input, and no multi-step interaction.

codeforcescompetitive-programming
CF 105059C - SeaTac

We are given a connected undirected graph that represents a city, where intersections are nodes and roads are edges. A car starts at node 1 and must reach node n. Every road costs exactly one unit of fuel to traverse.

codeforcescompetitive-programming
CF 105059D - Assignment Allocation

We are given a semester divided into days, and a collection of assignments. Each assignment is available only during a fixed interval of days, from its start day to its deadline day, and it can be completed on any single day inside that interval.

codeforcescompetitive-programming
CF 105058A - Степенные числа

We are given many independent queries. Each query provides two integers, a starting value n and a base k. We want to find the smallest integer x such that x ≥ n and x can be written as a sum of distinct powers of k. This means we are allowed to pick exponents a1, a2, ...

codeforcescompetitive-programming
CF 105058C - Нечестная игра

We are given an $n times m$ grid with a single token (the “piece”) starting at cell $(r, c)$. The game evolves in discrete rounds.

codeforcescompetitive-programming
CF 105056D - Tasks at Odoo

We are given a line of tasks, each with a fixed processing time, and a global deadline. Tasks must be launched in order, meaning task i cannot begin before task i-1 has been started. This creates a dependency chain on start times, not on completion order.

codeforcescompetitive-programming
CF 105056A - Potential Odoo Email

We are given a single string that is supposed to represent an email-like identifier, and we need to decide whether it matches a very specific pattern used by a fictional group of addresses. A valid string must consist of two parts separated by a single '@' character.

codeforcescompetitive-programming
IMO 1963 Problem 4

The system is a cyclic linear homogeneous system with five variables and a real parameter $y$.

imomathematicsolympiad
IMO 1963 Problem 3

The first issue is whether the hypothesis “consecutive sides satisfy $a_1 \ge a_2 \ge \cdots \ge a_n$” is purely linear or implicitly cyclic.

imomathematicsolympiad
IMO 1963 Problem 2

For a point $P$ in space, the condition that the angle with vertex at $P$ has one side passing through $A$ and the other intersecting segment $BC$ means that there exists a point $X \in BC$ such that…

imomathematicsolympiad
IMO 1963 Problem 1

The equation

imomathematicsolympiad
CF 105056C - Viruses

We are simulating objects moving on a one-dimensional line segment from position 0 to a fixed destination k. Each module starts somewhere on this line and moves to the right at a constant speed of one unit per second.

codeforcescompetitive-programming
IMO 1959 Problem 6

All invalid reasoning in the previous attempt comes from unbounded motion along a line and from treating angle limits at infinity as meaningful geometric invariants.

imomathematicsolympiad
CF 105056H - Views Testing

We are given a tree of views. Each view can move to any other view by following a unique shortest path, and moving between two views has a cost equal to the number of edges on that path. Alongside the tree, there is a cyclic array of size $k$.

codeforcescompetitive-programming
CF 105056G - Giant Community

We are given a rooted inheritance structure of applications. Each app has a unique identifier, a parent pointer, and two parameters that define a linear profit function over time: a slope and an intercept.

codeforcescompetitive-programming
IMO 1959 Problem 5

Small values of $m$ are checked to determine structural invariants.

imomathematicsolympiad
CF 105056F - Odoo Trees

We are given a company hierarchy that forms a rooted tree, where employee 1 is the root and every other employee has exactly one direct manager. Any employee’s subtree represents all people under them in the organizational chart. Each employee starts with an initial salary.

codeforcescompetitive-programming
CF 105056E - POS Kiosk

We are given an array of integers where each value describes the net change in stored records during a batch: positive values increase occupied space and negative values free space.

codeforcescompetitive-programming
CF 105056B - Make it ODOO!

We are given a string made only of the characters O and D. We are allowed to modify it using two operations, each costing one minute. One operation deletes a single character, but only if it is at the left end or the right end of the string.

codeforcescompetitive-programming
CF 105058E - Годовой отчет

We are given several independent scenarios. In each scenario, there are up to 40 candidates, each carrying a label that encodes their knowledge about a fixed number of topics as a bitmask.

codeforcescompetitive-programming
CF 105058D - Стековое кодирование

We are given a static array and for each query we must output a sequence of stack operations that reproduces exactly the subarray defined by the query, using a very specific encoding model. The model is a stack that supports three actions.

codeforcescompetitive-programming
CF 105058B - Mixing Drinks

We are given a cup made of multiple horizontal layers of coffee. Each layer has a fixed volume (height) and a fixed “strength”. The layers are stacked from bottom to top, and initially nothing is mixed.

codeforcescompetitive-programming
CF 105059B - Bus Routes

We are given a street with stops labeled from 1 to n, and we want to move from stop 1 to stop n. Movement is free only when it happens through bus routes, and otherwise it costs exactly the distance walked along the line. Each bus route is an interval [L, R].

codeforcescompetitive-programming
IMO 1959 Problem 4

The previous approach failed because it tried to manufacture several derived lengths from $c$ without a coherent straightedge-and-compass dependency chain and without a well-defined geometric configur…

imomathematicsolympiad
IMO 1959 Problem 3

Let $t=\cos x$.

imomathematicsolympiad
CF 105059F - Average of Averages

We are given an integer array and we look at every contiguous segment of it. For each segment, we compute its average value, meaning the sum of elements in that segment divided by its length. The task is to take all these segment averages and compute their overall mean.

codeforcescompetitive-programming
CF 105059E - Mole Whacking Robots

We have a line of $n$ holes labeled from 1 to $n$. Each hole contains a single mole, and every mole appears exactly once during a game that lasts $n$ seconds.

codeforcescompetitive-programming
IMO 1959 Problem 2

Let

imomathematicsolympiad
CF 105059A - Luddy Rocks

The task is essentially about checking whether a fixed target word can be constructed from the letters available in a given string. For each test case, we are given a “banner” made of uppercase letters.

codeforcescompetitive-programming
CF 105062A - Is It Rated??

We are given two integers, m and d. Think of m as a month number in a calendar year and d as a day of the month. The task is to decide whether this pair can represent a valid calendar date in the simplified world implied by the problem.

codeforcescompetitive-programming
CF 105062E - Fixing Chaos

The problem describes a sequence of special values called “chaos points,” indexed starting from 1. We are given a small index $n$, and we must output the value associated with the $n$-th position in this sequence.

codeforcescompetitive-programming
CF 105062D - Important Memories

The input describes a single integer $n$, constrained to a very small range from 1 to 6. There is no additional structure, no secondary parameters, and no hidden dataset implied by the statement. The task is to produce a single integer output based on this value.

codeforcescompetitive-programming
CF 105064A - A Highly Constrained Problem...

We are asked to construct a permutation of length $n$, meaning each integer from $1$ to $n$ appears exactly once, such that every position $i$ carries two independent constraints that describe how it participates in increasing subsequences.

codeforcescompetitive-programming
Kvant Physics Problem 36

The scan of Kvant problem F36 is missing, so the physical system, numerical data, and even the problem statement are not available.

kvantphysics
CF 105064K - ab ba count

We are given a small alphabet, at most 7 letters, and a set of allowed swaps between ordered pairs of characters. Each swap rule says that whenever we see two positions in a string whose characters match one of these directed pairs, we are allowed to swap those positions.

codeforcescompetitive-programming
CF 105064J - Non-Intersecting Arcs

We are counting how many permutations of numbers from 1 to n can be arranged so that when we connect consecutive elements with straight segments, those segments never cross in their interiors.

codeforcescompetitive-programming
CF 105064I - k-goodness

We are given an integer array. From this array we define two special quantities that depend on how we restrict subarrays. The first quantity, call it $m0$, comes from looking only at subarrays that contain no negative numbers.

codeforcescompetitive-programming
CF 105064H - Tree Scoring

We are given a sequence of values placed on the vertices of an unknown rooted tree. The root is fixed at vertex 1, and every other vertex must attach to a parent with a strictly smaller label.

codeforcescompetitive-programming
CF 105064G - Armed Soldiers 1

We are given a set of soldiers placed on a number line. Each soldier has a fixed position and a weapon with a certain power. When a monster appears at some position, every soldier shoots toward that position.

codeforcescompetitive-programming
CF 105064F - Armed Soldiers 2

Each soldier sits at an integer position on a number line and has a firing strength. A monster appears at some position and comes with a shield that weakens incoming bullets depending on how far they travel.

codeforcescompetitive-programming
CF 105064E - Color Conundrum

We are working with a rooted tree where each vertex carries a color label. The root is fixed at vertex 1. On this tree, we must support two operations over time: recoloring a single vertex, and querying how many vertices of a given color exist inside a particular subtree.

codeforcescompetitive-programming
CF 105064D - Snakes Among Us

We are dealing with a classroom of an odd number of students, each secretly holding a nonzero integer score. Exactly one student has the largest score, and that score is strictly greater than everyone else.

codeforcescompetitive-programming
CF 105064C - You and Assignments

Each course has a number of assignments, and we are allowed to repeatedly transform the value in any single course using a special operation that depends on its index. The goal is to minimize the sum of all course values after applying these operations any number of times.

codeforcescompetitive-programming
CF 105066H - Afterimages

We are given two arrays of heights, each of length $n$, representing two lines of Korosensei’s afterimages. During each song, every position $i$ forms a pair between the $i$-th element of the first line and the $i$-th element of the second line, and their interaction cost is…

codeforcescompetitive-programming
CF 105066L - Gaslighting

We are given a fixed string and then a large number of queries, each query specifying a substring interval $[l, r]$.

codeforcescompetitive-programming
CF 105066K - Another Ordering Problem

We are given a collection of sushi toppings, each topping having a cost and a single forbidden relationship. If we choose topping i, then another specific topping bi is not allowed to appear together with it.

codeforcescompetitive-programming
CF 105066J - Everyone Loves Threes Magic (Easy Version)

We are given many independent queries, and each query defines an interval $[L, R]$ with values up to one million. For each such interval, we must imagine all subintervals $[l, r]$ that lie completely inside it, meaning $L le l le r le R$.

codeforcescompetitive-programming
CF 105066I - Another Bitwise Problem

We are given an array of integers, and we repeatedly apply a transformation controlled by a nonnegative integer parameter $x$. For a fixed choice of $x$, every array element $ai$ is XORed with $x$, and all these results are summed together.

codeforcescompetitive-programming
CF 105066F - Unique Subsequences

We are given a string and a target length $k$. From this string, we consider every possible subsequence of length $k$. A subsequence is formed by choosing positions in increasing order, not necessarily contiguous, and reading the characters at those positions.

codeforcescompetitive-programming
Kvant Math Problem 1499

We seek infinitely many rational solutions of

kvantmathematicsolympiad
Kvant Math Problem 1497

A toroidal $15\times 15$ chessboard can be identified with the group $\mathbb Z_{15}\times\mathbb Z_{15}$, where coordinates are taken modulo $15$.

kvantmathematicsolympiad
Kvant Math Problem 1477

The phrase “cut off a similar one” is interpreted in the standard geometric sense used in olympiad problems: from a convex polygon one performs cuts along straight lines intersecting adjacent sides, p…

kvantmathematicsolympiad
Kvant Math Problem 1473

Let

kvantmathematicsolympiad
Kvant Math Problem 1463

Part (a): let

kvantmathematicsolympiad
Kvant Math Problem 1462

Let

kvantmathematicsolympiad
Kvant Math Problem 1459

The vessel rotates steadily about a vertical axis.

kvantmathematicsolympiad
Kvant Math Problem 1458

I cannot produce a correct solution to M1458 from the text alone, because the problem explicitly depends on the geometry of the pulley arrangement shown in the figure.

kvantmathematicsolympiad
CF 105270C - Range Contradiction

We are given an array of even length, and we are allowed to freely reorder its elements using swaps, so in effect we can permute it arbitrarily.

codeforcescompetitive-programming
CF 105271K - MnTm

We are given a grid of seats with n rows and m columns. Each cell contains a cost, and picking a seat means paying that cost. AAlikhan wants to choose exactly k + 1 seats (himself plus k friends) such that the total cost does not exceed a budget B.

codeforcescompetitive-programming
CF 105271F - Minim and his struggle

Minim has a sequence of n hours before an exam. At each hour, exactly one activity is possible: either eating or sleeping, depending on a given string. A character e means he is allowed to eat in that hour, and s means he is allowed to sleep.

codeforcescompetitive-programming
CF 105271A - ACC triangle

We are given two types of resources: one type represents single “A” pieces and the other represents “C” pieces. Using these, we want to build a triangular structure where row i contains exactly one A followed by i−1 C’s. So the structure grows row by row.

codeforcescompetitive-programming
CF 105272I - Investigating Mars

We are given a rectangular grid where each cell is either empty, a wall, or the unique starting position of a robot. The robot starts with an initial direction encoded in that starting cell, and then repeatedly applies a deterministic movement rule.

codeforcescompetitive-programming
CF 105272F - Festival of the Moon

We are observing a single festival where every participant bought exactly one ticket. There are two ticket types: a normal ticket costing v and a discounted lunar ticket costing exactly half of that, v/2, where v is guaranteed to be even.

codeforcescompetitive-programming
CF 105272B - Battle in space

Two players take turns writing a number. First, the opponent announces an integer n. After seeing it, we choose our own integer m. Whoever writes the larger number wins immediately.

codeforcescompetitive-programming
CF 105276J - Joining Two Trees

We are given two separate trees, one on the vertices of the first block and one on the vertices of the second block. We are allowed to connect exactly one vertex from the first tree to exactly one vertex from the second tree, turning the whole structure into a single tree.

codeforcescompetitive-programming
CF 105276B - Binary Bracket

We are given a fixed single-elimination tournament with $2^K$ players. The bracket structure is completely predetermined: players are placed in order, first round pairs adjacent indices, then winners of adjacent matches face each other in the next round, and so on until one…

codeforcescompetitive-programming
CF 105278H - Emblems

A Codeforces user is tracked through their rating history, and their “status tier” changes as their rating crosses fixed thresholds such as pupil, specialist, expert, and so on.

codeforcescompetitive-programming
CF 105278C - s-parkour

We are given a sequence of building heights, all distinct. For any interval from index $i$ to $j$, we imagine walking along the buildings in order. Each step compares two consecutive heights: if we move to a higher building it is an ascent, otherwise it is a descent.

codeforcescompetitive-programming
CF 105283H - Digit Removal

We are given a very large integer a and another integer b, both written as decimal strings. The number a has exactly four more digits than b.

codeforcescompetitive-programming
CF 105283A - P!=NP

We are asked to count how many ordered pairs of integers $(n, p)$ satisfy a small set of constraints involving a product relationship between the two values. The value $p$ is chosen first and is restricted to the range $0 le p le P$.

codeforcescompetitive-programming
CF 105284H - Thomas Sometimes Hides His Feelings in C++

We are given an even number of indices, each representing a character trope. Between every ordered pair of tropes we have a directed value, which may be negative one meaning the relationship is forbidden, or a nonzero modular value otherwise.

codeforcescompetitive-programming
CF 105284A - P!=NP

We are asked to count integer pairs $(n, p)$ where $p$ is constrained to lie between $0$ and $P$, and two arithmetic conditions involving multiplication and factorial-like behavior must both hold.

codeforcescompetitive-programming
CF 105292E - Employees Selection

We are given a company hierarchy that forms a rooted tree, with employee 1 as the root and every other employee having exactly one direct supervisor.

codeforcescompetitive-programming
CF 105293A - Mr. Wow and Lucky Array

We are given a binary array where each prefix is tightly constrained: every element is either 0 or 1, and at any prefix position, the number of ones cannot exceed half of the prefix length (rounded down).

codeforcescompetitive-programming
CF 105297K - Grabbing plush

We are given a row of N stuffed animals, each with an integer value that can be positive or negative. We are allowed to perform at most M operations.

codeforcescompetitive-programming