brain

tamnd's digital brain — notes, problems, research

43815 notes

CF 105307B - Emma and the Pixie dust

We are given a large set of distinct positive integers representing “cuteness levels”. From these numbers, Emma first selects exactly $N$ elements.

codeforcescompetitive-programming
CF 105307C - Chopsticks

We are given a collection of identical “pairs” of chopsticks, where each pair is characterized by a single integer length. From each pair we can treat the two chopsticks as two equal sides of a rectangle.

codeforcescompetitive-programming
CF 105297L - Night at Hazrat Sultan

We are maintaining a dynamic set of points on the plane. Initially we are given a collection of stars, each represented by integer coordinates. After that, we repeatedly add or remove stars.

codeforcescompetitive-programming
CF 105297J - Acarajé

We are given a list of potential customers, where each customer has a maximum price they are willing to pay for a product. If we set a price $P$, then exactly those customers with $pi ge P$ will buy the product, and each of them contributes $P$ to the revenue.

codeforcescompetitive-programming
CF 105297I - From Baikonur to Mars

We are given an array of non-negative integers, where each value represents the height of a mountain. The goal is to reduce every value to zero using as few operations as possible. Two operations are available, and both can be applied to any chosen subset of indices.

codeforcescompetitive-programming
IMO 1966 Problem 3

The problem concerns a regular tetrahedron with vertices $A,B,C,D$ and circumcenter $O$.

imomathematicsolympiad
CF 105297H - Traffic light

The task is to compute the earliest possible arrival time at a destination node in a graph where each edge behaves like a traffic-controlled corridor.

codeforcescompetitive-programming
CF 105297G - Teleporting through Kazakhstan

We are given a sequence of points on a number line that must be visited in a fixed order. We start at position 0. At each step we move to the next required position in the list, but we are allowed to choose between two movement modes.

codeforcescompetitive-programming
CF 105297E - Energy crisis

We are given a connected undirected graph where nodes represent power plants and edges represent possible transmission routes. Each route has a cost that changes over time according to a quadratic function in time $t$, specifically $a t^2 + b t + c$.

codeforcescompetitive-programming
CF 105297B - Chopping Down Trees

We are choosing a set of $M$ distinct integer positions from the range $[1, N]$. Each chosen position contains a tree of fixed height $H$.

codeforcescompetitive-programming
CF 105297D - A is for Apple

We are given a rectangular 3D box aligned with the coordinate axes, stretching from the origin to $(x, y, z)$. Inside this box, there is already one spherical apple placed somewhere in space. Its center is given as $(tx, ty, tz)$, and it has radius $r$.

codeforcescompetitive-programming
CF 105297C - Road Cycling

We are given a circular route with $n$ cycling stations. Each station has two values: the amount of energy you gain when stopping there, and the amount of energy required to travel from it to the next station in the cycle. A cyclist starts at a chosen station with zero energy.

codeforcescompetitive-programming
CF 105293E - Mr.Wow and Hidden Permutation

We are given a hidden permutation $p$ of length $n$, where $n equiv 2 pmod 4$. We never see the permutation directly. Instead, we can query any set of exactly $n/2$ distinct indices, and the judge returns the median value among the corresponding $p$-values.

codeforcescompetitive-programming
CF 105293F - Mr.Wow and Decoding

We are given a circular array of constraints, and we want to construct another array of nonnegative integers that satisfies them while minimizing the total sum.

codeforcescompetitive-programming
CF 105293C - Mr. Wow and Spells

We are given a row of monsters, each with a positive health value. A spell is an operation where we choose a number x, then scan monsters from left to right. The first monster whose current health is at least x gets reduced by x, and the spell stops immediately.

codeforcescompetitive-programming
CF 105293B - Mr. Wow and Dislikes

We are given an array of integers. The goal is to repeatedly apply an operation so that, at the end, every element in the array is non-positive. One operation works like this. We pick an index $i$.

codeforcescompetitive-programming
CF 105293D - Mr.Wow and Multiset

We start with a multiset containing the numbers from 1 to n. Each operation picks two currently present values x and y, removes both, and inserts their difference x − y. After exactly n − 1 such operations, only one number remains.

codeforcescompetitive-programming
IMO 1966 Problem 2

The condition mixes side lengths and tangents of angles.

imomathematicsolympiad
CF 105284J - Grid Product

We are given a grid of upper bounds, and we consider all integer grids of the same size where each cell is chosen independently within its allowed range. For each such choice of grid values, we compute a score formed from row sums and column sums.

codeforcescompetitive-programming
CF 105284K - The Astral Express

We are given a one-dimensional universe made of segments arranged in a line. Each segment has a value, initially either +1 or -1 depending on whether it lies in the left half or the right half of the array.

codeforcescompetitive-programming
CF 105284I - Flappy Deer

We are simulating a character that moves strictly from left to right on an infinite grid. Time advances in discrete steps, and at every step the x-coordinate increases by one, while the y-coordinate can change by at most one unit up or down.

codeforcescompetitive-programming
IMO 1966 Problem 1

Let

imomathematicsolympiad
CF 105284G - Ifrit Tile

We are given a tree with $n$ nodes. Each of $m$ colors corresponds to a fixed simple path in this tree, defined by two endpoints $si$ and $ti$. Think of each color as a group of tokens that would occupy every node on that path when active.

codeforcescompetitive-programming
CF 105284F - Stage 4

We start with a single integer value and process a sequence of operations. Each element in the permutation gives us a binary choice: either we add that number to the current value, or we flip a single bit of the current value using XOR with a power of two determined by the…

codeforcescompetitive-programming
CF 105284E - Waymo orzorzorz

Jason starts from an empty text and wants to end up with a text consisting of the string "orz" repeated at least $N$ times.

codeforcescompetitive-programming
CF 105284D - Kawaii the Rinbot

We are given a fixed external database that can be thought of as a long ordered list of anime titles, each sitting on a specific line number starting from 1.

codeforcescompetitive-programming
CF 105284B - Monkey Arrays

We are given an array and three distinguished values, $X$, $Y$, and $K$, with the ordering $Y < K < X$. For each test case, we need to count subarrays where two extremal conditions hold simultaneously: within the subarray, the maximum value must be exactly $X$, the minimum…

codeforcescompetitive-programming
CF 105284C - Monkey Math Tree

We are given a path graph with nodes numbered from 1 to n, where each node is connected to its immediate neighbors. Then each node i is independently kept with probability 1/i and removed with probability 1 − 1/i.

codeforcescompetitive-programming
CF 105283K - Waymo orzorzorz

We are building a text consisting of repeated copies of the string “orz”. The goal is to produce at least $N$ copies of this string in minimum time. At any moment, Jason has a current amount of text, and he can perform three actions.

codeforcescompetitive-programming
CF 105283J - Kawaii the Rinbot

We are given a fixed external text file that lists anime titles, one per line. Each title is unique and appears exactly once in that file.

codeforcescompetitive-programming
CF 105283I - Monkey Math Tree

We are given a path graph with nodes numbered from 1 to n, where each node i is independently kept with probability 1/i and removed otherwise.

codeforcescompetitive-programming
CF 105283G - Monkey Arrays

We are given an array and three special values, with a strict ordering $Y < K < X$. For each test case, the task is to count how many contiguous subarrays satisfy three simultaneous conditions: the maximum element in the subarray is exactly $X$, the minimum element is exactly…

codeforcescompetitive-programming
CF 105283F - XOR Game

We are given a binary grid and we want to travel from the top-left cell to the bottom-right cell, only moving right or down. The restriction is that every visited cell must contain a 1.

codeforcescompetitive-programming
CF 105283E - Minimize Sum

We are given an array of integers. One operation is allowed: pick any two elements, remove both, compute their bitwise XOR, and insert that result back into the array. This changes the array size by exactly minus one, since two elements are replaced by one.

codeforcescompetitive-programming
CF 105283C - Phonier

We are given an array, and each query asks about all ordered pairs of indices inside a segment. For a query segment $[l, r]$, we take every pair $(i, j)$ in that range, compute $ai + aj$, and then XOR all of those results together.

codeforcescompetitive-programming
CF 105283D - Parallel Arrays

We are given the numbers from 1 to 2n, and we must split them into two ordered lists a and b, each of length n, using every number exactly once.

codeforcescompetitive-programming
CF 105283B - Ifrit Tile 2

We are given a rectangular grid where each cell is one of three types. Some cells are valid high ground positions where we can place a unit, some are low ground cells where enemies stand, and some cells are blocked and irrelevant for placement.

codeforcescompetitive-programming
IMO 1965 Problem 6

The problem asks for an upper bound on the number of segments of maximal length among $n$ points in the plane.

imomathematicsolympiad
CF 105278M - grinch

We are given a tree with up to one million nodes. A token starts on some node, and two players alternately move it.

codeforcescompetitive-programming
CF 105278L - Strobogrammatic

We are given a single number written in hexadecimal, using digits 0 to 9 and letters A, b, C, d, E, F. The task is to modify this string into a strobogrammatic number, meaning that if we rotate the representation by 180 degrees, it should look identical again.

codeforcescompetitive-programming
CF 105278K - Baby Chaves

We are given a line of integers. In one move we pick two neighboring positions and transfer any amount of value between them: we add some integer $k$ to one side and subtract the same $k$ from the other side.

codeforcescompetitive-programming
CF 105278J - Gerrymandering

We are given a circular arrangement of voters, each voting for either J or L. We must cut this circle into exactly K consecutive segments, where the last segment wraps around to the beginning.

codeforcescompetitive-programming
CF 105278I - d-parkour

We are given a sequence of buildings, each with a distinct height. For any interval of buildings from index i to j, we consider two traversals: moving from left to right and moving from right to left.

codeforcescompetitive-programming
CF 105278G - Chocolate Volcano

We are given a polygonal “cake” whose upper boundary is defined by a polyline through $n$ points whose x-coordinates are strictly increasing.

codeforcescompetitive-programming
CF 105278F - Pacman or Shot

The grid represents a maze where two agents move over discrete time steps: Pacman and a ghost. Pacman starts at a fixed cell and then follows a predetermined sequence of moves consisting of up, down, left, and right commands.

codeforcescompetitive-programming
CF 105278E - Chaves and habibi arrays

We are given a permutation of length $N$, meaning all values are distinct. From this array we consider every contiguous subarray, and we want to count how many of those subarrays are “valid” according to a stack simulation rule.

codeforcescompetitive-programming
CF 105278D - Wise Splitting

We are given a list of money transfers between people, where each record says that one person paid on behalf of another, creating an implicit debt relationship. From these transactions we can compute how much each person ultimately owes or is owed.

codeforcescompetitive-programming
CF 105278B - Missing LDAP

We are given a person’s full name split into three or four words. The last two words are fixed surnames, while everything before them forms the given names. From this name, we must reconstruct a very specific sequence of candidate login identifiers called LDAPs.

codeforcescompetitive-programming
CF 105278A - Pacman and Russian Roulette

We are simulating a short sequence of moves on a toroidal 15 by 15 grid, where Pacman follows a fixed deterministic path while a hidden ghost moves randomly. Both start from the same uniformly random cell.

codeforcescompetitive-programming
IMO 1965 Problem 5

The previous attempt failed because it incorrectly assumed a simple affine relation between $M$ and the orthocenter $H$ of $\triangle OPQ$.

imomathematicsolympiad
CF 105276K - Keep Them Stacked

We are given three rectangular sheets, each with a fixed width and height, and we are allowed to place them on a plane without rotating them. The task is to arrange all three so that the total area of the region they occupy is as small as possible.

codeforcescompetitive-programming
CF 105276L - Lift Problem

There are $N$ lifts and $N$ special floors called waiting floors. The $i$-th waiting floor is fixed at height $10i - 5$, so these floors are evenly spaced and strictly ordered. Each lift initially sits on its own waiting floor: lift $i$ starts at floor $10i - 5$.

codeforcescompetitive-programming
CF 105276I - Ideal Cutting

We are given a convex polygon described by its vertices in counterclockwise order. The task is to cut this polygon into triangles using non-intersecting diagonals between vertices, exactly forming a triangulation.

codeforcescompetitive-programming
CF 105276H - Handful of Balls

We are given a triangular board of side length $N$. The board is not a rectangle but a triangle where row $k$ contains $k$ cells, aligned to the left, forming the familiar triangular grid structure.

codeforcescompetitive-programming
CF 105276F - Far-reaching Citations

Each published paper is constructed incrementally. Some papers are independent strings, while others are formed by taking an earlier paper and appending an extra string to its end.

codeforcescompetitive-programming
CF 105276G - GPT Intrusion

We are given a program as plain text, split into several lines. The task is to determine whether this program is “suspected to be written by GPT and exceeds its output limit.

codeforcescompetitive-programming
CF 105276E - Enthusiast of Algorithms

We are given several categories of algorithms, where each category contains a certain number of distinct algorithms. Over the next $K$ days, Bob will study exactly one category per day, and on that day he must learn exactly $M$ algorithms from that chosen category.

codeforcescompetitive-programming
CF 105276C - Cross Across the Grid

The grid can be thought of as a set of concentric square rings around the center cell. Because the size is odd, there is a single center and every other cell belongs to exactly one ring.

codeforcescompetitive-programming
CF 105276D - Decisive Duels

We are given a binary string where each character represents the outcome of a point in a badminton match simulation. A substring corresponds to a single match, and we scan it from left to right, updating a running score: 1 adds a point to David, 0 adds a point to the opponent.

codeforcescompetitive-programming
CF 105276A - Always Right

We are working on a grid maze where each cell is either a wall or a free space, and exactly one cell is marked as a start and one as an exit. The movement rules are not the usual four-directional steps.

codeforcescompetitive-programming
CF 105272A - Arc surveillance

We are given positions of occupied cells arranged around a circular prison with labels from 1 to 360. Because the structure is circular, cell 360 is adjacent to cell 1, so any contiguous surveillance interval may wrap around this boundary.

codeforcescompetitive-programming
IMO 1965 Problem 4

Let

imomathematicsolympiad
CF 105272J - Jupiter's Dinner

We are given a sequence of requests arranged in a line, where each position corresponds to a person who ordered a specific type of dish.

codeforcescompetitive-programming
CF 105272H - Honor to Saturn

We are given a linear sequence of asteroids, each colored either a or b. We are allowed to choose any contiguous segment of this sequence, remove it, and then glue its ends together to form a cycle.

codeforcescompetitive-programming
CF 105272G - Genealogy of aliens

We are looking at a population that evolves in perfectly rigid generations. The first generation starts with some number of individuals, call it $a$.

codeforcescompetitive-programming
CF 105272E - Excavating Mercury

The horizon of Mercury is described as a line of mountains, each position having a given height. We are allowed to perform only one type of operation: reduce the height of any mountain by removing material.

codeforcescompetitive-programming
IMO 1965 Problem 3

The plane $\varepsilon$ is parallel to both skew edges $AB$ and $CD$.

imomathematicsolympiad
CF 105272C - Cosmic candidates

We are given a group of $n$ people, where $n$ is divisible by 3, and these people are already partitioned into teams of exactly 3 members each. Each team will only agree to participate in a competition if at least two of its three members are convinced to go.

codeforcescompetitive-programming
CF 105272D - Dividing the solar pizzas

We are given an even number of friends, say 2n, and each friend has a single integer value representing a pizza flavor preference. The group wants to order exactly n pizzas, and each pizza must be made from two different friends’ preferences.

codeforcescompetitive-programming
CF 105271C - Trains 2

We are given a tree with vertices labeled from 1 to n. Each vertex acts like a train station, and moving along any edge between two stations costs exactly one ticket. The twist is that tickets are not globally fixed in price.

codeforcescompetitive-programming
IMO 1965 Problem 2

The coefficient matrix has positive diagonal entries and negative off-diagonal entries.

imomathematicsolympiad
IMO 1965 Problem 1

The expression involves $\sin 2x$ inside two square roots of complementary forms, suggesting the standard algebraic identity

imomathematicsolympiad
IMO 1964 Problem 6

The configuration is affine, involving a tetrahedron and three lines through the vertices of one face parallel to a fixed direction $DD_0$, where $D_0$ lies in the plane $ABC$.

imomathematicsolympiad
IMO 1964 Problem 5

Five given points determine ten straight lines joining them.

imomathematicsolympiad
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