brain

tamnd's digital brain — notes, problems, research

41641 notes

CF 105444E - Exhaustive Experiment

Each component is a point on a plane with integer coordinates, and each point is labeled either as untested, positively tested, or negatively tested. We are asked to assume that some subset of these points are “leaking sources”.

codeforcescompetitive-programming
CF 105444F - Film Critics

We are asked to arrange a set of film critics in an order that determines how they score a movie, where each critic’s final rating is not only based on their own initial opinion but also on the current average score produced by earlier critics. The process works sequentially.

codeforcescompetitive-programming
CF 105444D - Dams in Distress

The system is a rooted tree where every node is a dam, and the root represents the war camp. Each dam has a capacity and a current stored amount of water. Water can be added at exactly one chosen node.

codeforcescompetitive-programming
CF 105444C - Coin Stacks

We are given several stacks of coins. In one move, two players jointly choose two different stacks and remove exactly one coin from each of those stacks. They keep doing this until no coins remain anywhere.

codeforcescompetitive-programming
CF 105444B - Big Brother

We are given the boundary of a simple polygon representing a floor plan. The vertices are listed in clockwise order, and the polygon can have a very large number of vertices, up to half a million.

codeforcescompetitive-programming
CF 105444A - Array of Discord

We are given a nondecreasing sequence of integers, where each value is written in decimal form. The gods want the sequence to stay sorted, meaning each element must remain less than or equal to the next.

codeforcescompetitive-programming
CF 105445G - Timosh and Set

We are given a collection of allowed operations defined by an array of distinct positive integers. Each operation picks one of these integers, say ai, and transforms a current value x into the largest multiple of ai that is strictly less than or equal to x.

codeforcescompetitive-programming
CF 105445F - Ranking Random Pick

We are given an array of values, and a stochastic process that repeatedly manipulates it until it becomes empty. At each step, a fair coin decides who acts.

codeforcescompetitive-programming
CF 105445E - Sigma Problem (Hard Version)

We are given an array and asked to answer many queries about a very specific aggregation over subarrays. For any segment $[l, r]$, we conceptually look at every starting index $i$ inside it, and from each $i$ we consider every ending index $j ge i$ up to $r$.

codeforcescompetitive-programming
CF 105445D - YEET!

We are asked to construct a permutation of the numbers from 1 to n such that every adjacent pair in the permutation avoids two specific “bad interactions” defined using a parameter m.

codeforcescompetitive-programming
CF 105445A - Sum Fun

We are asked to decide whether it is possible to construct a number with very rigid structure: it must have exactly n digits, it must be a palindrome, none of its digits can be zero, and the sum of all its digits must be exactly m.

codeforcescompetitive-programming
CF 105445C - Sigma Problem (Easy Version)

We are given a single array and asked to compute a very large nested sum built from all contiguous subarrays. For every starting index i, we look at every ending index j ≥ i, compute the product of the subarray a[i] ...

codeforcescompetitive-programming
CF 105445B - Interviews

We are given a small system of interviewers who repeatedly conduct interviews in groups. Each interview consists of exactly z distinct interviewers, and each interviewer can only participate in at most y interviews per day.

codeforcescompetitive-programming
CF 105446L - Leg Day

The task describes a repeating training schedule that classifies each day into one of three categories based on textual cues: leg-focused training days, arm-focused training days, and rest days.

codeforcescompetitive-programming
CF 105446K - Knitting

We are given a partially constructed sequence representing a knitted scarf. Each position is a color, and some prefix of the scarf is already fixed.

codeforcescompetitive-programming
CF 105446J - Jabber Network

We start with a network of $n$ computers connected by exactly $n-1$ cables, so the structure is a tree. Every computer pair has a known communication demand $c{ij}$, and if we route traffic along the unique path in the current tree, the cost contributed by this pair is $c{ij}$…

codeforcescompetitive-programming
CF 105446I - Inconsistent Patterns

We need to construct a synthetic dataset that demonstrates a reversal phenomenon across aggregation. There are two teams, and performance is measured over several categories. For each category, we assign how many problems each team attempted and solved.

codeforcescompetitive-programming
CF 105446H - Hedge Topiary

We are given two simple polygons, both centered at the origin in the sense that the origin lies strictly inside each of them. The first polygon represents a shape we are allowed to scale uniformly around the origin. The second polygon is a fixed container.

codeforcescompetitive-programming
CF 105446G - Word Search

We are given two rectangular character grids. The first grid is a small pattern, and the second grid is a much larger canvas where we want to search for occurrences of that pattern as a contiguous 2D block.

codeforcescompetitive-programming
CF 105446F - Finding Suspicious Proteins

We are given a collection of proteins, each represented by a short identifier and a vector of length $l$. You can think of each protein as a point in a low-dimensional integer space, where each coordinate is between 0 and 9.

codeforcescompetitive-programming
CF 105446E - Eradication Sort

We are given a sequence of heights laid out in a single row, representing people in a photograph. We are allowed to remove any subset of these people.

codeforcescompetitive-programming
CF 105446B - Budget Analysis

We are given a long sequence of paired observations. Each observation represents a month, where one value is advertising spend and the other is resulting sales. From this data, we repeatedly build a simple predictive model of the form of a straight line mapping spend to sales.

codeforcescompetitive-programming
CF 105446D - Drone Control

We are controlling a simplified flight controller with four adjustable parameters corresponding to four flaps: north, east, south, and west. Each request gives three desired physical effects: pitch, roll, and yaw.

codeforcescompetitive-programming
CF 105446C - Cross Country

We are given a start point, a sequence of line segments that represent checkpoints, and a finish point. A runner moves freely in the plane, and their path is measured as Euclidean length.

codeforcescompetitive-programming
CF 105446A - Amalgram

We are given two strings consisting of lowercase English letters, and we want to construct a third string that “covers” both of them in terms of letter multiplicities.

codeforcescompetitive-programming
CF 105449L - Выгодный процент

A bank offers a special high-interest deposit that can only be opened if the deposited amount reaches or exceeds a threshold value b. Philip has a rubles available, and his goal is to maximize how much money he can place into this high-interest deposit.

codeforcescompetitive-programming
CF 105449A - Скип или не скип

We are given a process that starts from task 1 and moves through a system that dynamically chooses the next task based on what we previously did. Each task has a score value and also a “jump limit” that affects where the next available task can come from if we skip.

codeforcescompetitive-programming
CF 105449E - Покупка колы

We are given a vending machine with several hidden compartments, each containing some number of cans. There are also the same number of buttons, but the labels are lost, so each button is secretly wired to exactly one compartment via a fixed unknown permutation.

codeforcescompetitive-programming
CF 105449B - Отгадай строку

We are given a hidden string of length $n$, built from the first $k$ lowercase Latin letters. We are not given the string directly. Instead, we are given two pieces of information that uniquely determine it.

codeforcescompetitive-programming
CF 105449C - Холмы и ямы

We are given an array of integers that represents terrain heights along a one-dimensional road. Each position has either surplus sand (positive value) or a deficit that must be filled (negative value).

codeforcescompetitive-programming
CF 105450J - Candy Production

We are given a collection of machines, and each machine can be configured in one of three productive roles or left unused.

codeforcescompetitive-programming
CF 105450A - Minimize Sour Difference

We are given a list of integer sourness values representing candies. Alice is allowed to remove exactly $k$ candies from this list, leaving $n-k$ candies behind.

codeforcescompetitive-programming
CF 105450F - Houdini

We are given a tree with one value on each node, representing how many candies sit in that container. The magician is allowed to delete edges, which breaks the tree into connected components.

codeforcescompetitive-programming
CF 105450B - Sour Strip Shapes

We are given two axis-aligned squares on a 2D grid. Each square is described by the coordinates of its lower-left corner and a side length.

codeforcescompetitive-programming
CF 105453F - Anomia

We are given a rectangular grid that behaves like a small city map. Some cells are roads, some are buildings that block movement, and some contain police officers who look in a fixed direction with limited vision.

codeforcescompetitive-programming
CF 105453B - Bureaucracy

We are given a queue of people standing in a fixed initial order from 1 to N. Each person has a workload Ri, representing how much processing time they need at a government office. The office works in rounds.

codeforcescompetitive-programming
CF 105454K - Квантовые каналы связи

We are given a binary string consisting only of opening and closing parentheses. From this string, we consider subsequences, meaning we may delete characters without changing the order of the remaining ones.

codeforcescompetitive-programming
CF 105454H - Как же это посчитать?

We are given an interval of integers from a to b, and we need to count how many numbers inside this interval have exactly six positive divisors.

codeforcescompetitive-programming
CF 105454G - Сестра и братья

We are dealing with a situation where two baskets of apples exist. One basket contains a known amount $X$, the second contains an unknown positive number $Y$, strictly smaller than $X$.

codeforcescompetitive-programming
CF 105454A - Очень длинное условие

We are given a rooted tree with vertices numbered from 1 to n, where each vertex except the root has a parent given explicitly. The task is to assign one of k colors to every vertex such that no edge connects two vertices of the same color.

codeforcescompetitive-programming
CF 105454C - Почтальон Печкин в большом городе

The city is an undirected connected graph where each house is a vertex and each road is an unweighted edge. A postal hub must be placed at exactly one vertex.

codeforcescompetitive-programming
CF 105455B - Bureaucratic Games

We are given a linear sequence of service windows, and at each window there is exactly one possible transformation between documents: if you currently hold a specific document, you may choose to perform a procedure that converts it into another document.

codeforcescompetitive-programming
CF 105455A - Juan's Femur

We are given multiple independent scenarios. Each scenario provides three positive integers representing the lengths of three bone fragments left after a fracture.

codeforcescompetitive-programming
CF 105456C - Jan's Cookies

We are given several independent scenarios. In each one, there are many cookies, each cookie belongs to a type and has a deadline time when it disappears.

codeforcescompetitive-programming
CF 105456B - Deleting Letters from the SMS

We are given a string of lowercase letters representing an SMS message. Pedro is required to shorten it by deleting exactly $n - k$ characters while keeping the relative order of the remaining characters unchanged.

codeforcescompetitive-programming
CF 105457A - Words

We are given multiple independent test cases. Each test case consists of two strings of equal length, and some positions in both strings may contain unknown characters represented by a question mark.

codeforcescompetitive-programming
CF 105458C - Flipping Rectangles

We are given a grid of size $n times m$ filled with two types of cells, black and white. The goal is to turn every cell into white using a specific operation.

codeforcescompetitive-programming
CF 105459M - Weird Ceiling

We are given a single integer $n$, and we conceptually evaluate a function $f(n, i)$ for every integer $i$ from 1 up to $n$. Each value of $f(n, i)$ is defined by a procedure that scans integers downward from $i$ to 2 and checks divisibility against $n$.

codeforcescompetitive-programming
CF 105459I - A Brand New Geometric Problem

We start with a collection of positive integers that represent edge lengths of an $n$-dimensional hyper-rectangle. Two aggregate values matter: the sum of all edge lengths and the product of all edge lengths.

codeforcescompetitive-programming
CF 105459E - Marble Race

There are $m$ marbles, each moving on the real line. Each marble first picks one of $n$ fixed starting positions on the negative side of the axis uniformly at random, independently of all others.

codeforcescompetitive-programming
CF 105459A - Build a Computer

We are asked to construct a compact representation of all binary numbers in a given inclusive interval $[L, R]$. Instead of listing these numbers directly, we must build a directed acyclic graph with a single source and a single sink, where every valid path from source to sink…

codeforcescompetitive-programming
CF 105461L - Drawing Rectangles

We are repeatedly choosing axis-aligned rectangles inside an $n times m$ grid whose corners lie on integer coordinates.

codeforcescompetitive-programming
CF 105461I - Periodic Recurrence

We are given a sequence generated by a linear recurrence modulo a fixed integer $M$. The sequence starts from two initial values $a0$ and $a1$, and every next element is formed by combining the previous two using fixed coefficients $A$ and $B$, then reducing the result modulo…

codeforcescompetitive-programming
CF 105461F - Autobahn Optimization

We are given a sequence of cars that arrive in a fixed order. Each car has a maximum possible speed, and we are allowed to assign each car to one of two lanes. The order of cars inside each lane is the same as the original order, so each lane forms a subsequence.

codeforcescompetitive-programming
CF 105461A - Matrix Minors

We are given a square matrix and asked to compute a very specific derived matrix. For every cell $(i, j)$, we conceptually remove row $i$ and column $j$ from the original matrix and compute the determinant of the remaining $(n-1) times (n-1)$ matrix.

codeforcescompetitive-programming
CF 105461C - Concert Lineup

We are maintaining a dynamic ordering of $n$ distinct items representing artists in a concert lineup. The lineup is stored as a sequence, and we repeatedly apply operations that depend on positions inside the current sequence. Each operation gives an even number $k$.

codeforcescompetitive-programming
CF 105465L - LIS on Grid

We are given a grid with $n$ rows and $m$ columns. For each column $j$, we must choose exactly $aj$ cells to paint black. All other cells remain white. The choices inside each column are free, as long as the number of black cells per column is fixed.

codeforcescompetitive-programming
CF 105465H - High Towers

We are given a line of positions representing towers, and for each position we are told how many other towers that tower must be able to “see” or communicate with. Two towers can communicate if, between them, there is no tower strictly higher than both endpoints.

codeforcescompetitive-programming
CF 105465E - Eliminate Tree

We are given a tree where every operation changes the structure in a very specific way. One type of operation inserts a new vertex and connects it to exactly one existing vertex, effectively creating a new leaf.

codeforcescompetitive-programming
CF 105465A - AND-OR closure

We are given a set of distinct integers, and we are allowed to repeatedly apply two operations: bitwise AND and bitwise OR between any two elements. Every time we apply one of these operations, the result must also belong to the set.

codeforcescompetitive-programming
CF 105471B - Counting Multisets

We are counting how many multisets of non-negative integers satisfy three simultaneous constraints, but the constraints are expressed in a slightly indirect way. Each multiset has size $n$, so it contains exactly $n$ elements when multiplicities are expanded.

codeforcescompetitive-programming
CF 105472K - Keep it Cool

We are given a fridge divided into several independent slots. Each slot already contains some number of cold soda bottles, and each slot also has a fixed maximum capacity.

codeforcescompetitive-programming
CF 105472I - Incremental Induction

We are given the complete results of a round-robin tournament among $n$ contestants, but the results are encoded incrementally. For every pair of contestants $i < j$, we know whether contestant $j$ defeated contestant $i$.

codeforcescompetitive-programming
CF 105472F - Flow Finder

The tree describes a system where every node carries a nonnegative “flow value”. Leaves represent independent sources of water and may take any positive integer value. Every internal node represents a confluence, and its value is exactly the sum of the values of its children.

codeforcescompetitive-programming
CF 105472E - Eeny Meeny

We are simulating a selection process on a circular arrangement of children. The children stand in a fixed clockwise order, and we repeatedly remove one child at a time based on a counting rule defined by a given rhyme, which is just a sequence of words.

codeforcescompetitive-programming
CF 105472B - Building Boundaries

We are given three rectangular buildings, each with fixed side lengths, and we are allowed to rotate each rectangle by 90 degrees. The goal is to place all three rectangles on a single larger axis-aligned rectangle such that they do not overlap.

codeforcescompetitive-programming
CF 105472C - Cocoa Coalition

We are given a rectangular chocolate bar made of unit squares arranged in an n by m grid. We repeatedly take a single rectangular piece and split it into two smaller rectangles by making one straight cut, either horizontally or vertically.

codeforcescompetitive-programming
CF 105475A - Pizzas

Each attendee requests a number of pizza slices, and every requested slice has a specified topping. A pizza shop sells pizzas in only one topping per pizza, and each pizza is always cut into exactly 8 equal slices.

codeforcescompetitive-programming
CF 105475C - Word Expansion

We start with a single string made of lowercase letters. Each letter is not static: it expands into another string according to a fixed substitution table of size 26. If a character is x, it is replaced by the string px.

codeforcescompetitive-programming
CF 105476E - Ninjas

We are given a tree representing a palace, where each room is a node and corridors are edges. Some rooms are special: exactly the leaves of the tree, those with only one corridor, contain doors. Two groups enter the tree from two different leaves.

codeforcescompetitive-programming
CF 105476B - Multiples of 11

We are given a string of digits for each test case and asked to count how many of its contiguous substrings represent integers divisible by 11. Each substring is interpreted as a decimal number, but substrings may start with zero, so leading zeros do not affect divisibility.

codeforcescompetitive-programming
CF 105476A - Distractions

We are working with a sequence of strings where each term is constructed from the previous one by describing it in terms of consecutive runs of digits.

codeforcescompetitive-programming
CF 105477C - Decoding Permutations

We are given a sequence of constraints that come from a hidden permutation of the numbers from 1 to n. Instead of the permutation itself, we receive, for each position i, a value ci that counts how many earlier positions contain values smaller than the value placed at position i.

codeforcescompetitive-programming
CF 105477B - Russian Roller Coasters

We are asked to count how many valid “roller coasters” can be formed from a fixed number of segments, where each segment moves one unit horizontally and either goes up or down by one unit vertically.

codeforcescompetitive-programming
CF 105478C - Greed

Each test case gives a shop structured as several independent stacks of items. In each stack, items are arranged in a fixed order from top to bottom, and you are only allowed to access the next item in a stack if you have already bought everything above it.

codeforcescompetitive-programming
CF 105481K - 可重集合

We start with an empty multiset $S$. Each operation either inserts one occurrence of a number $x$ into $S$, or removes one occurrence of $x$ that is guaranteed to exist.

codeforcescompetitive-programming
CF 105481I - 野兽节拍

We are given a long string made of lowercase letters. We are allowed to choose a pattern string T of length three.

codeforcescompetitive-programming
CF 105481F - 飞沙走蛇

We are given a directed graph on up to 500 vertices. Every vertex has the same number of outgoing and incoming edges, and the graph is strongly connected.

codeforcescompetitive-programming
CF 105481E - 俄式简餐

We are given a rectangular grid with $n$ rows and $m$ columns, and two kinds of tetromino pieces. Each piece occupies exactly four unit cells, and we are allowed to rotate or reflect each piece arbitrarily before placing it on the grid.

codeforcescompetitive-programming
CF 105481C - 插排串联

The system is a rooted tree that models an electrical setup. The root is a single socket with a fixed power limit, and every other node is either an electrical device or a power strip.

codeforcescompetitive-programming
CF 105481B - 比分幻术

We are given a scoreboard written in the form A-B, where A represents Alex’s score and B represents the opponent’s score. Both values are single digits from 0 to 9. The system applies a “score illusion” operation that simply swaps the two values.

codeforcescompetitive-programming
CF 105485N - 低谷(hard)

We are given a sequence of numbers and allowed to perform a fixed number of operations. Each operation chooses a single position and decreases that value by exactly one. After doing this up to k times in total, we want to maximize how many indices become “valleys”.

codeforcescompetitive-programming
CF 105485L - 数组交换

We are given a single array of odd length. The process runs for exactly half of its length rounded down, and each round always removes the first two elements after allowing a single adjacent swap somewhere in the array.

codeforcescompetitive-programming
CF 105485I - 智力博弈

We are given an array that contains each integer from 1 to n exactly twice, but the order is arbitrary. Think of it as a sequence of 2n labeled cards where every label appears exactly two times. Two players then play a game on this sequence.

codeforcescompetitive-programming
CF 105485E - 伤害最大化

We are scheduling actions over a short time horizon of at most 18 steps. At each time step, we must choose exactly one of four skills.

codeforcescompetitive-programming
CF 105485F - 猫猫虫困境 II

We are working on a one-dimensional number line from 1 to n. On this line there are two types of special points: p starting positions for independent agents (called catworms in the statement), and k teleport portals. There is also a single target position g.

codeforcescompetitive-programming
CF 105485B - 借阅图书

We are simulating a library system where books are stored in a stack and readers interact with the system over a sequence of time-stamped events. The books are initially arranged so that book number 1 is at the bottom and book number n is at the top.

codeforcescompetitive-programming
CF 105486M - Two Convex Holes

We are tracking how a point light source moves in a horizontal plane while two fixed convex “gates” in space restrict which points on the ground can be illuminated.

codeforcescompetitive-programming
CF 105486F - Double 11

We are given a list of positive values $si$, each representing the daily demand of a product type. We must partition these $n$ items into exactly $m$ non-empty groups. For each group $j$, we assign a positive real parameter $kj$. Two quantities are defined from this construction.

codeforcescompetitive-programming
CF 105486B - Athlete Welcome Ceremony

We are given a line of n volunteers, each position already partially assigned one of three costume types or left unassigned. The fixed assignments are immutable, while the unassigned positions must be filled using costumes of type a, b, or c.

codeforcescompetitive-programming
CF 105487L - Puzzle

We are given four kinds of puzzle pieces, labeled A, B, C, and D, with limited quantities of each. Each piece has special edge geometry, and pieces can only be placed next to each other if their touching edges are compatible in a complementary way, meaning one side must “fit…

codeforcescompetitive-programming
CF 105487F - Perfect Square

We are given a sequence of positive integers. For each number $ai$, we must choose a divisor $di$. After making all choices, we look at the product $D = prod di$. Among all possible choices, we only care about those where this product is a perfect square.

codeforcescompetitive-programming
CF 105487C - CCPC

We are given a single long string consisting only of uppercase letters. We are allowed to rearrange its characters arbitrarily. After rearranging, we look at how many times the pattern “CCPC” appears as a contiguous substring in the resulting string.

codeforcescompetitive-programming
CF 105492L - Levelling Locks

We are given a line of water-filled chambers, each with its own initial water level. All adjacent chambers are separated by gates, and initially every gate is closed, so nothing is connected.

codeforcescompetitive-programming
CF 105492H - Horse Habitat

We are given a large rectangular grid where each cell is either usable terrain or blocked terrain. A usable cell can be part of a training course, while a blocked cell cannot.

codeforcescompetitive-programming
CF 105492B - Buggy Blinkers

We are given a directed graph where each node represents an intersection and each edge corresponds to a one-way road in one of the four cardinal directions.

codeforcescompetitive-programming
CF 105493F - Volunteering

We are given a fixed large interval on a number line, together with several smaller intervals. Each small interval contributes coverage to some portion of the large interval.

codeforcescompetitive-programming
CF 105493B - Scientific Hypotheses

We are given a sequential process of “reactions” indexed from 1 to n. At each step i, we assign a value p[i], and this value is constrained from above by a global limit pmax.

codeforcescompetitive-programming
CF 105494F - Traffic Lights

We are simulating a bus moving through a sequence of traffic lights. Between intersections, the bus spends a fixed amount of travel time, and at each intersection it may need to wait depending on the current state of a periodic traffic signal.

codeforcescompetitive-programming
CF 105494C - Linear Maze

We are given a sequence of rooms indexed from 1 onward, and we process them strictly in order. While moving through the prefix of rooms, we maintain a single integer value called the current answer. Each room contributes in one of two ways.

codeforcescompetitive-programming