brain

tamnd's digital brain — notes, problems, research

43815 notes

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 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 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 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 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 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 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
CF 105579G - Minecraft

We are given a vertical cross-section of a Minecraft world represented as an $h times w$ grid. Each cell is either empty, a dirt block, or a gold block.

codeforcescompetitive-programming
CF 105579B - Knight's Revenge

We are given a fixed 10 by 10 chessboard-like grid. Each cell is either empty or contains an enemy. The task is to choose exactly one empty cell as a starting position. From that position, we consider all cells that a chess knight can reach in a single move.

codeforcescompetitive-programming
CF 105578L - The Grand Contest

We are given a chronological log of submissions made by two teams during a programming contest. Each submission belongs to one of the two teams, targets a problem, arrives at a specific time, and is either correct or incorrect.

codeforcescompetitive-programming
CF 105578H - Guide Map

We are given a complete graph on $n$ cities, but only $n-2$ of its edges are marked as scenic. Those scenic edges form a structure that is almost connected, in the sense that if we were allowed to add exactly one more edge, the scenic graph would become fully connected.

codeforcescompetitive-programming
CF 105578F - Light Up the Hypercube

We are working with an n-dimensional hypercube whose 2^n vertices each hold a binary light state. A move consists of choosing one of 2^n operation types.

codeforcescompetitive-programming
CF 105578D - Dot Product Game

We are given two permutations of size $n$, call them $A$ and $B$. Think of them as two aligned sequences of weights. Their interaction is measured by the dot product, where position $i$ contributes $ai cdot bi$.

codeforcescompetitive-programming
CF 105578A - Safety First

We are asked to count how many different “stable ladders” can be formed using exactly n segments, where each segment has a positive integer length and the sequence of lengths is non-increasing from left to right.

codeforcescompetitive-programming
CF 105575J - 我喜欢回文串

We are given a string that may contain lowercase letters and wildcard characters. Each wildcard can be replaced by any lowercase letter.

codeforcescompetitive-programming
CF 105575A - 统计选手

The task describes a very small computation: four integers are provided as input, and the program must output their total sum. There is no additional structure, no hidden transformation, and no dependency between the numbers beyond simple addition.

codeforcescompetitive-programming
CF 105575D - Permutation with MAX Score

We are given multiple independent queries, each query consists of a single integer $n$. For each $n$, we need to compute a value that depends on how far we can repeatedly apply a specific growth process starting from a fixed base expression derived from small integers.

codeforcescompetitive-programming
CF 105570E - Horse Racing In The Wilderness (horse)

We are given $N$ competitors. Each competitor $i$ has an unknown parameter $hi$, which represents how fast they finish. Smaller values of $hi$ always correspond to earlier finishing times, so the final ranking is exactly the ordering of all $hi$ in increasing order.

codeforcescompetitive-programming
CF 105570C - Get Out Away (getoutaway)

We are given a weighted tree of up to 500,000 nodes. Two people start from the same unknown city and then take turns moving through the tree. On a turn, the active person may move to a neighboring city as long as that city has never been visited by either person before.

codeforcescompetitive-programming
CF 105562J - Jib Job

Each crane sits at a fixed point on the plane and has a vertical tower height. From the top of each tower, we attach a rotating horizontal beam. The beam length must be a positive integer and cannot exceed the tower height.

codeforcescompetitive-programming
CF 105562K - Kruidnoten

We are working on a weighted graph where intersections are nodes and cycleways are undirected edges with positive lengths. Karlijn starts at node 1 and wants to reach node n. Some nodes contain shops.

codeforcescompetitive-programming
CF 105562D - Dutch Democracy

We are given a collection of political parties, each with a certain number of seats. A “coalition” is simply a subset of these parties. We want to count how many subsets satisfy a very specific notion of being a valid governing coalition.

codeforcescompetitive-programming
CF 105562E - Evolving Etymology

We start with a string of length n and a transformation that builds a new string from a doubled version of itself. Each application takes the current string t, forms t + t, and then keeps characters at positions 0, 2, 4, ... of that doubled string.

codeforcescompetitive-programming
CF 105400D - Cool Sort

We are given a permutation of the numbers from 1 to N arranged in a line. The goal is to transform this permutation into the sorted order 1 through N using swaps, but with a strict restriction on what swaps are allowed.

codeforcescompetitive-programming
CF 105400K - Powerful Swaps (Hard Version)

We are given an array and asked whether it can be transformed into a sorted array using adjacent swaps, but with a constraint that makes swaps progressively harder as the process goes on. The operation is not a standard swap.

codeforcescompetitive-programming
CF 105400E - Is this Segment Tree Beats?

We are given the final state of an array where every element is between 1 and 10. This array did not start in this form. Instead, it was transformed by repeatedly applying global operations over the entire array.

codeforcescompetitive-programming
CF 105327E - Enigma of the Jewelry Case

We are given an $N times N$ grid of integers representing a square jewelry box. Each cell contains a distinct number of pearls, and in the intended correct configuration the values increase strictly from left to right along every row and also increase strictly from top to…

codeforcescompetitive-programming
CF 105327L - Lecographically Maximum

We are given an array of integers, and we are allowed to repeatedly apply an operation that swaps individual bits between two numbers at the same position. If we pick two indices and a bit position, we can exchange whether that bit is 0 or 1 between the two numbers.

codeforcescompetitive-programming
CF 105327D - Decrease the Boss Strength

We are given a starting value $N$, which we can think of as the “health” of a boss. We also have $M$ operations, called spells. Each spell has two parameters $ai$ and $bi$.

codeforcescompetitive-programming
CF 105325B - Expensive Transport

We are given a directed weighted graph with a distinguished start node, node 0. A traveller moves along edges, but the cost model is not the usual shortest path.

codeforcescompetitive-programming
CF 105325E - Game on a Graph

We are given an undirected graph whose vertices are labeled from 0 to n−1. The graph is split into connected components, and the structure changes as the game progresses because vertices are permanently removed.

codeforcescompetitive-programming
CF 105323D - 战至终章

We are given a set of nodes, each representing a demon. Every node has a required strength threshold, a reward strength increase, and a set of prerequisite “keys”.

codeforcescompetitive-programming
CF 105322A - Coin

We are tracking a single participant, Eric, who starts at a fixed position among $n$ people ordered by rank. Each round pairs people into disjoint matches.

codeforcescompetitive-programming