brain

tamnd's digital brain — notes, problems, research

41641 notes

CF 105937G - Primal Core Optimization: Attribute Balance

We are given a collection of $N$ points in a 3-dimensional integer space. Each point represents a partner with three attributes $(S, F, E)$. The goal is to apply operations so that all points become identical, meaning every partner ends with exactly the same triple.

codeforcescompetitive-programming
CF 105937E - Pythagorean Cup

We are given a line of $n$ cups. Each cup starts in one of three states: empty, half full, or full. A full cup immediately overflows and effectively becomes empty, so after initialization only empty and half-full cups matter.

codeforcescompetitive-programming
CF 105937H - 9-Nine

We are given two very small binary grids, each of size 3 by 3. Think of the first grid as configuration A and the second as configuration B. Every cell is either 0 or 1. We are allowed to perform three kinds of operations.

codeforcescompetitive-programming
CF 105937D - Symmetrical Isolation: The Battle of Black and White

We are given a rectangular board of size $N times M$. Each cell is either already black or white. We are allowed to paint additional white cells black, but we are never allowed to repaint a black cell back to white.

codeforcescompetitive-programming
CF 105937C - Quantum Mechanics

We are given a quantum system consisting of $n$ qubits, and instead of a classical state like a bitstring, the system is described as a complex-valued vector of size $2^n$. Each index of this vector corresponds to one basis state, i.e., one binary string of length $n$.

codeforcescompetitive-programming
CF 105937A - Card Master

We are given a single round of a very simple card game where exactly three cards are drawn. Each card has an integer value between 1 and 13. The score for the round is normally just the sum of the three values.

codeforcescompetitive-programming
CF 105931E - Матрица циклических сдвигов

We start with a one-dimensional array, but instead of working with it directly, we use it to generate an $n times n$ matrix where every row is just a cyclic shift of the original array.

codeforcescompetitive-programming
CF 105931D - Вычислительная машина

We are given two binary strings of equal length, which we can think of as two rows aligned vertically. On each query, we take a substring interval and are allowed to apply two local transformation rules inside that interval.

codeforcescompetitive-programming
CF 105931B - Манхэттенские перестановки

We are given a permutation of length $n$, meaning an arrangement of the numbers from $1$ to $n$ without repetition. For any position $i$, the contribution of that position is the distance between the value placed there and the index itself, taken in absolute value.

codeforcescompetitive-programming
CF 105931A - Новый университет

The university is enrolling up to n students in total. Every student must fall into one of two categories. If a student pays tuition, they contribute a fixed amount a to the university. If a student receives a scholarship, their funding comes from a sponsor.

codeforcescompetitive-programming
CF 105930M - Triangulation

We are given a circle with $n$ equally spaced points. Think of them as vertices placed around a round table in clockwise order, but their labels are unknown.

codeforcescompetitive-programming
CF 105930H - Minimum Spanning Tree

We are given a connected undirected weighted graph. On top of the existing edges, we are allowed to add up to k extra edges.

codeforcescompetitive-programming
CF 105930J - Useful Algorithm

We are given a permutation of size $n$ and a target value $k$. We imagine running a binary search algorithm on this permutation, treating it as if it were a sorted array even though it may be completely arbitrary.

codeforcescompetitive-programming
CF 105930A - Project Management

Each employee comes with two attributes: a rank value and a personal tolerance. The rank determines who they consider “higher” than themselves, and the tolerance specifies how many higher-ranked colleagues they are willing to tolerate in the same project team.

codeforcescompetitive-programming
CF 105930F - ACE String

We are given a string and we want to find a substring that has a very rigid internal structure. Inside such a substring, we must be able to choose a length p and a starting position for a middle block so that the substring can be conceptually split into five consecutive parts.

codeforcescompetitive-programming
CF 105930D - Distributed System

We are given a system with n worker nodes arranged in a circle, indexed from 0 to n-1. Each task does not go to a single node, but instead generates a contiguous sequence of sub-tasks. A task is described by two values: a and b.

codeforcescompetitive-programming
CF 105928M - Bridge IV

Two players are dealt full information about a bridge-like game. For every suit, each player already knows exactly how many tricks they would win if they became the declarer and chose that suit.

codeforcescompetitive-programming
CF 105928C - Knight

We are given a large rectangular chessboard and a single starting square. A piece called a knight can move in a generalized way: from any square it can jump either k steps in one axis and 1 step in the other, or the reverse, with all sign variations as long as the destination…

codeforcescompetitive-programming
CF 105928I - FST: First Search Traversal

We are given two sequences of length $n$, each of which is a permutation of the numbers from $1$ to $n$. We are asked whether it is possible to construct a rooted tree on these $n$ labeled nodes such that one of the permutations can be obtained as a valid depth-first search…

codeforcescompetitive-programming
CF 105928E - LCM Queries

We are maintaining a dynamic array where elements can change over time, and we must answer range queries about a multiplicative structure derived from those elements. Each query either updates a single position or asks about a segment of the array.

codeforcescompetitive-programming
CF 105925K - K Missing Elements

We are given a sequence that defines an ordering constraint between positions and another sequence that assigns a weight to each position.

codeforcescompetitive-programming
CF 105925E - Particle Energization

A particle starts at position 1 on an infinite number line. A fixed parameter $Y$ is given. The particle evolves in discrete steps.

codeforcescompetitive-programming
CF 105925C - Matrix Logic Circuits

We are given a quantum circuit described as a sequence of reversible logic gates acting on an N-qubit system. Each gate is either a CNOT or a CCNOT.

codeforcescompetitive-programming
CF 105925J - Journey of the Particles

We are given a circular arrangement of N filters. Each filter has a threshold value, and particles move through these filters in a fixed direction. A particle starts at filter i with an initial phase equal to the threshold of that filter.

codeforcescompetitive-programming
CF 105924K - 微信小游戏

We are given an $n times m$ grid where each column contains a vertical stack of colored blocks. There is also an extra “floating” block $d$, initially colorless.

codeforcescompetitive-programming
CF 105924H - 王国------迁移

We are given a system with two interacting sides: cities and groups of people. There are $n$ cities, each with a cost parameter $ci$, and $n$ groups of residents, where group $i$ contains $bi$ people.

codeforcescompetitive-programming
CF 105924E - 树上删边

We are given a tree where every node carries a weight, and we repeatedly remove exactly $k$ edges. The removal process is constrained: at every step, the edge we remove must still lie inside the connected component that contains node 1.

codeforcescompetitive-programming
CF 105924A - GD 终极节奏实验室

We are given a sequence of integers representing rhythm intensities across a level. The task is to count how many contiguous segments of this sequence are “perfectly synchronized”, meaning that within the segment the greatest common divisor of all values is exactly equal to…

codeforcescompetitive-programming
CF 105922L - Good Matrix

We are working with a binary matrix of size $n times m$, where each cell contains either 0 or 1. For every position $(i, j)$, we define two quantities: the XOR of all elements in row $i$, and the XOR of all elements in column $j$.

codeforcescompetitive-programming
CF 105922A - Genius Cirno's Genius Computer

We are given an interactive system that behaves like a tiny register machine. Four registers start with unknown positive integers, and four auxiliary registers start at zero.

codeforcescompetitive-programming
CF 105922J - Odd-Even Game

We are given two integers, and we are told a strict structural property about them: one of them is guaranteed to be odd and the other is guaranteed to be even. Each number represents a “player’s choice” in a very simple comparison game.

codeforcescompetitive-programming
CF 105920M - Magical Book

We are given a string consisting only of opening and closing parentheses. For every query, we look at a fixed interval inside this string and count how many different substrings fully inside that interval form a correct bracket sequence.

codeforcescompetitive-programming
CF 105920J - Bridge III

The input describes a sequence of actions in a simplified bridge auction. Four players act in a fixed cyclic order, and each action is either a bid (an auction like “2C” or “1S”), a pass, a double, or a redouble. The rules govern how these actions can legally appear.

codeforcescompetitive-programming
CF 105911E - God's String on This Wonderful World

We are given a long string of lowercase letters and a fixed integer $k$. For any substring, we are asked whether its letters can be rearranged so that the substring becomes exactly $k$ identical blocks concatenated together.

codeforcescompetitive-programming
CF 105904N - Number of Steps

We are given an undirected weighted graph representing locations in a park and paths between them. Each path has a distance, and that distance translates into travel time for two different groups: Carlos on a bicycle and people walking.

codeforcescompetitive-programming
CF 105902M - The Journey Onwards...

We are given a line with several special landing points, each located at some distance from the starting position. KP starts at position 0 and wants to reach the farthest of these points. Movement is done in two ways.

codeforcescompetitive-programming
CF 105883D - Why Does Every Baozii Cup Have a GCD Problem

We are maintaining an array of integers under two kinds of destructive updates and range sum queries. One update forces a single position to become a new value.

codeforcescompetitive-programming
CF 105869C - Diamonds and the Genie

The grid contains a value in every cell representing diamonds. Jack moves through this grid using only right and down steps, so any path is monotone from the top-left corner to the bottom-right corner. The twist is that we are not optimizing a single simple path in isolation.

codeforcescompetitive-programming
CF 105851B - 疲配

I can’t write a meaningful Codeforces-style editorial from what you provided, because the actual problem statement is missing. Right now I only see the placeholder “B” with no description of the input, output, or task.

codeforcescompetitive-programming
CF 105760G - Bad Tree

We are given the numbers from 1 to n and we insert them into an empty binary search tree in a chosen order. The usual BST rule applies: smaller values go left, larger values go right, and each new value is placed where the search process ends.

codeforcescompetitive-programming
CF 105760D - Food Display Arrangement

The task describes a rectangular display of food items that must be arranged under a specific constraint pattern.

codeforcescompetitive-programming
CF 105755C - Count Pairs

We are given a multiset of positive integers, and we want to choose a subset with no duplicates such that every pair of chosen numbers satisfies a strict bitwise condition involving XOR. For any two chosen numbers $x$ and $y$, we compute $x oplus y$.

codeforcescompetitive-programming
CF 105755F - Fill the Gym with Argon

We are given a rooted structure of activities. Each activity has a profit value, which can be positive or negative, and every activity except the first depends on exactly one earlier activity.

codeforcescompetitive-programming
CF 105646J - Polygon II

We are given several random segment lengths. Each length is not fixed but uniformly random on a continuous interval from zero to twice a parameter attached to that segment. Concretely, the i-th side length Xi is chosen uniformly from the interval [0, 2ai].

codeforcescompetitive-programming
CF 105638K - Hile counts the Qi

The board is a grid containing three types of cells: black stones, white stones, and empty intersections. Stones of the same color that touch orthogonally form a single connected group.

codeforcescompetitive-programming
CF 105638M - Kyooma Loves Numbers Ⅱ

We are given a single integer per test case, and for each one we must construct five positive integers such that all five are at most that given limit and they satisfy a hidden arithmetic condition.

codeforcescompetitive-programming
CF 105638G - Geos Likes Shopping

We are given several item types. Each type has a limited supply, and we must pick exactly a fixed number of items in total across all types. The twist is that the profit from a type is not constant per item.

codeforcescompetitive-programming
CF 105638D - Piza Removes the Letters

We are given a lowercase string. The process applied to it has two stages. First, we delete one contiguous segment of fixed length.

codeforcescompetitive-programming
CF 105633K - Scheduling Two Meetings

We are given a set of candidate time slots for scheduling two separate meetings. For each time slot, every judge either attends on-site or only joins remotely.

codeforcescompetitive-programming
CF 105633G - Beyond the Former Explorer

We are placed at the center of a square grid and there is a single hidden target cell somewhere in this grid. A previous explorer started from the same center cell and walked through the grid without ever revisiting a cell.

codeforcescompetitive-programming
CF 105633B - The Sparsest Number in Between

We are given a closed interval of integers from a to b, where both endpoints can be as large as $10^{18}$. Among all numbers in this interval, we need to choose one whose binary representation contains the smallest number of set bits, meaning the fewest 1s.

codeforcescompetitive-programming
CF 105632L - Z-order Curve

We are given a way to enumerate all non-negative integers in a special spatial order called the Z-order curve. Instead of thinking of this as a formula, it is more helpful to view it as a single infinite directed walk over points indexed by integers, where each integer label…

codeforcescompetitive-programming
CF 105632D - Guessing Game

We are given a growing sequence of pairs, and after each prefix we need to evaluate a hypothetical game on that prefix. For a fixed prefix of length k, imagine we pick one of the k indices i.

codeforcescompetitive-programming
CF 105632G - Same Sum

We are given an array of integers that changes over time. Two operations are applied in sequence: one operation increases every element in a contiguous segment by a fixed value, and the other asks whether a chosen segment can be rearranged into disjoint pairs such that every…

codeforcescompetitive-programming
CF 105631M - Make SYSU Great Again 3

We are given the integers from 1 to n and must place them around a circle in some order. Once the circle is fixed, every consecutive triple of positions is considered, including the wrap-around triples that involve the last and first elements.

codeforcescompetitive-programming
CF 105631K - King of Card Games

We are drawing numbers repeatedly from a set containing all integers from 1 to n, with replacement. Each draw is independent and uniformly random, so any sequence of length m is simply an ordered m-tuple where each position can be any value from 1 to n.

codeforcescompetitive-programming
CF 105631A - Anniversary Celebration

We are given multiple independent scenarios. In each scenario, there are three types of balloons: those labeled S, those labeled Y, and those labeled U. From these balloons we want to repeatedly assemble identical decoration bundles called SYSU sets.

codeforcescompetitive-programming
CF 105631D - Depths of Cities

We start with a tree of cities connected by roads. On top of this tree, we consider a hypothetical operation: for every possible ordered pair of cities $(u, v)$, we temporarily add a new edge between them.

codeforcescompetitive-programming
CF 105629F - 数数

We are working with binary strings of fixed length $n$. Each position is either 0 or 1, so the total space contains $2^n$ strings.

codeforcescompetitive-programming
CF 105629B - 四舍五入

The task revolves around applying standard rounding rules, the same idea behind “round to the nearest integer” that we learn in arithmetic, but implemented on numbers given in a textual or digit-based form.

codeforcescompetitive-programming
CF 105615K - 似花还似非花

I can’t write a correct Codeforces-style editorial for this problem yet because the actual problem content is missing. Right now, the statement section only contains the title and metadata, but no description of the input, output, or task.

codeforcescompetitive-programming
CF 105615H - Good Digits

I can’t write a correct editorial for this yet because the actual problem statement is missing. Right now we only have the title “Good Digits”, but no definition of the input, output, or the rules that determine what makes a digit “good”.

codeforcescompetitive-programming
CF 105615C - I Am the Captain of USTA

I can’t produce a correct, problem-specific editorial for Codeforces 105615C - I Am the Captain of USTA because the actual statement content (input/output definition, constraints, and operations) is missing from what you provided.

codeforcescompetitive-programming
CF 105608A - Сундук сокровищ

We are given a rectangular chest with three edge lengths $X$, $Y$, and $Z$. The chest can be oriented in any way, meaning any pair of its sides can become the “base” that tries to pass through a rectangular portal.

codeforcescompetitive-programming
CF 105592B - Учёные

We are given a collection of objects numbered from 1 up to a very large integer n. Each object has a simple derived label: the sum of digits of its index. Two objects are considered equivalent if their digit sums match. We are not choosing specific indices ourselves.

codeforcescompetitive-programming
CF 105591D - Учёные

We are looking at all integers from 1 up to a very large number n. Each integer is treated as a bacterium, and each bacterium is assigned a label equal to its number. Two bacteria are considered similar when the sum of digits of their labels is the same.

codeforcescompetitive-programming
CF 105591C - Первое уравнение

We are given a positive integer $n$. We want to count how many ordered quadruples of natural numbers $(a, b, c, d)$ exist such that both pairs satisfy the same sum constraint $a + b = n$ and $c + d = n$, and all four numbers are strictly ordered as $a < c < d < b$.

codeforcescompetitive-programming
CF 105588L - Last Chance: Threads of Despair

Two opposing teams are on the battlefield, each consisting of several units with integer health values. Before any combat begins, a global spell is cast that triggers a cascading “death explosion” effect: whenever a unit dies, every unit on the field loses one additional…

codeforcescompetitive-programming
CF 105588M - Matrix Construction

We are asked to place the integers from 1 up to $n cdot m$ into an $n times m$ grid, using each number exactly once.

codeforcescompetitive-programming
CF 105588H - Horizon Scanning

We place a radar at the origin, and every island becomes a direction from the origin, represented by its polar angle.

codeforcescompetitive-programming
CF 105588G - GCD

We are given two positive integers, one small (up to 5000) and one potentially extremely large (up to 10^18). In a single move, we pick one of the numbers and subtract from it the greatest common divisor of the current pair.

codeforcescompetitive-programming
CF 105588D - Dolls

We are given several test cases. In each test case there is a permutation of integers representing doll sizes placed in a row. Each position initially contains exactly one doll, and all sizes are distinct.

codeforcescompetitive-programming
CF 105588C - Coin

We are simulating a repeated elimination process on a line of positions from 1 to n. In each round, the pirates are currently arranged in order, and we remove every k-th position starting from the first one.

codeforcescompetitive-programming
CF 105586L - 向日葵的坡道

We are given a directed bipartite graph whose vertices are split into two equal parts. The left part contains nodes numbered from 1 to n, and the right part contains nodes numbered from n + 1 to 2n. Every existing edge goes strictly from a left node to a right node.

codeforcescompetitive-programming
CF 105586N - 哥伦比亚大选

We are given a small list of candidates in a presidential election, where each candidate has a name and a number representing how many supporters they have. The task is to determine which candidate has the largest number of supporters and output that candidate’s name.

codeforcescompetitive-programming
CF 105586G - 可乐喝雪碧

We are given a sequence of numbers, each being −1, 0, or 1. Between every pair of adjacent elements, we are allowed to place either a plus or a multiplication sign, and we are also free to use parentheses implicitly by choosing the evaluation order in the usual way…

codeforcescompetitive-programming
CF 105586I - 小 P 爱折跃

We are given a directed structure hidden inside an array. Each city has exactly one outgoing teleport, and every teleport belongs to exactly one city.

codeforcescompetitive-programming
CF 105586D - 魔法少女素世世

We are given a directed acyclic graph where each node represents a room containing a monster with a fixed power value. The graph has a special structure: every room can eventually reach the final room numbered $n$, and there are no directed cycles.

codeforcescompetitive-programming
CF 105586A - 演奏春日影

We are given a short playlist of songs represented as strings. Each string is a single program item in an original concert schedule. The task simulates a simple rule applied while reading this schedule from top to bottom.

codeforcescompetitive-programming
CF 105583L - Lightbulbs

We are given a collection of switches and lightbulbs, but the wiring is hidden. Each switch is connected to exactly one bulb, and each bulb has at least one switch attached.

codeforcescompetitive-programming
CF 105583J - Jeerman

We are asked to construct a string of fixed length $N$, using lowercase English letters, such that it “contains” as many different given pattern words as possible. A pattern is considered present if it appears as a contiguous substring anywhere in the constructed string.

codeforcescompetitive-programming
CF 105583F - Fashionable Tiles

We are asked to fill an $N times N$ grid with integers from $1$ to $N$. Each integer appears exactly $N$ times, so the grid is perfectly balanced across colors.

codeforcescompetitive-programming
CF 105583G - Game with XORs

We are given a multiset of integers. Two players, Kolya and Mitya, alternate picking numbers from this set, with Kolya starting first. After all numbers are taken, each player computes the bitwise XOR of the numbers they collected.

codeforcescompetitive-programming
CF 105583B - Bank

We are given a long binary string that was originally a concatenation of many bank transfer records. Each record consists of three binary numbers written back to back: a sender identifier, a recipient identifier, and a transfer amount.

codeforcescompetitive-programming
CF 105583A - Assemble the Tower

We are building a vertical structure made of repeated modular pieces. Each unit of height is a layer, and each layer consumes a fixed number of identical bricks. Layers are grouped into blocks, and each block has a color.

codeforcescompetitive-programming
CF 105582L - Lexica

We are given a square board of size (n+2) × (n+2) where the inner region corresponds to a crossword-like grid. Some inner cells are active, marked with dots, and the rest are blocked. The active cells form a connected structure where we need to place letter tiles.

codeforcescompetitive-programming
CF 105582H - Hamburgers

We are given several groups of friends, and for each group we want to choose a cafe that makes as many people in that group happy as possible. Each person has a preference described by a small set of ingredients, encoded as a short string.

codeforcescompetitive-programming
CF 105582I - Intricate Path

We are asked to construct a small grid world that behaves like a controllable maze for a robot. The grid has three types of cells: empty space, obstacles, and a single starting cell for the robot.

codeforcescompetitive-programming
CF 105582D - Dinner Party

We are given a pile of identical square tables, each representing a unit square tile. We must use all of these tiles to build one or more rectangular “large tables”. Each large table is formed by arranging some number of unit squares into a perfect axis-aligned rectangle.

codeforcescompetitive-programming
CF 105582C - Constructor

We are given several types of construction parts. Each type has a fixed mass and a limited supply. From these parts we want to assemble several identical kits. “Identical” means every kit uses exactly the same number of parts of each type.

codeforcescompetitive-programming
CF 105581G - Robot Vacuum Cleaner

We are given an $N times M$ grid representing a room divided into square tiles. A robot starts at the top-left cell $(1,1)$ and repeatedly performs a very specific cleaning routine. Each cell, when visited, is marked as cleaned.

codeforcescompetitive-programming
CF 105581H - Amphitheater

We are given a theater whose seats form a triangular structure rather than a rectangle. The first row has a fixed number of seats, and each row below grows by two seats.

codeforcescompetitive-programming
CF 105581D - Mosquitoes

We are given a grid of size $N times M$. Each cell represents a window with an initial “brightness” value. That brightness does not just represent local effect, it acts as a source that sends mosquitoes to every window in the building, including itself.

codeforcescompetitive-programming
CF 105581A - Scanner

We are watching a process that can only start at discrete moments. Vitya visits a scanner periodically, every t minutes starting from time 0, and the day ends at time T.

codeforcescompetitive-programming
CF 105580G - Metro

We are given an undirected graph describing a metro system, and we must decide whether it can be generated by a very rigid geometric construction. The construction has a distinguished central station.

codeforcescompetitive-programming
CF 105580H - Domino

We are given a set of domino pieces placed on a number line. Each piece sits at an integer coordinate and has a height.

codeforcescompetitive-programming
CF 105580D - Cakes

We are given a sequence of cakes, each cake requiring three distinct fillings in a fixed order. There are only three possible filling types, labeled 1, 2, and 3, so every cake is a permutation of these three values.

codeforcescompetitive-programming
CF 105580C - Mosaic

We are given a rectangular grid of lowercase letters, where each letter represents a colored tile. The task is to locate a subrectangle whose set of colors satisfies a very rigid combinatorial constraint: exactly K distinct colors appear, and if we count how many times each of…

codeforcescompetitive-programming
CF 105579K - Dima and Petya's Café

The city is a rectangular grid of blocks formed by a set of horizontal streets and vertical avenues. Each intersection of streets and avenues defines a block, and every block contains a known number of potential customers. Two cafes must be placed in two different blocks.

codeforcescompetitive-programming
CF 105579A - Traffic Light

We are simulating a simple driving scenario on a straight road. A car starts some distance away from an intersection and moves toward it at a constant speed. At a certain future time, a traffic light at the intersection will turn red for a fixed duration.

codeforcescompetitive-programming