brain

tamnd's digital brain — notes, problems, research

41641 notes

CF 106440B - 凸包

We are given a set of distinct points in the plane. The task is to split these points into two non-empty groups, call them A and B, such that the convex hull formed by A and the convex hull formed by B do not touch at all, neither in their interiors nor on their boundaries.

codeforcescompetitive-programming
CF 106084J - Gas Station

The input describes a weighted tree. Each node represents an interchange and each edge represents a road with a travel distance. The graph is connected and there is exactly one simple path between any two nodes, so every trip between interchanges is uniquely determined.

codeforcescompetitive-programming
CF 106073A - A healthy menu

Each class reports how many students like each fruit, but this information is aggregated. For a fixed class and a fixed fruit, the value tells us how many distinct students in that class like that fruit.

codeforcescompetitive-programming
CF 106072A - Angry Birds

We are given a closed polyline drawn in the plane $z = 0$. In simpler terms, there are $n$ points in the XY-plane, and they are connected in a cycle: each point connects to the next, and the last connects back to the first.

codeforcescompetitive-programming
CF 106068H - Wanna win? Solve

We are working with a mutable array of integers, and each query asks us to relate one index in the array to all other indices using a distance condition that depends on the value stored at those indices.

codeforcescompetitive-programming
CF 106059J - Jigsaw of Perfect Squares

We are given a multiset of integers and we are allowed to permute them freely. After choosing an order, each value is placed into a position indexed from 1 to n.

codeforcescompetitive-programming
CF 106030B - osu!mania

I can’t reliably reconstruct Codeforces 106030B - osu!mania from the information provided here. The statement section is effectively empty, and this problem name has multiple possible interpretations in CF gym sets (typically involving rhythm lanes, falling notes, or grid…

codeforcescompetitive-programming
CF 106026C - 或非

We are given a complete graph on vertices labeled from 0 to n-1. Every pair of vertices is connected, and the weight of an edge is not a simple arithmetic value but a bitwise construction based on the labels of its endpoints.

codeforcescompetitive-programming
CF 106016K - Cookies

A line of children is given, each child carrying a rating. We must assign a positive number of cookies to every child, but the assignment cannot be arbitrary.

codeforcescompetitive-programming
CF 105922E - Eternal Feather

We are given a second-order linear recurrence sequence defined by two parameters $p$ and $q$. The sequence starts with $f(0)=0$, $f(1)=1$, and each next term is a linear combination of the previous two terms: $f(i)=p f(i-1)+q f(i-2)$. This is a Lucas-type sequence.

codeforcescompetitive-programming
CF 105920E - Ever Forever

We maintain a dynamic set of strings that changes over time. After every update, we must compute how many ordered pairs of distinct words currently in the set have the property that one word is a suffix of the other. In other words, at each moment we have a collection of strings.

codeforcescompetitive-programming
CF 105920A - Clan Battle

We are given a sequence of bosses that Kyouka attempts to defeat in a fixed order. Each boss type can appear multiple times, and these appearances are not independent: the availability of a boss in later “rounds” depends on what has already been defeated earlier in the…

codeforcescompetitive-programming
CF 105911C - Osiris

We are given Jotaro’s initial poker hand of five cards drawn from a standard 52-card deck. Each card has a rank from 1 to 13 (Ace through King), and each rank appears exactly four times in the deck.

codeforcescompetitive-programming
CF 105902E - Binary Banter: Counting Combinatorial Bits

We are given a number $n$, and for every integer $i$ from $0$ to $n$, we look at the entire $i$-th row of Pascal’s triangle. For each entry in that row, we take the binomial coefficient $binom{i}{j}$, reduce it modulo 2, and sum all those values.

codeforcescompetitive-programming
CF 105902D - Where's My Money?

We are given three people who travel together, and each of them pays a sequence of bills during the trip. Each test case provides three lists of positive amounts, one list per person.

codeforcescompetitive-programming
CF 105901J - Dictionary

We are given a fixed “dictionary string” S. Every possible word is simply a substring of S. Over q days, we are shown intervals on S. On day i, we take the substring S[li..ri] and consider it as a prefix pattern.

codeforcescompetitive-programming
CF 105901I - Bingo 3

We are asked to fill an $n times n$ grid with all integers from $1$ to $n^2$, each used exactly once. So the grid is just a permutation reshaped into a matrix. Now define a property for a threshold value $x$.

codeforcescompetitive-programming
CF 105901E - Colorful Graph

We are given an undirected graph with $n$ vertices and $m$ edges. Each edge must be assigned a color, using colors labeled from $1$ to $m$, and colors may be reused across edges.

codeforcescompetitive-programming
CF 105900J - Joining Xegos

We are given an array of values placed on a shelf, where each value represents a xego piece identified by a large integer.

codeforcescompetitive-programming
CF 105883M - ABAB

We are given a sequence of integers and asked to count ordered index quadruples $(i, j, k, l)$ such that the indices are strictly increasing and the values form an alternating pattern.

codeforcescompetitive-programming
CF 105883L - OR + AND

We are given an array of integers, and we repeatedly need to answer queries on subsegments. For any chosen subarray, we are allowed to split its elements into two groups. One group contributes the bitwise OR of its elements, the other contributes the bitwise AND of its elements.

codeforcescompetitive-programming
CF 105883J - HDZ Explosion

We are given a permutation of the numbers from 1 to n. Each position has a unique “height”, and there is exactly one position that contains the maximum value n. That position is the target we want to reach. A robot starts at an arbitrary index i. It has a movement range d.

codeforcescompetitive-programming
CF 105883I - Two Squared Equals Four

We are given a collection of distinct lattice points on the plane. From these points, any subset of four points is considered “good” if those four points can serve as the vertices of a square in any orientation, not necessarily axis-aligned.

codeforcescompetitive-programming
CF 105883H - Dilworth's Theorem

We are asked to construct a permutation of the numbers from 1 to n such that two classical order statistics of the sequence coincide: the length of the longest increasing subsequence and the length of the longest decreasing subsequence must be equal.

codeforcescompetitive-programming
CF 105883G - Fatalerror: Implementation Failed

We are dealing with a hidden 64-bit non-negative integer, and our only way to learn about it is by probing it with carefully chosen masks.

codeforcescompetitive-programming
CF 105883E - Another GCD

We maintain a dynamic collection of pairs of integers, where each pair has a value v and a weight w. The structure supports inserting pairs, removing existing occurrences, and answering queries of the form: given an integer k, find among all stored pairs those whose first…

codeforcescompetitive-programming
CF 105883A - Beautiful Substrings

We are given a string and asked to count how many of its substrings have a very specific three-part structure. A substring is called valid when it can be split into three consecutive equal-length blocks where the first and last blocks are identical, and the middle block is the…

codeforcescompetitive-programming
CF 105883B - Firefly's Favourite Problem

We are given a very large integer $N$ written in decimal form and a digit $x$ between 1 and 9. The task is to examine every positive integer $M$ from 1 up to $N$, count how many times the digit $x$ appears inside each $M$, and group numbers by that count.

codeforcescompetitive-programming
CF 105870B - Mashup

We are given a collection of contests. Each contest contains a fixed number of problems, and every problem has a difficulty label in a small range from 1 to K.

codeforcescompetitive-programming
CF 105870E - Polynomial Equation

We are given a structured polynomial identity involving two variables $x, y$ over a finite field. The core object is a bivariate polynomial $P(x,y)$, but it is not arbitrary.

codeforcescompetitive-programming
CF 105870D - Scary Subsequences

We are given three fixed strings over a small alphabet, and we treat them as reference sequences that define which subsequences are “available” in a constrained sense.

codeforcescompetitive-programming
CF 105870A - Beautiful Bracelets

We are given an array of integers representing colored beads. From this array we construct two related sequences and then compare them in a cyclic way, meaning we are allowed to rotate one of them before comparing.

codeforcescompetitive-programming
CF 105869L - Empty Triangles

We are given a set of points in the plane and multiple queries. Each query gives us three distinct points forming a triangle, and we need to determine whether there exists at least one other point from the set strictly inside that triangle.

codeforcescompetitive-programming
CF 105869K - Bitter

We are given a rooted tree where each node represents an element that may carry an identifier, but this identifier is not always “fixed” in how it should be interpreted.

codeforcescompetitive-programming
CF 105869J - Sumotonic Sequences

We are working with a sequence that is easier to understand through its differences rather than its raw values. Instead of reasoning directly about the sequence, we look at how each element changes compared to the previous one.

codeforcescompetitive-programming
CF 105869I - Random Remainders

We are given an array of positive integers. The task is to compute a global sum over all ordered pairs where each element in the array acts as a divisor in a modular expression.

codeforcescompetitive-programming
CF 105869H - Decent Path Around Bajtów

We are working with a graph where each state is a directed edge traversal decision, not just a vertex value. For every vertex $v$, and every neighbor $u$ adjacent to it, we define a quantity $L(v, u)$ which represents the longest possible walk that starts at $v$ and is forced…

codeforcescompetitive-programming
CF 105869G - Road Trip

We are given a tree where each edge has an implicit distance, and a fixed parameter $c$ representing how far a car can travel on a full tank. When moving along the tree, a refuelling event is required whenever the remaining fuel is insufficient to continue along the next edge.

codeforcescompetitive-programming
CF 105869E - Gambling

We are given a process defined on pairs of positive integers $(a, b)$ with $a < b$. From a state $(a, b)$, the system either terminates immediately with probability $1/2$, or transitions to a new state $(2a, b - a)$ with probability $1/2$.

codeforcescompetitive-programming
CF 105869D - Money in the Hat

We are dealing with a process where a set of integers from 1 to n exists, and we randomly select a subset of size k from it. From that subset, we are interested in the maximum element.

codeforcescompetitive-programming
CF 105869B - ICFC World Finals

We are given a rooted tree, and the task is to imagine drawing it on a grid under a very specific geometric rule. Each subtree is drawn inside a rectangular bounding box, and different subtrees attached to the same parent must be placed inside disjoint bounding boxes.

codeforcescompetitive-programming
CF 105864C - Кофебол

We are given a list of athletes, each with a strength value, and a sorted list of coffee cups, each with an increasing strength requirement. A cup can only be drunk by an athlete whose strength is at least the cup’s requirement.

codeforcescompetitive-programming
CF 105864M - Турнир покемонов

We are given a collection of pokémons, each described by two numbers: its initial strength and its price. We are allowed to pick exactly one pokémon as our champion before the tournament starts.

codeforcescompetitive-programming
CF 105864L - Медианы 2

We are given two arrays of the same odd length, and every value appearing in either array is unique globally. Because of this uniqueness, sorting each array produces a well-defined ordering with no ties, and the median is simply the element at position $(n+1)/2$.

codeforcescompetitive-programming
CF 105864J - Роботы в пещере

We are given a one-dimensional cave split into n vertical columns. Each column has a ceiling height h[i]. Over time, the ceiling in every column drops uniformly: at each second, every positive height decreases by one.

codeforcescompetitive-programming
CF 105864I - Воронежини животнини

We are given a permutation of numbers from 1 to n, but it is hidden. Instead of the permutation itself, we only know a derived array of length n − 1 where each value is the maximum of two consecutive elements in that hidden permutation.

codeforcescompetitive-programming
CF 105864H - Черепашка

We are given a length $n$ array, and from it we build an $n times n$ grid where every row is a cyclic shift of the previous one. The first row is the array itself, and each next row shifts all elements one position to the left, wrapping the first element to the end.

codeforcescompetitive-programming
CF 105864G - Лисица на древе

We are given a tree, meaning a connected graph with no cycles. Two special vertices are marked, a starting point $s$ and a target $t$. A fox moves on this tree, but its movement rules are stronger than normal adjacency.

codeforcescompetitive-programming
CF 105864E - Длинный остров

We are working on a dynamic grid where each cell stores an integer height. A cell is considered land only if its current height is strictly positive. Connectivity is defined in the usual grid sense, where movement is allowed only between cells sharing a side.

codeforcescompetitive-programming
CF 105864D - Хорошие раскраски 6

We are given a very large grid that is never explicitly revealed. Each cell of this grid is painted with one of three colors, and we are guaranteed that no two side-adjacent cells share the same color.

codeforcescompetitive-programming
CF 105864A - Кроссворд

We are given four short lowercase strings and need to determine whether it is possible to place all of them into a fixed grid as two horizontal words and two vertical words.

codeforcescompetitive-programming
CF 105863B - Numbers on the Blackboard

Codeforces 105863B: Numbers on the Blackboard

codeforcescompetitive-programming
CF 105863H - Maximizing Pairs

We are given a multiset of integers. The task is not about sorting or selecting elements directly, but about understanding how these values interact when forming pairs whose sum is fixed.

codeforcescompetitive-programming
CF 105863A - Reflecting

We are working on a coordinate system where each move is not a standard step but a reflection-like transformation.

codeforcescompetitive-programming
CF 105863G - A Counting Problem

We are given a fixed number of positions and a range of values, and we conceptually assign values from this range to each position.

codeforcescompetitive-programming
CF 105863E - Partitioning

We are given an array of positive integers and we need to evaluate a function that depends on splitting this array into contiguous blocks.

codeforcescompetitive-programming
CF 105863D - Counting Minimal Graphs

We are given an undirected graph structure implicitly described through distances from a fixed root node, node 1.

codeforcescompetitive-programming
CF 105851K - 最小生成树

We are asked to count labeled undirected graphs on $n$ vertices where each possible edge is either absent or assigned a weight in $[1, k]$, under a specific structural constraint about minimum spanning trees.

codeforcescompetitive-programming
CF 105851J - 四舍五入

The task revolves around applying a precise rounding rule to numeric inputs. Each input value is given in a textual form, and we are required to transform it into an integer according to standard rounding behavior, where the fractional part determines whether we move the value…

codeforcescompetitive-programming
CF 105851H - Link与矩阵除法

I can’t write a correct editorial from just “H” and an empty statement. Codeforces 105851H (“Link与矩阵除法”) clearly has missing problem content in your prompt, so there’s no way to reconstruct: - what the input actually represents (matrix operations, graph…

codeforcescompetitive-programming
CF 105851G - 萤火虫难题

I can’t write a meaningful editorial for this because the actual problem content is missing. Right now the “Problem Statement” section only contains the single character G, and there is no description of the input, output, or rules.

codeforcescompetitive-programming
CF 105851E - 布置WAP

The problem statement for Codeforces 105851E - 布置WAP is missing in what you provided. Right now there’s no description of the task, inputs, outputs, or constraints, so any attempt to write a correct editorial would be guesswork.

codeforcescompetitive-programming
CF 105851D - 最近公共祖先

The task is about maintaining and querying ancestry relationships in a rooted tree. We are given a connected acyclic graph, and we interpret one node as the root of the structure.

codeforcescompetitive-programming
CF 105851A - 删除01串

The problem statement in your prompt is effectively empty (only the title “删除01串” without any input/output definition or constraints), so there isn’t enough information to reconstruct what is being solved.

codeforcescompetitive-programming
CF 105838C - Cowardly Lizard IV

We are given an array of positive integers and many range queries. For each query, a segment from index $l$ to $r$ is chosen. Inside this segment, we are allowed to pick a split point $k$ such that $l le k < r$.

codeforcescompetitive-programming
CF 105838M - Dye Your Color

We are given a tree with $n$ nodes. Each node represents a region, and each region has a value that depends on whether it is currently marked as colored or not. Initially all nodes are uncolored and each node $i$ has a base value $ai$.

codeforcescompetitive-programming
CF 105838K - ruskal's Reconstruction Number

We are given a positive integer written as a decimal string. In one move, we are allowed to choose a single pair of adjacent digits and swap them. We may perform at most one such swap, or choose to do nothing.

codeforcescompetitive-programming
CF 105838I - We Must Be Together No Matter How Far

We are given a connected undirected graph with $n$ islands and exactly $n$ roads. Every road has cost 1, and the same road can be traversed multiple times, paying its cost each time.

codeforcescompetitive-programming
CF 105838J - Skill Tree

We are given a rooted tree where node 1 is the root. Each node represents a skill, and each skill has a value called its power.

codeforcescompetitive-programming
CF 105838G - Who Likes Mathematics is not Boki-chan

We are given a very large interval of integers, from $L$ to $R$, where $R$ can be as large as $10^{18}$. The task is to count how many numbers inside this interval satisfy a digit-based property: when you look at the decimal representation of a number, the absolute difference…

codeforcescompetitive-programming
CF 105838F - Boki-chan Who Dislikes Mathematics

We are working on a grid of all pairs $(i, j)$ where $1 le i le n$ and $1 le j le m$. For each pair, we look at the greatest common divisor of $i$ and $j$. From that gcd value $g$, we compute the number of divisors of $g$, written as $d(g)$.

codeforcescompetitive-programming
CF 105838E - Creative Boki-chan

We are given a sequence $b$ whose length is $n$. This sequence was originally produced from an unknown integer array $a$, but during the process, the array was modified in a structured way. The hidden construction is the following.

codeforcescompetitive-programming
CF 105838D - Cowardly Lizard V

We are given several independent test cases. In each test case, there are $n$ caves labeled from 1 to $n$, and a sequence of $n$ planned inspections, where each inspection targets one cave. The sequence is fixed and known in advance.

codeforcescompetitive-programming
CF 105838B - Lunch!

We are given a sequence of exactly three integers. We are allowed to rearrange these three values using swaps between any two positions, and after doing so we want the resulting arrangement to satisfy a very specific pattern: the first element must be strictly greater than the…

codeforcescompetitive-programming
CF 105837A - Balls and Bins

We are given a collection of bins. Each bin starts with some number of balls and has a maximum capacity. The key operation in the process is that whenever a bin becomes full, it is removed from active consideration and its entire content is transferred into a shared reserve.

codeforcescompetitive-programming
CF 105837E - Sequence Evaluation

The problem defines a sequence built from a very structured combinatorial recurrence. Each term is formed by considering all ways to decompose an integer into ordered or unordered collections of positive integers, and then aggregating weights derived from those decompositions.

codeforcescompetitive-programming
CF 105837B - Median of Medians

We are working with a permutation of the integers from 1 to 3N, split conceptually into three consecutive segments of equal size N.

codeforcescompetitive-programming
CF 105833D - Double String

We are given a single lowercase string and we are asked to count special substrings that have a very rigid structure.

codeforcescompetitive-programming
CF 105761C - Soccer Standing Table

We are given five integers that describe a soccer team’s season statistics, but the order of these integers is scrambled. We know they correspond to matches played, wins, draws, losses, and total points, but we do not know which number is which.

codeforcescompetitive-programming
CF 105761A - Odd/Even Strings

We are given a single string consisting only of lowercase English letters. The task is to classify this string based on how many times each distinct letter appears. A string is called odd if every character that appears in it occurs an odd number of times.

codeforcescompetitive-programming
CF 105761K - Really Nerdy Game

We are given a circular board with positions labeled from 1 to n. A token starts at position 1. Each move consists of rolling a fair die with faces from 1 to d, and moving forward that many steps along the circle. If we go past n, we wrap back to 1. Some positions are special.

codeforcescompetitive-programming
CF 105761J - Ultimate Commitment Forever

We are working on a very large integer grid where each point has four-neighbor movement, up, down, left, and right. Some grid points are blocked because construction is happening there, and these blocked points cannot be visited.

codeforcescompetitive-programming
CF 105761I - K-gap Subsequence

We are given a sequence of integers and a threshold value k. From the sequence, we want to pick a subsequence, meaning we keep some elements without changing their order, and we try to make it as long as possible.

codeforcescompetitive-programming
CF 105761H - Discord Daisy Chain

We can model the system as a directed graph where each channel is a node. Each bot acts like a small forwarding rule: it listens on exactly one source channel, and when that channel receives a message, the bot forwards the message to a fixed list of destination channels.

codeforcescompetitive-programming
CF 105761G - Toboggan Ride

We are given a straight path from position 0 to position L. Along this line there are special points called boost stations.

codeforcescompetitive-programming
CF 105761F - Food Poisoning

We are trying to identify one unknown “bad” restaurant among n candidates. Each week we are allowed to choose any subset of restaurants and observe a binary outcome: if the bad restaurant is inside the chosen subset, Mikey gets sick that week, otherwise he does not.

codeforcescompetitive-programming
CF 105761E - Tutorial Groupings

We are given a list of students, each with a distinct knowledge level. The goal is to partition them into contiguous groups after sorting by knowledge level, so that each group satisfies two constraints: the range inside the group, defined as maximum minus minimum knowledge…

codeforcescompetitive-programming
CF 105761D - Caterpillar Walk

We are given a skyline-like city made of axis-aligned rectangular buildings placed on top of the x-axis. Each building starts at some x-coordinate, extends to the right for a fixed width, and rises vertically to a given height.

codeforcescompetitive-programming
CF 105761B - Fiborooji Sequence

We are given a starting pair of single-digit numbers, where at least one is non-zero. From this pair, we generate a sequence where each next value is formed exactly like Fibonacci: sum of the previous two values.

codeforcescompetitive-programming
CF 105837D - Indivisible Inversions

We are given a permutation-like array where inversions matter, and the central object of interest is the number of inversions inside a subarray. For any segment $[i, j]$, let $f(i, j)$ be the number of pairs $i le a < b le j$ such that $p[a] p[b]$.

codeforcescompetitive-programming
CF 105838L - Greedy World

We start with a multiset of exactly $k$ numbers. Out of these, $k-1$ copies are equal to some value $x$, and a single element equals $y$. So initially the structure is extremely uniform except for one “disturbance”.

codeforcescompetitive-programming
CF 105838H - Defense Deployment

We are given multiple independent test cases. Each test case describes a set of points on an infinite 2D grid. Every point represents a tower placed at integer coordinates.

codeforcescompetitive-programming
CF 105838A - A New Journey

Each test case describes a group of candidates being evaluated on two independent dimensions: performance in a series of training contests, and performance in a problem-solving assessment outside contests.

codeforcescompetitive-programming
CF 105851I - 最小LCM

I can’t reliably write a correct editorial for this because the actual problem statement is missing. Right now you’ve provided only the title (“最小LCM”) and empty Input/Output sections, which isn’t enough to reconstruct the intended task.

codeforcescompetitive-programming
CF 105851F - 腐蚀与膨胀

The statement content is missing from your prompt (only the title “腐蚀与膨胀” is present, with no input/output or description). Without the actual rules of the process, there’s no way to reconstruct the intended algorithm or write a correct Codeforces-style editorial.

codeforcescompetitive-programming
CF 105851C - 砝码

I’m missing the actual problem content for Codeforces 105851C - 砝码. The statement section you provided is empty, so there’s no way to reliably reconstruct the task, constraints, or required solution without guessing.

codeforcescompetitive-programming
CF 105863F - Modular Madness

We are given a sequence of numbers and a sequence of modulo operations that are applied to them. Each time a number is processed with a modulus value, it is replaced by its remainder.

codeforcescompetitive-programming
CF 105863C - Leafy Distance

We are given a tree, meaning a connected graph with no cycles. Some vertices of this tree are leaves, vertices with degree one.

codeforcescompetitive-programming
CF 105864K - Медианы 1

We are given two arrays of the same odd length, and every number appearing anywhere in the input is globally unique. The only operation allowed is to pick an index and swap the elements of the two arrays at that position.

codeforcescompetitive-programming
CF 105864F - Хеширование

We are given a sequence of integers and a fixed way of turning any contiguous segment into a number using a rolling base.

codeforcescompetitive-programming