brain

tamnd's digital brain — notes, problems, research

43815 notes

CF 105485H - 文神的比赛

We are given a group of contestants in a programming contest. Each contestant has solved a set of problems, and this set is encoded as a string of distinct uppercase letters from A to Z. The length of the string is the number of solved problems.

codeforcescompetitive-programming
CF 105485C - 文神的序列

We are given a sequence of positive integers. In one operation, we pick two different positions i and j, and replace the value at i with the bitwise AND of the two values, ai becomes ai & aj.

codeforcescompetitive-programming
CF 105485D - 低谷(easy)

We are given a sequence of integers representing heights. In one move, we choose any position and decrease that single value by one. We may repeat this operation up to k times.

codeforcescompetitive-programming
CF 105485A - 数组

The task describes an array purely as a way to motivate indexing from zero. If an array has length $n$, its valid indices run from $0$ up to $n - 1$. The problem then asks us to output the index of the last element of such an array when only the length $n$ is given.

codeforcescompetitive-programming
CF 105481M - 盲盒谜题

We are simulating a fairly involved single-player process on a fixed 3×3 grid where items are placed one by one from a given sequence. Each grid cell either holds a “turtle” of some color or is empty.

codeforcescompetitive-programming
CF 105481L - 龙之研习

We are looking at a modified calendar where each year is classified as either a training year or a rest year. Starting from the year 2024, the character gains exactly one unit of progress in every training year, while rest years contribute nothing.

codeforcescompetitive-programming
CF 105481J - 结课风云

Each student has two components in their grade: a fixed exam score and a controllable continuous assessment score. For student $i$, the current total is $xi + yi$, where $xi$ is the coursework score capped at $a$, and $yi$ is the exam score capped at $b$.

codeforcescompetitive-programming
CF 105481H - 划分数字

We are given a large integer $x$ (up to $10^{18}$). For each such number, we may split its decimal representation into two non-empty parts by choosing a cut position in its digit string.

codeforcescompetitive-programming
CF 105481G - 顾影自怜

We are given one or more arrays. For each array, we look at every contiguous subarray and assign it a value based on a simple rule: take the maximum element inside the subarray, count how many times this maximum appears, and if that count is at least k, the subarray…

codeforcescompetitive-programming
CF 105481D - 都市叠高

We are given a set of $n$ distinct points in the plane, revealed one by one in order. At the moment a point appears, it becomes “active”.

codeforcescompetitive-programming
CF 105481A - 爱上字典

We are given a long piece of text that represents a story. The text contains words mixed with spaces and punctuation marks such as commas, periods, exclamation marks, and question marks.

codeforcescompetitive-programming
IMO 1970 Problem 5

The configuration places strong orthogonality constraints: the projection of $D$ onto the plane $ABC$ is the orthocenter of $\triangle ABC$, and at the same time $\angle BDC$ is a right angle.

imomathematicsolympiad
CF 105477A - Coins

We are given several independent scenarios. In each scenario, Baq owns a collection of coins, each coin having a positive integer value. Using any number of these coins, he can form sums by choosing a subset and adding their values.

codeforcescompetitive-programming
CF 105476D - Witch Hunt

We are given a set of people connected by two kinds of relationships. Each person must be assigned one of two roles, which we can think of as either being a witch or not being a witch. The relationships impose constraints on these assignments.

codeforcescompetitive-programming
CF 105476C - Of Streetlights and Thieves

We are given several independent scenarios along a street. In each scenario, there are fixed positions where people stand, and a set of streetlights, each placed at some coordinate and each able to illuminate a symmetric interval around itself determined by its radius.

codeforcescompetitive-programming
CF 105475D - Rooms

We can model the situation as a directed graph on $N$ nodes, one node per person. Each person $i$ keeps one key for their own room and deposits a second key into the room of person $ci$.

codeforcescompetitive-programming
CF 105475E - Coloring Trees

We are given a tree where each vertex is colored either 0 or 1. In one move, we are allowed to choose a set of vertices that forms a connected subgraph in the tree and such that all chosen vertices currently share the same color.

codeforcescompetitive-programming
CF 105475B - Chickens

We are given a set of points on a number line, each point initially holding one chicken. Two chickens are considered connected if we can move from one position to the other using a sequence of jumps, where each jump must be strictly shorter than a chosen value $k$.

codeforcescompetitive-programming
CF 105472J - Jealous Youngsters

Something went wrong while generating the response. If this issue persists please contact us through our help center at [help.openai.com](https://help.openai.com/).

codeforcescompetitive-programming
IMO 1970 Problem 4

The flawed solution failed because it tried to force a “singleton prime contribution” without proving it, and it confused “a prime factor appears once” with “its valuation contributes an unavoidable o…

imomathematicsolympiad
CF 105472H - Hot Hike

We are given a sequence of daily temperatures covering a vacation of length $n$. We must choose a continuous block of exactly three consecutive days: the first day is hiking up to a lake, the second day is rest (ignored for heat considerations), and the third day is hiking back.

codeforcescompetitive-programming
CF 105472D - Dungeon Dawdler

We are inside an unknown rectangular dungeon made of grid cells. Each cell is either a wall or a walkable space, and the walkable space has a special twist: there can be up to two trapdoors that behave like hidden teleporters.

codeforcescompetitive-programming
CF 105472A - Alphabet Animals

We are given the last animal name spoken by the previous player and a pool of unused animal names. A valid move for us must satisfy a chaining rule: the new name must begin with the last character of the previous name, and it must not have been used before.

codeforcescompetitive-programming
CF 105472G - Game of Gnomes

We are given a set of identical units called gnomes, and we must split them into at most a fixed number of groups before the process starts.

codeforcescompetitive-programming
CF 105471G - An Easy Math Problem

We are given a positive integer $n$. We look at all ways to pick two positive integers $p$ and $q$ such that their product divides $n$, and additionally $p le q$. For each valid pair, we compute a value $r = frac{p}{q}$.

codeforcescompetitive-programming
CF 105471C - Counting Strings

We are given a string indexed from 1 to n. We look at pairs of indices $(l, r)$ with $l le r$. Each such pair defines a substring $s[l..r]$, but we only accept it if the endpoints are coprime, meaning $gcd(l, r) = 1$.

codeforcescompetitive-programming
CF 105465M - Max Minus Min

We start with an array of integers. In one move, we are allowed to pick a contiguous segment and add the same value to every element in that segment. We may also choose not to perform any move at all.

codeforcescompetitive-programming
CF 105465K - $K$ Subsequences

We are given an array consisting only of 1 and -1. We must split the indices of this array into k groups. Each group is treated as a subsequence in the original order, meaning we keep relative order but do not require contiguity.

codeforcescompetitive-programming
CF 105465J - Jackpot

We are given an array of length 2n. We repeatedly pick two adjacent elements in the current array, remove them, and gain a score equal to the absolute difference of those two values. After doing this exactly n times, the array becomes empty.

codeforcescompetitive-programming
CF 105465G - Graph Race

We are working with a connected, unweighted, undirected graph. Every vertex has two values attached to it, $au$ and $bu$. The task only cares about vertices that are directly connected to vertex $1$.

codeforcescompetitive-programming
CF 105465I - Impossible Numbers

We are given a collection of $n$ cubes, each cube having six visible digits. Each cube can be oriented so that any one of its six faces becomes the top face, which means that for every cube we can choose any one of its six digits as the digit it contributes.

codeforcescompetitive-programming
CF 105465F - Fast XORting

We are given a permutation of all integers from 0 to n − 1, where n is a power of two. The goal is to transform this permutation into sorted order using two types of operations.

codeforcescompetitive-programming
CF 105465D - Distinct Game

We are given two sequences, each acting like a stack where only the last element is accessible. Every value from 1 to k appears exactly twice across both sequences, so each number forms exactly one pair of occurrences scattered between the two stacks. Two players alternate moves.

codeforcescompetitive-programming
CF 105465B - Build Permutation

We are given an array of integers and asked to construct a permutation π of indices from 1 to n such that pairing each position i with π[i] makes all sums ai + aπ[i] identical across every index i.

codeforcescompetitive-programming
CF 105465C - Christmas Sky

We are given two finite point sets in the plane. One set represents the stars in a new photograph, the other represents stars in an old photograph. We are allowed to translate the new photo by a vector $(tx, ty)$, without rotating or scaling it.

codeforcescompetitive-programming
CF 105461K - Cheater Detector

We are given a set of students where some pairs are known to have exchanged homework. Each report is an undirected edge between two students, meaning those two are connected in a “cheating interaction” graph.

codeforcescompetitive-programming
CF 105461H - Zürich Trams

The network of Zurich stations forms a tree, so between any two stations there is exactly one simple path. On top of this static structure, there are several trams.

codeforcescompetitive-programming
CF 105461J - Gibberish

We are dealing with a hidden permutation of positions from 1 to n. Whenever we send a word of length n, the system rearranges the letters according to this fixed permutation and returns the result.

codeforcescompetitive-programming
CF 105461G - Contrived Intelligence

We are dealing with a hidden integer-coefficient polynomial $P(x)$, but we never evaluate it directly. Instead, we interactively query an index $k$, and the judge tells us how many values among $P(1), P(2), dots, P(k)$ are divisible by $k$.

codeforcescompetitive-programming
CF 105461E - Lighting the Street

We are given a straight street represented as a continuous segment from 0 to L. There are n fixed lamp posts placed at integer coordinates along this segment. We are not allowed to choose their positions, only the type of bulb installed in each lamp post.

codeforcescompetitive-programming
CF 105461B - Digital Products

We are given a number $n$, and we consider every integer $x$ from 1 up to $n$. For each number $x$, we compute a value formed by multiplying all its decimal digits. If a number contains a zero digit, its digit product becomes zero.

codeforcescompetitive-programming
CF 105461D - LSB

We are given a system that allows us to construct new bitsets from an initial bitset $B0$. Each bitset has length $n$, and we can generate new ones using only a small set of operations: shifting left or right, XOR, and OR between previously constructed bitsets.

codeforcescompetitive-programming
CF 105459L - A Game On Tree

We are given a tree with $n$ nodes. A “move” in this problem is not about edges or nodes directly, but about choosing a simple path between any two nodes in the tree.

codeforcescompetitive-programming
CF 105459K - Farm Management

We are deciding how to distribute a fixed working day of length $m$ across $n$ crop types. Each crop $i$ gives a linear profit: every unit of time spent on it contributes $wi$ profit.

codeforcescompetitive-programming
CF 105459J - New Energy Vehicle

We are given a vehicle that can consume energy from multiple batteries while moving forward on a number line. Each battery starts fully charged and contributes a fixed amount of usable distance, one unit of charge equals one kilometer.

codeforcescompetitive-programming
CF 105459H - Subsequence Counting

We are given a long sequence that is not stored explicitly as an array, but described as runs of equal values. Each run contributes a block of identical elements, so the original sequence can be seen as a compressed array of length $L$, where $L$ can be extremely large.

codeforcescompetitive-programming
IMO 1970 Problem 3

The expression for $b_n$ involves weighted increments of the nondecreasing sequence $(a_k)$, with each term having the structure

imomathematicsolympiad
CF 105459G - Welcome to Join the Online Meeting!

We are given an undirected graph where vertices represent participants and edges represent mutual acquaintance. The goal is to “activate” all participants in an online meeting that starts with exactly one creator and then grows by invitations along acquaintance edges.

codeforcescompetitive-programming
CF 105459F - 1D Galaxy

We are given a set of particles on a line. Each particle starts at a coordinate and has a fixed weight, which can be positive or negative.

codeforcescompetitive-programming
CF 105459D - A Simple String Problem

We are working with a very thin grid, only two rows and many columns. From any cell, movement is constrained: you can always move to the cell immediately to the right in the same row, and from a cell in the top row you may also drop vertically into the cell directly below it…

codeforcescompetitive-programming
CF 105459B - Concave Hull

We are given a set of points in the plane, with the promise that no three lie on a straight line. From these points we may choose any subset and arrange the chosen points in some cyclic order to form a simple polygon.

codeforcescompetitive-programming
CF 105459C - Giving Directions in Harbin

We are given a sequence of movement instructions on an infinite grid. Each instruction tells us to move in one of the four absolute directions, north, south, west, or east, and to go a certain number of intersections in that direction.

codeforcescompetitive-programming
CF 105458D - Professor Oak Strikes Back

We are given several independent typing sessions. In each session, Professor Oak produces a long text using a very specific two-finger typing model on a fixed keyboard.

codeforcescompetitive-programming
CF 105458B - The Fortune of Francis

We are given a collection of license plates belonging to cars purchased over time by a single owner. Each plate is a fixed-format string: four digits followed by three uppercase letters.

codeforcescompetitive-programming
CF 105458A - Juan's Flight

Each test case describes Juan’s attempt to choose a single store from which he will buy three required components for a flying car: an engine, a steering wheel, and a spare tire. Every store offers all three items, but each store has different prices for them.

codeforcescompetitive-programming
CF 105457D - Pickle Rick

We are working on an infinite grid where each cell is a unit square. A 1×1×2 cuboid starts in a fixed initial configuration at the origin, and it moves by rolling over one of its edges, like a domino flipping from one face to another. Each such roll counts as one move.

codeforcescompetitive-programming
CF 105457B - Islands and Mountains

We are given a line of land split into $n$ consecutive segments, each with a fixed height. Over time, the sea level rises in steps, and after each rise we must determine how many connected groups of dry land remain.

codeforcescompetitive-programming
CF 105457C - Schedules

We are given a list of class schedules, each represented by a start time and an end time on a single circular day that has m discrete hours.

codeforcescompetitive-programming
CF 105456D - Multidimensional Excursions

We are working in a k-dimensional integer lattice. A state is a point with k integer coordinates, and each move changes exactly one coordinate by either +1 or −1. After 2n moves, we want to count how many different sequences of moves bring us back to the origin.

codeforcescompetitive-programming
CF 105456A - Palindrome ABC

We are given counts of three characters, namely how many times we must use the letters A, B, and C. For each test case, the task is to construct a string using exactly those characters such that the string reads the same forwards and backwards, and among all valid such strings…

codeforcescompetitive-programming
IMO 1970 Problem 2

Let the common digit string be interpreted in two positional systems with bases $a$ and $b$.

imomathematicsolympiad
CF 105455D - La Pachanga

We are given a set of players and a list of pairwise “hate relations”, each with a numerical strength. We need to split all players into two teams. A pair of players placed in the same team is only acceptable if their mutual hate is not “too large”.

codeforcescompetitive-programming
CF 105455C - Spam Mail

We are given a number of points on a line representing mailboxes that must all be “visited” and cleaned, and another set of points representing people who can move along the same line. Each person starts at a fixed coordinate and can move one unit per second left or right.

codeforcescompetitive-programming
CF 105454L - Конфет много не бывает

Two players alternate taking turns from a pile of $N$ candies. The first player starts, and on each move a player removes some number of candies, but only amounts that are powers of two, meaning the move set is $1, 2, 4, 8, 16, dots$.

codeforcescompetitive-programming
CF 105454J - Диета для учёных

We are given a set of dishes, each with four nutritional values: proteins, fats, carbohydrates, and calories. Separately, we are given acceptable ranges for each of these four quantities.

codeforcescompetitive-programming
CF 105454I - Грибы против зомби

We are given a sorted set of objects on a number line: some positions contain zombies moving left, and some contain mushrooms that can reverse a zombie’s direction. A zombie starts in a normal state moving toward decreasing coordinates at speed 1.

codeforcescompetitive-programming
CF 105454F - Новое слово

We are given an alphabet that is cyclic, numbered from 1 to $C$. A word is just a sequence of these numbers, and we are interested in finding occurrences of a pattern word $W$ inside multiple texts.

codeforcescompetitive-programming
CF 105454D - Музыкальные стулья

The game can be viewed as a directed graph on $n$ vertices, where each vertex $i$ has exactly one outgoing edge to $ai$. Every participant initially sits on a distinct vertex (chair), and during a round they all try to move along the outgoing edge of their current vertex.

codeforcescompetitive-programming
CF 105454B - Красивый угол

We are working in a plane with a vertex that defines an angle and two rays forming its sides. One ray is determined by the vertex and a second point, and the other ray is determined similarly.

codeforcescompetitive-programming
CF 105454E - Команды на ПРОШП

We are given a group of $n$ people and want to form teams of exactly three distinct members. However, not every triple is allowed because there are $m$ forbidden pairs of people who cannot appear together in the same team.

codeforcescompetitive-programming
CF 105453H - The magical forest of Seih Sou

We are given a forest represented as an undirected graph with up to one million nodes and edges. Some nodes are initially marked as special, and these special nodes define what it means for a node to be “magical”.

codeforcescompetitive-programming
CF 105453G - Airport Departures' Optimization

We are given a sequence of flights sorted by their scheduled departure times. Each flight has a time when it ideally wants to use the runway, a payment it offers if it is allowed to depart exactly at that time, and a penalty it imposes if it is not.

codeforcescompetitive-programming
IMO 1970 Problem 1

The earlier algebraic model failed because it used incorrect expressions for $\frac{r_1}{q_1}$ and $\frac{r_2}{q_2}$ and then attempted to repair the resulting identity through polynomial manipulation…

imomathematicsolympiad
CF 105453E - Generation and transmission network

We are given a fully specified network of islands where every island can either be powered by building a generator on it or by being connected through transmission lines to some other island that eventually has a generator.

codeforcescompetitive-programming
CF 105453D - Deciphering Ancient Symbols

The task is to analyze a string written on an ancient tablet and determine how much of it can be interpreted using a set of known “meaningful fragments”. Each fragment is a short string that is already understood.

codeforcescompetitive-programming
CF 105453A - The Binary Chicken Farm

We are given a directed influence network over N chickens. Each chicken maintains a binary string state of fixed length L, and this state evolves day by day. On day 1, every chicken has an initial binary string.

codeforcescompetitive-programming
CF 105453C - Fair Split of the Golden Tablet

The problem describes a geometric situation involving a circular region and a cut that divides it into two parts. One part is a “green” segment-like region whose area depends on a height parameter $h$, the radius $R$, and the geometry of a circular segment.

codeforcescompetitive-programming
CF 105450I - Can I Find My Candy?

We are given an array of integers of length $n$. Each position stores a number that represents how many candies are in that bag.

codeforcescompetitive-programming
CF 105450G - Treat or Trick

We can view the street as two parallel rows of houses, each row having $n$ positions. From any house at position $i$, Julia can move left or right along the same row, or switch vertically to the other row at the same position.

codeforcescompetitive-programming
CF 105450H - Warhead Games

We are given a rectangular grid where each cell is either usable or blocked. A token starts at the top-left cell and two players alternate moves.

codeforcescompetitive-programming
CF 105450E - Give Me Your Candy

We are given a line of candies, each with a numerical value representing how enjoyable it is to eat that candy. These values can be positive or negative, so taking a candy can either help or hurt the total enjoyment.

codeforcescompetitive-programming
CF 105450D - Trick or Treat

We are given a set of points on a 2D grid, and we start from the origin at coordinate (0, 0). We want to choose a direction and walk in a straight line passing through the origin. While moving along that line, we collect all candies that lie exactly on it.

codeforcescompetitive-programming
CF 105450C - Sour Straws

We are given a collection of integer lengths, each representing a sour straw. From these, we want to choose a subset such that when we sort the chosen lengths in nondecreasing order, every smaller element divides every larger element that comes after it.

codeforcescompetitive-programming
CF 105418C - Reduce or Divide

We start with a number $n$ that is encoded in binary, but the string is given in reverse order, so the least significant bit comes first. The first task is simply to interpret this string correctly as an integer. Two players, Bob and Alice, alternate moves starting from Bob.

codeforcescompetitive-programming
CF 105417J - Egg Placement

We are given several points on a grid, each representing an egg. The “compactness” of the farm at any moment is the sum of Manhattan distances over all unordered pairs of eggs.

codeforcescompetitive-programming
CF 105417G - The Chicken and the Egg

We are given a directed graph where movement along each edge takes different time depending on whether we are simulating a chicken or an egg. There are several designated entrance nodes where the experiment can start, and several exit nodes which represent success states.

codeforcescompetitive-programming
CF 105417F - Incubation Line

We are given positions of eggs placed on a number line, each at a distinct integer coordinate. We are allowed to install at most k heat lamps, and each lamp can also be placed at an integer coordinate on the same line.

codeforcescompetitive-programming
CF 105417D - Scrambled!

We are given a multiset of lowercase letters. These letters were originally arranged into a string with two properties. First, the string was a palindrome, so its left half determines its right half by symmetry.

codeforcescompetitive-programming
CF 105416G - The Chicken and the Egg

We are given a directed graph where moving along each edge has two different costs depending on the traveler: one cost for a “chicken” and another for an “egg”.

codeforcescompetitive-programming
CF 105416E - Yodel Yolk

We are given a one-dimensional landscape where each position has an integer height. Think of it as a sequence of vertical columns of different heights placed side by side.

codeforcescompetitive-programming
CF 105416C - Egg Order

We are asked to arrange the numbers from 1 to n in some order, forming a permutation. Inside this permutation, we look at contiguous segments, and we care about segments where values increase by exactly 1 at every step.

codeforcescompetitive-programming
CF 105416D - Scrambled!

We are given a multiset of lowercase letters. These letters originally came from a string that had a very strong structure: it was a palindrome, and among all possible palindromes that could be formed using exactly these same letters, it was the lexicographically smallest one.

codeforcescompetitive-programming
CF 105408E - Expected Closest Friend

We are given a weighted, undirected, connected graph of cities. Jorge lives at city 0. Each edge represents a road with a positive length, and shortest paths define the distance between any two cities. Jorge has k friends, and each friend independently occupies a distinct city.

codeforcescompetitive-programming
CF 105404D - Coins 3

We are given a multiset of coin values and a target amount $k$. Pedro processes the coins in a very specific way: he sorts them in descending order and scans from largest to smallest. While scanning, he maintains a remaining amount he still needs to pay.

codeforcescompetitive-programming
IMO 1969 Problem 6

The expression involves two triples $(x_i,y_i,z_i)$ constrained by $x_i>0$ and $x_i y_i-z_i^2>0$.

imomathematicsolympiad
CF 105404E - Separated Cells

We are given a tree, meaning a set of nodes connected with exactly one simple path between any two nodes. Each node represents a prison cell that can hold at most one inmate.

codeforcescompetitive-programming
CF 105404A - No More Ties!

We are given several independent scenarios. In each scenario, a contest has a list of participant scores and only the top k participants are supposed to qualify.

codeforcescompetitive-programming
CF 105403A - Pieces

We are given a very short board with only up to three rows and an extremely long number of columns. The task is to cover every cell of this board using rectangular tiles of three possible sizes: single cells, dominoes covering two adjacent cells, and triominoes covering three…

codeforcescompetitive-programming
CF 105403E - Directing the Roads of Grafolandia

We start with a connected undirected graph representing cities and bidirectional roads. The government wants to choose exactly k of these roads and assign a direction to each selected road so that, after this operation, every city can still reach every other city using only…

codeforcescompetitive-programming
CF 105403D - The Route of the 12 Lakes

We are given a circular structure of lakes, where consecutive lakes are connected by weighted roads. If we walk from lake i to i+1 (and from n back to 1), we pay the corresponding edge cost.

codeforcescompetitive-programming