brain

tamnd's digital brain — notes, problems, research

41641 notes

CF 105895C - Kings Game (Easy Version)

We are given an array of positive integers, and many queries. Each query selects a contiguous segment of this array. For that segment, the two players effectively play a game on a chosen subsequence of its elements.

codeforcescompetitive-programming
CF 105891K - Welfare

There are two types of cows and two ways they can choose to receive grass. Each cow can choose option A or option B. If k cows choose A, then every A-cow receives x/k units of grass. If a cow chooses B, it simply receives y units.

codeforcescompetitive-programming
CF 105891G - student

We are given a row of students, each with a fixed score. A teacher repeatedly selects a student and checks whether that student can be removed from the row.

codeforcescompetitive-programming
CF 105891F - LOCK S

We are given a rooted tree with $n$ nodes, each node carrying a positive weight $vi$. Two players, Dawn and Tsuki, alternately “claim” nodes until one of them cannot make a legal move, at which moment the game immediately ends and both are considered to meet.

codeforcescompetitive-programming
CF 105891D - Stock

We start with an initial value $v$, and we are given $n$ operations. Each operation is either an addition by some real number $xi$, or a multiplication by some factor $xi$. We are allowed to reorder these operations arbitrarily.

codeforcescompetitive-programming
CF 105891A - Color

We are given a strip divided into n consecutive segments. Each segment already has an initial color, but that starting configuration does not really matter for the final goal except as a source of structure.

codeforcescompetitive-programming
CF 105887K - 消消乐

We start with an $n times n$ grid where every cell initially contains the value 1. Two arrays $a1 dots an$ and $b1 dots bn$ control a random process that repeatedly deletes either a row or a column until all rows and columns are gone.

codeforcescompetitive-programming
CF 105887J - RGB 树

We are given a tree where every node initially carries one of three colors: red, green, or blue. We are allowed to recolor any subset of nodes into white, and white nodes are treated as “removed” in the sense that they no longer participate as red, green, or blue.

codeforcescompetitive-programming
CF 105887H - 连接

We are given two rows of balls placed along the boundary of a rectangle. The bottom row contains a fixed permutation of numbers from 1 to n.

codeforcescompetitive-programming
CF 105887F - 赢麻了

Each test describes a simple comparison game between three values: Alice’s strength a, Bob’s strength b, and Candy’s strength c. The output is a string chosen by applying a priority rule over these comparisons. The decision process is sequential.

codeforcescompetitive-programming
CF 105887C - 区域划分

We are given an $n times n$ grid of unit cells. The task is to assign each cell one label from $1$ to $n$, forming exactly $n$ regions, where a region is simply the set of cells with the same label. Regions do not need to be connected.

codeforcescompetitive-programming
CF 105887A - 题目背景是 GPT 给的

We are given a circular array of length $n$, where each position holds an integer value representing some bitmask. The array evolves in discrete rounds.

codeforcescompetitive-programming
CF 105828L - Синий Трактор Airlines

There are $n$ animals placed on distinct positions on an infinite number line. Each animal also has exactly one associated “fan” (we will call them collectors) placed on another set of distinct positions.

codeforcescompetitive-programming
CF 105828J - Выгляни в окно

We are given several independent rectangles that represent possible shapes of a board. For each board, we need to count how many ways we can place an axis-aligned rectangular “window” inside it such that the window has a fixed area s, and it does not touch any border of…

codeforcescompetitive-programming
CF 105828E - Простой карандаш

We are asked to count how many positive integers strictly smaller than a given number n could have appeared on a special pencil during sharpening. The key constraint is that all valid numbers must be prime and must not contain the digit zero.

codeforcescompetitive-programming
CF 105828C - Цветы-мутанты

We are given a rectangular garden with $n$ rows and $m$ columns. Each cell contains an integer describing the type of flower growing there. We observe the garden twice: once before a transformation process and once after it.

codeforcescompetitive-programming
CF 105822D - Beaverland

We are given an undirected graph with a distinguished starting vertex, which we can think of as vertex 1. Alongside the graph, we are also given a sequence of vertices starting from this root, written as x0 = 1, followed by x1, x2, up to xk.

codeforcescompetitive-programming
CF 105822C - Feeding Beavers

We are given a binary string of length $N$, where each character describes how the $i$-th item must be paired with values drawn from a fixed set of numbered elements.

codeforcescompetitive-programming
CF 105791A - Autocomplete

We are given a fixed dictionary of words and then a sequence of query strings. For each query, we want to know how many words in the dictionary start with that query as a prefix.

codeforcescompetitive-programming
CF 105791K - Known Issue

The wall is given as an n by m grid of cells. Each cell is either empty or blocked by a nail. A poster can only be hung on a rectangular region of the wall, and every cell inside that rectangle must be free of nails.

codeforcescompetitive-programming
CF 105791I - Intense Duel

Two players alternate climbing a coconut tree. On the first climb Samuell takes a fixed amount $x$, and on the second climb Lleumas takes $y$.

codeforcescompetitive-programming
CF 105791G - Grisi Maps

We are given an undirected weighted graph that models a region. Two special vertices are distinguished: one is the main entrance of a university, and the other is the destination called IC. For every query vertex $x$, we compare two ways of reaching IC.

codeforcescompetitive-programming
CF 105791D - Darts

Each test describes a simple structured battle: there are n waves of enemies, and the i-th wave contains exactly i balloons. Every balloon in a wave has the same power level k, and the cost of destroying a single balloon is i raised to the power k.

codeforcescompetitive-programming
CF 105790C - Song

The task “Song” is essentially about reconstructing or evaluating a sequence derived from a structured description of a song.

codeforcescompetitive-programming
CF 105789B - Brazilian FootXOR

We are given a collection of vectors, each consisting of bits, and we are allowed to choose some of them to form a subset.

codeforcescompetitive-programming
CF 105789L - LED Counter

Each test case describes the state of a single 7-segment LED digit display, but the display is imperfect and ambiguous.

codeforcescompetitive-programming
CF 105789K - Keep Fighting

We are simulating a repeating deck of cards used by Bob in a fight against a monster with health $h$. Each card either increases Bob’s power additively, multiplies it, or deals damage directly. Once the deck is exhausted, it resets and can be reused in the same order again.

codeforcescompetitive-programming
CF 105789J - Just Look Up

We are given a set of points on the surface of a unit sphere in 3D space. Each point is a direction from the origin, so geometrically it can be treated as a unit vector.

codeforcescompetitive-programming
CF 105789I - Infinite Arrays

We are given a dynamic permutation $P$ of size $K$ and another array $A$. The permutation defines an infinite periodic sequence $P^infty$, formed by repeating $P$ endlessly.

codeforcescompetitive-programming
CF 105789H - Horrible Restaurants

We are given a collection of restaurants, and for each restaurant we can assign it a number of stars from 0 up to 3. Assigning stars has a cost that depends on the restaurant and the chosen number of stars.

codeforcescompetitive-programming
CF 105789G - Game of Pieces

We are given a one-dimensional board where each column has a current height. A sequence of operations places pieces that affect contiguous segments of columns.

codeforcescompetitive-programming
CF 105789F - Festival Signs

We are maintaining a long sequence of positions that initially have no restrictions. Over time, the festival organizers place “signs” that enforce height constraints on contiguous ranges.

codeforcescompetitive-programming
CF 105789E - Exciting Business Opportunities

We are given a tree of stations and a long sequence of operations applied over time. Each operation is either opening a business at a node of the tree or marking a node as sponsored. The key difficulty is that we do not evaluate these operations globally.

codeforcescompetitive-programming
CF 105789D - Dangerous City

We are given a city modeled as an undirected weighted graph where intersections are nodes and roads are edges. Each intersection has a danger value, and each road connects two intersections.

codeforcescompetitive-programming
CF 105789C - Coatless in Yakutsk

We are given a sequence of daily temperatures and a coat that can be used only in limited stretches. Once you wear it for a number of consecutive days, it becomes dirty and cannot be used again until it is washed.

codeforcescompetitive-programming
CF 105789A - Ananna

We are working with a directed graph whose edges are labeled with characters. The task is not to answer reachability in the usual sense, but to discover all pairs of vertices that can be connected by a walk whose sequence of edge labels forms a palindrome.

codeforcescompetitive-programming
CF 105791M - Mayor

We are given a small graph with up to 10 vertices, where every ordered pair of vertices has an associated cost for building a directed edge from one to the other.

codeforcescompetitive-programming
CF 105791L - Legendary Paper Cup

We are asked to count how many numbers inside a given interval can be expressed in a very specific form: the product of three consecutive integers. Every such number comes from choosing an integer $x$ and forming $x cdot (x+1) cdot (x+2)$.

codeforcescompetitive-programming
CF 105791J - Judge Fail

Each submission in the contest belongs to exactly one contestant, and each contestant has a personal restriction on which verdicts they can possibly receive. For every submission, the system does not produce a deterministic result.

codeforcescompetitive-programming
CF 105791H - Homo Programmius

We are given a binary string representing a DNA sequence, where each position is either normal or mutated. A value of 1 indicates a mutation, while 0 indicates a normal gene.

codeforcescompetitive-programming
CF 105791F - Four is too much

We are given a group of X marathonists who need transportation to a destination. There are N available ride options, and each ride option behaves like a single vehicle that can be used at most once.

codeforcescompetitive-programming
CF 105791E - Elevator

We are looking at a building with floors numbered from 1 up to n + 1. Pep lives on the top floor, and he wants to go down using an elevator.

codeforcescompetitive-programming
CF 105791C - Coconuts

We are given a line of kiosks along a beach avenue, each kiosk offering exactly one drink. A traveler starts at satisfaction value 1 and chooses a single contiguous segment of kiosks to walk through.

codeforcescompetitive-programming
CF 105791B - Beautiful Handsome's Canteen

We are given a polyline in the plane defined by n points sorted by increasing x-coordinate. The path starts at the first point and proceeds in straight line segments between consecutive points, so the walker moves along a piecewise linear curve.

codeforcescompetitive-programming
CF 105804E - Tokens

We are playing a deterministic game on the vertices of a regular n-gon, which is best thought of as positions on a cycle labeled from 0 to n − 1. Your opponent secretly maintains a token on one vertex. You do not know its position, but you interactively influence how it moves.

codeforcescompetitive-programming
CF 105822B - Kites

The problem describes a two-player game played on a binary string. The players alternately transform the string under a fixed rule, and the structure of the string determines whether a player can force a win or avoid losing indefinitely.

codeforcescompetitive-programming
CF 105828K - Капибары на дачном участке

We are given two sets of points on an infinite grid. The first set represents positions where cameras can be installed, and the second set represents positions of capybaras that must be observed.

codeforcescompetitive-programming
CF 105828I - Учебные группы

We are given a set of $2n$ students and a list of pairs who cannot be placed in the same study group. The task is to split all students into two groups, each containing exactly $n$ people, so that no forbidden pair ends up inside a single group.

codeforcescompetitive-programming
CF 105828H - Все на весенний бал!

We are given a set of distinct points on a 2D plane, each representing a nail on a wall. Any pair of nails can be connected with a straight string, forming a line segment.

codeforcescompetitive-programming
CF 105828F - История о юноше, изучавшем математику, когда попал в другой мир

We are given several independent test cases. In each test case there is a set of cards, where each card has two digits written on it. One digit is visible when the card is placed normally, and the other digit appears after the card is flipped over.

codeforcescompetitive-programming
CF 105828D - Опять секретики

We are given a collection of binary strings, all of the same length. Each string is a word in a language, and we are allowed to shorten a word only by deleting characters from its right end.

codeforcescompetitive-programming
CF 105828B - Строки и столбцы

We are given an $n times n$ grid where every cell contains an integer from $1$ to $k-1$. Two different people extract a score from this same grid using two different aggregation rules.

codeforcescompetitive-programming
CF 105828A - Бесконечная игра

We are given a row of cells, each containing a lowercase letter. A token starts at the first cell and repeatedly moves according to a deterministic rule.

codeforcescompetitive-programming
Kvant Math Problem 337

Let

kvantmathematicsolympiad
CF 105887B - 列车

We are given a railway line with stations numbered from 1 to n. There are m trains. Each train starts at a fixed station li, ends at ri, and has a capacity ci.

codeforcescompetitive-programming
CF 105891M - Nightmare

We are given a line of $n$ positions. Each position has a fixed weight and an initial color, either black or white. The line is naturally divided into maximal consecutive segments of identical color, which we will call blocks. Time evolves in discrete steps.

codeforcescompetitive-programming
CF 105891H - candy

We are given a binary string describing a day-by-day plan over $n$ days. On day $i$, the plan prescribes either eating a candy or avoiding it. If the character is 1, the mood increases by $+1$. If it is 0, the mood decreases by $-1$.

codeforcescompetitive-programming
CF 105891B - Light

We are given a system of $n$ lamps, each currently either on or off, and $m$ switches. Each switch is wired to a subset of lamps. Pressing a switch flips the state of every lamp connected to it.

codeforcescompetitive-programming
CF 105895K - LRU is Best? (Easy Version)

We are given a fixed sequence of requests, and a small “cache” of size at most $m$, initially empty. As we scan the sequence from left to right, each element we encounter can either already be in the cache or not.

codeforcescompetitive-programming
CF 105895F - Yuhina City

We are given a connected weighted undirected graph representing a city. Some nodes are radiation sources, each source node has a radiation strength that spreads through the graph and decays linearly with shortest-path distance.

codeforcescompetitive-programming
CF 105895A - 一卡通

We are given a single 9-character string that represents a student ID issued by a university system. The task is to decide whether this ID follows a very specific structural rule. The format is fixed-length and divided into conceptual segments.

codeforcescompetitive-programming
CF 105900N - Na zdrowie

We are given a fixed sequence of length n that is already a permutation of the numbers from 1 to n. This means every number appears exactly once, but we do not know their order. For each query, we are asked about a contiguous segment of this array, from index l to r.

codeforcescompetitive-programming
CF 105900K - Koga needs you

We are given a single line describing a battle scenario in a simplified Pokémon-type cycle. The line contains a fixed prefix and then a single Pokémon name among three possibilities: Torterra, Staraptor, or Luxray.

codeforcescompetitive-programming
CF 105900F - Fibonacci

We are given three integers $a$, $b$, and $M$. The task is not to compute a Fibonacci number in the usual sense of “take index and return value”, but instead to evaluate a Fibonacci number whose index is itself a product: we need the value of $f{a cdot b}$, then take it…

codeforcescompetitive-programming
CF 105900C - Collatz-Star of Pain and Suffering

The problem describes a grid of size $H times W$, where each cell initially stores two integers $A{0,i,j}$ and $B{0,i,j}$.

codeforcescompetitive-programming
CF 105901M - Flight Tracker

Each test case describes a sphere centered at the origin with radius $r$. Three points lie on its surface: your house, the aircraft’s departure point, and its destination.

codeforcescompetitive-programming
CF 105901H - WildFire, This Is for You!

We are asked to construct two very large positive integers, call them x and y, with a very specific geometric property. The only operation allowed on a pair of integers is to move in the grid by changing one coordinate by plus or minus one, and each such move costs one unit.

codeforcescompetitive-programming
CF 105901B - Black Red Tree

A tree is given with $n$ nodes, and every edge starts out colored black. We then perform $n-1$ operations. In the $i$-th operation, a specific edge is recolored from black to red, so the set of black edges gradually shrinks until the tree has no black edges left.

codeforcescompetitive-programming
CF 105902J - Spirit of Cola.

We are given a very small system: three cups with fixed capacities and current amounts of cola. We can move liquid between cups with a simple rule that always pours as much as possible until either the source empties or the destination fills.

codeforcescompetitive-programming
CF 105902F - Imbalanced Bracket

We are given a string made of opening and closing brackets. We are allowed to change characters one by one, each change turning a bracket into the opposite type. After performing some number of such changes, we look at every possible non-empty subsequence of the resulting string.

codeforcescompetitive-programming
CF 105902A - One Must Imagine Time Tight,

We are given three candidate routes or plans for completing the same task, each associated with a time cost. The goal is simply to choose the fastest option among the three and output its time. Each input consists of exactly three integers.

codeforcescompetitive-programming
CF 105911J - Hot Pepper

We are given several points on an infinite grid. Each point represents a pepper placed at a specific coordinate, and each pepper has a fixed type. One type interacts along its column, meaning it “cares” about other peppers sharing the same x-coordinate.

codeforcescompetitive-programming
CF 105911F - Caloric Difference

We are given a sequence of days. On each day we choose a nonnegative real number $ri$, interpreted as caloric intake, but it is restricted to lie in a fixed interval $[L, R]$.

codeforcescompetitive-programming
CF 105911A - Nezha Naohai

We are given three independent events that represent how long Nezha spends causing disturbances in the sea. Each event has a duration measured in hours, and during every hour of disturbance, a fixed number of complaints is generated.

codeforcescompetitive-programming
CF 105920I - Ciallo

We are given two strings, and we are allowed to build new strings by taking a prefix of the first string and concatenating it with a suffix of the second string.

codeforcescompetitive-programming
CF 105920F - Pull

We are modeling a repeating random process where each “cycle” consists of drawing until we obtain a rare event, then resetting. Each draw has a probability of producing a 6-star result, but this probability is not fixed.

codeforcescompetitive-programming
CF 105920C - Dominance

We are given several independent matrices. Each matrix contains a permutation of values, meaning every number from 1 up to n·m appears exactly once.

codeforcescompetitive-programming
CF 105922I - Black and White Coloring

We are given a simple undirected graph with maximum degree at most three. Initially every vertex is uncolored. Two players interact with this graph in two stages.

codeforcescompetitive-programming
CF 105922F - Ever Forever

We are given a single string of lowercase letters. The task is to look at all ordered pairs of positions where the first position contains the character e, the second position contains the character f, and the e appears earlier in the string than the f.

codeforcescompetitive-programming
CF 105922B - Triangle Uika

We are given three independent “moving points”, each controlled by its own polyline path. Each path is a sequence of coordinates, and the corresponding point starts at the first coordinate and moves along straight segments at constant unit speed until it reaches the last…

codeforcescompetitive-programming
CF 105924J - 王国------回忆

We are given a directed graph on $n$ labeled cities, but we do not know its edges. Instead, we are told a matrix that describes reachability: for each pair $(i, j)$, we know whether it is possible to travel from $i$ to $j$ using one or more directed roads.

codeforcescompetitive-programming
CF 105924F - 年少的誓约Ⅱ

We are working with a simplified analog clock where both the hour hand and minute hand can be controlled independently. The clock uses a 12-hour cycle for hours and a 60-minute cycle for minutes.

codeforcescompetitive-programming
CF 105924B - 交换

We are given a permutation of length n, and we are allowed to apply at most k local operations. Each operation targets a pair of adjacent positions.

codeforcescompetitive-programming
CF 105925I - Inspecting the Entanglement

We are given a time interval of length $T$, and at every second exactly one sensor must be active. Each sensor produces a value that depends on both the sensor and the time, so activating sensor $i$ at time $j$ contributes $c(i, j)$ to the total score.

codeforcescompetitive-programming
CF 105925F - Feynman Memorizing Numbers

We are given a static array of up to a thousand integers, and multiple independent queries. Each query asks for the number of distinct quadruples of indices $(i, j, k, l)$ with strictly increasing order such that the sum of the four corresponding values equals the query target.

codeforcescompetitive-programming
CF 105925A - Ambiguous Schrödinger Cat

We are given a system with two binary pieces of information: whether a box is open or closed, and the actual internal state of a cat inside it. The first value, C, describes observability. If the box is closed, the state of the cat cannot be observed externally.

codeforcescompetitive-programming
CF 105928L - AL-1S

We are given a string that contains lowercase letters, uppercase letters, digits, and wildcard characters. Each wildcard can be replaced independently by any lowercase letter, uppercase letter, or digit.

codeforcescompetitive-programming
CF 105928F - Where the West Wind Ends

We are given an array of length $n$, where every element is one of the values $1, 2, 3$. We are guaranteed that all three values appear at least once somewhere in the array. The array itself is hidden.

codeforcescompetitive-programming
CF 105928A - Balanced Eating

We are given several test cases. In each test case there are multiple skewers, and each skewer has a certain number of meat pieces.

codeforcescompetitive-programming
CF 105930K - Path Planning 2

We are given a grid where each cell contains an integer value. From the top-left corner we can only move right or down until we reach the bottom-right corner. Any such movement forms a monotone path, and every path collects the values of the cells it passes through.

codeforcescompetitive-programming
CF 105986G - 神圣愤怒

Codeforces 105986G: 神圣愤怒

codeforcescompetitive-programming
Kvant Physics Problem 567

The solution depends critically on the two missing elements: the $I$–$U$ characteristic of the bulb (Figure 3) and the circuit configuration (Figure 4).

kvantphysics
Kvant Physics Problem 566

An atom moves in the laboratory frame with velocity $v$, where

kvantphysics
Kvant Physics Problem 559

The physical system is the carbon cycle of thermonuclear reactions in a star.

kvantphysics
Kvant Physics Problem 558

A small heavy ball of mass $m$ enters a hollow smooth spherical shell of radius $R$ and mass $m$.

kvantphysics
Kvant Physics Problem 557

I cannot write a correct solution to Kvant problem F557 from the text alone, because the problem statement refers to "Figure 3", and the circuit diagram is essential.

kvantphysics
Kvant Physics Problem 555

Part (a) concerns a light rigid rod of length $l$ hinged at its lower end.

kvantphysics
Kvant Physics Problem 553

A heavy board of mass $M$ rests horizontally on two thin walled rollers.

kvantphysics
CF 106443G - Gabmei, the hacker

We are given up to 20 distinct points on a 2D plane, each point representing a balloon. A single dart is not limited to a segment or ray; it behaves like an infinite straight line. Once a dart is thrown, every balloon lying exactly on that line is popped.

codeforcescompetitive-programming
CF 106440M - 微软大战代码

We are given a rooted version tree. Version 1 is the root. Every other version has exactly one parent among earlier versions, and the edge from parent to child carries a character. That character sequence along a root-to-node path defines the “signature string” of a version.

codeforcescompetitive-programming