brain

tamnd's digital brain — notes, problems, research

43815 notes

CF 105575I - 心意无向,前程有向

We are given a graph structure with directed constraints and undirected relationships over the same set of vertices.

codeforcescompetitive-programming
CF 105570G - Soccer (soccer)

We are given a polyline that represents a highway. It is defined by a sequence of points, and consecutive points are connected by straight segments, forming a broken line that always moves strictly to the right in the x-direction.

codeforcescompetitive-programming
CF 105562M - Mouse Trap

We are given a convex polygon described by its vertices in counterclockwise order. Inside this polygon, we imagine a point chosen uniformly at random.

codeforcescompetitive-programming
CF 105562G - Glued Grid

We are given an $h times w$ grid representing a sliding puzzle. Each cell contains a tile label, with the bottom-right cell containing the empty space labeled as $0$.

codeforcescompetitive-programming
CF 105556H - AGAIN! Permutation with MAX Score

We are given a permutation of numbers from 1 to n, and we are allowed to choose a positive integer k. For each position i, we compute the prefix sum up to i, and we count position i as “good” if that prefix sum equals k times the value stored at that position.

codeforcescompetitive-programming
CF 105400A - Spilled Milk I

We are given a single integer $N$, which is the product of some hidden sequence of dice rolls. Each roll was a standard die, so every factor in the hidden sequence is an integer from 1 to 6.

codeforcescompetitive-programming
CF 105400I - Lost

We are given three numbers per test case. These numbers come from four possible values computed from a hidden pair of integers $a$ and $b$: their bitwise AND, OR, XOR, and their sum.

codeforcescompetitive-programming
CF 105329A - Три числа

Three piles of candies are given, and each pile can independently be either left unchanged or doubled once. After choosing these operations, the total number of candies across all three piles is fixed.

codeforcescompetitive-programming
CF 105327G - Geography of Rivers

We are given a rooted construction of a single river system that ultimately merges all sources into one final river flowing into the sea. Each source starts as an independent river with a fixed initial amount of water and its own identifier as its name.

codeforcescompetitive-programming
CF 105327K - Karamell

We are given a multiset of bag sizes, where each bag contains a certain number of identical items. The bags must be processed in a chosen order, one by one. When processing a bag, its entire content is given to whichever of two people currently has fewer total items.

codeforcescompetitive-programming
CF 105327J - Journey through Colors

We are given an undirected multigraph where each edge connects two cities and carries a color label. The task is to construct a closed walk that uses every edge exactly once, so structurally this is an Euler tour requirement, but with an additional restriction on the order…

codeforcescompetitive-programming
CF 105327A - Attention to the Meeting

We are scheduling a meeting with $N$ speakers. Each speaker talks for the same integer number of minutes, and between every pair of consecutive speakers there is a fixed 1-minute break.

codeforcescompetitive-programming
CF 105325C - Brothers

We are given a row of dominoes placed from left to right at strictly increasing positions. Each domino has a height, and when it falls it can push everything to its right that lies within its reach, where reach means the interval from its position up to its position plus height.

codeforcescompetitive-programming
CF 105322F - Tetris

We are given a rectangular grid where each cell is either free or blocked. The task is to place as many tetrominoes as possible on the free cells.

codeforcescompetitive-programming
CF 105321G - Garlands

We are given a single string consisting of uppercase letters, and we want to form as many disjoint groups of exactly three letters as possible. Each valid group must be rearranged into either the word “TAP” or the word “TUP”.

codeforcescompetitive-programming
CF 105321N - New Dimensions

We are given a list of possible positive integer lengths. From this list, we must choose three values, allowing repetition, and interpret them as the three dimensions of a hollow rectangular box.

codeforcescompetitive-programming
CF 105321A - Advanced tic-tac-toe

The game is played on a fixed 3×3 grid, but instead of thinking about it as a board, it is easier to treat it as nine indexed positions from 1 to 9. Two players alternate turns, X going first and O second, placing their symbol into an empty cell.

codeforcescompetitive-programming
CF 105321D - Duo

Three players participate in a simple alliance game where exactly two of them form a team and the remaining player competes alone. Each player has a fixed integer score.

codeforcescompetitive-programming
CF 105319B - Broken String

We are given a string made of decimal digits. The only allowed operation is to pick a position and move its digit by one step up or down, staying within the range 0 to 9.

codeforcescompetitive-programming
CF 106030D - 有限小数

The task revolves around deciding whether a given rational number can be represented as a terminating decimal. In other words, for each provided fraction, we want to determine whether its decimal expansion ends after a finite number of digits instead of continuing indefinitely.

codeforcescompetitive-programming
CF 106030K - 小 C 的神秘图形

The statement for “Codeforces 106030K - 小 C 的神秘图形” is not actually included in what you provided.

codeforcescompetitive-programming
CF 106026I - Emotional Flutter

We are given three fixed convex polygons in the plane. Each polygon represents a region where one of three point masses must be placed.

codeforcescompetitive-programming
CF 106026D - Fever Dash

We are given a rhythm game where notes arrive at specific times. Each note contributes a base score and also contributes energy toward a “Fever gauge”. Once this gauge reaches a threshold, we are allowed to activate a Fever mode.

codeforcescompetitive-programming
CF 106026H - 快速排列置换

We are given a permutation $a$ of size $n$, so it is a bijection from positions $1 ldots n$ to values $1 ldots n$.

codeforcescompetitive-programming
CF 106026G - Good Number

We are given an integer range $[L, R]$, and for every integer $x$ in this range we look at its decimal representation and count how many times each digit $0$ to $9$ appears. Let that count for digit $i$ be $F(x, i)$.

codeforcescompetitive-programming
CF 106016M - Random Spanning Tree

We are working with labeled trees on vertices from 1 to n. Among all spanning trees, we only keep those in which the unique path between vertex 1 and vertex n is a diameter of the tree, meaning no other pair of vertices is farther apart than 1 and n are.

codeforcescompetitive-programming
CF 106016J - Arranged Marriage

We are given a sequence of families, each family contributing a number of boys and a number of girls. For any contiguous segment of families, we gather all boys and girls from those families.

codeforcescompetitive-programming
CF 106016H - Median Gcd

We start with every integer from l to r placed on a board. At each step we look at all remaining numbers, compute their greatest common divisor, add it to a running score, then delete the median element of the current set.

codeforcescompetitive-programming
CF 106016G - Mexy Permutation

We are asked to construct a permutation of numbers from 1 to n such that a derived array, formed from adjacent differences, avoids having many small positive integers.

codeforcescompetitive-programming
CF 106016F - Split

We are given an array of non-negative integers. The task is to split the elements into two non-empty groups such that every element belongs to exactly one group.

codeforcescompetitive-programming
CF 106016D - Least Uncommon Divisor

We are given a fixed number $x$ and a long list of values $ai$. For each $ai$, we want to find the smallest positive integer $z$ that satisfies two conditions: it must divide $x$, and it must fail to divide $ai$.

codeforcescompetitive-programming
CF 106016B - Colored Tree

We are given a tree where each vertex initially carries a color label. Then those labels are randomly permuted and reassigned to the vertices, so the multiset of colors stays the same but their locations become uniformly random.

codeforcescompetitive-programming
CF 106016A - The Beauty Of Homs

The input describes a single prompt that is always the same idea, a request to “tell a joke”. There is no hidden structure inside it that affects the answer, and no computation is required on the text.

codeforcescompetitive-programming
CF 106015O - The Echoing Scroll of Fate

We are given a mutable string that represents a “scroll”. Over a sequence of operations, we repeatedly select a substring and inspect its internal repetition structure.

codeforcescompetitive-programming
CF 106015N - The Squirrel's Scattered Nuts

We are given a collection of integers, each representing the “energy” of a nut. The task is to choose two distinct nuts such that the sum of their energies is odd, and among all such valid pairs, return the maximum possible sum.

codeforcescompetitive-programming
CF 106015M - Halzoom's strange feeding system

We are simulating a layered feeding system where food values grow over time across a line of cats. There are $M$ cats in a row and $N$ days. On the first day, every cat starts with exactly 1 gram of food.

codeforcescompetitive-programming
CF 106015J - Halzoom's Coffee Grid

The grid represents a field of values, where each cell contains a non-negative number describing a “smell strength”.

codeforcescompetitive-programming
CF 106015L - Gamal's Final Riddle

We are given several independent test cases. In each one, there is an array of integers, and we must count how many pairs of indices produce a special condition based on the least common multiple of the two values.

codeforcescompetitive-programming
CF 106015I - The Auntie Whispers' Labyrinth

We are given a graph where intersections are nodes and streets are undirected edges. Each edge has a success probability expressed as a percentage, meaning if you traverse that street you survive with that probability and fail with the complementary risk.

codeforcescompetitive-programming
CF 106015H - Whispers of Light in the Unknown

We are given a collection of N pieces of magical moss, where each piece contributes a fixed number of hours of light once used in the lantern.

codeforcescompetitive-programming
CF 106015G - The Unseen Geometry of the Unknown

We are given an isosceles triangle described only by its geometric parameters: the two equal sides have length $L$, and the base has length $B$.

codeforcescompetitive-programming
CF 106015F - The Spirit-Oak's Resonance

We are given a static array of integers, where each position represents a Spirit-Oak and its resonance value. After the array is fixed, we must answer many independent queries.

codeforcescompetitive-programming
CF 106015E - The Beast's Encoded Grid

We are given a rectangular grid of lowercase letters and an additional “target” string. The target string defines required letter counts: for each character, we must know how many times it appears in that string.

codeforcescompetitive-programming
CF 106015B - Adhoom and Halzoom Peculiar Pact

We are given a very large interval $[L, R]$, and we want to count pairs $(a, b)$ such that both numbers lie in this interval and $a le b$. The real restriction is a bit unusual: it connects modular arithmetic with a bitwise expression.

codeforcescompetitive-programming
CF 106015D - The Beast's Shadowy Game

We are given a multiset that initially contains an even number $N$ of identical values, all equal to 1. Two players manipulate this multiset in turns. In each round, Player A removes two arbitrary numbers from the multiset.

codeforcescompetitive-programming
CF 106015C - The Whispering Tree's Path

We are given a tree with up to 500,000 nodes. Each node stores a single digit from 1 to 9. The tree is rooted at node 0, but the root only matters for structure, not for direction of traversal. The task is to choose any two nodes and consider the unique simple path between them.

codeforcescompetitive-programming
CF 106007L - Equalize

We are given an array of length n and a fixed segment size m. In one operation we pick a contiguous block of exactly m elements and apply a bitwise OR with a query value x to every element in that block.

codeforcescompetitive-programming
CF 106007M - Maximum Or Permutation

We are asked to arrange the numbers from 1 to n in a circular order, meaning we place them in a line but also connect the last element back to the first.

codeforcescompetitive-programming
CF 106007K - And X Elements

We are simulating a process over an array where a single integer value v starts at zero and is updated step by step. At each position i, we must apply exactly one of two bitwise operations using the current array element a[i].

codeforcescompetitive-programming
CF 106007I - Reverse and Remove

We are given a sequence of numbers and a number of operations to perform on it. Each operation always removes the current first element of the sequence, and then reverses whatever remains.

codeforcescompetitive-programming
CF 106007H - Minimum Path

We are given several test cases, each consisting of an array indexed from 1 to n. We start at index 1 and must end at index n. The key movement rule is that from any current index i, we are allowed to jump to any other index j as long as their positions differ by at most 2.

codeforcescompetitive-programming
CF 106007G - Nim Game In Byteland

We are given a directed graph with $n$ nodes, where each node represents a city and has at most two outgoing edges. Alice starts at city $1$ and wants to reach city $n$.

codeforcescompetitive-programming
CF 106007E - Clean White Paths

We are given a tree where every vertex is colored either white or black. Over time, we perform updates that gradually turn vertices from white into black. After each update, we must compute a value that depends on how white vertices are distributed inside the tree.

codeforcescompetitive-programming
CF 106007A - GCD MEX

We are asked to construct, for each test case, a small integer array $a$ with at most $n$ elements. From this array we form another collection $b$ by taking the greatest common divisor of every pair of distinct elements in $a$.

codeforcescompetitive-programming
CF 106007D - Master of the Arena

We are given a directed tournament-like structure on n fighters, but not all outcomes are fixed. For every pair of fighters, either one is known to always beat the other, or the result is left undecided and we are free to assign it.

codeforcescompetitive-programming
CF 106007B - Random Shuffle?

We are given an array of length $n$. We repeatedly perform an operation $m$ times, and each time we append one number to a growing sequence written on paper. Each operation has three random layers.

codeforcescompetitive-programming
CF 105992M - 魔法使考核

We are given an array of $n$ magical orbs, all starting at value zero. The goal is to transform them into a target array $a$, where each position $i$ must end exactly at $ai$. Two operations are available.

codeforcescompetitive-programming
CF 105992K - 神之一手

We are simulating a probabilistic board process that runs over many rounds, where each round can instantly end the game depending on rare failure events.

codeforcescompetitive-programming
CF 105992J - 画圈

We are given an undirected simple graph where each edge is labeled either white or black. The graph is connected when we ignore colors. One operation lets us pick any simple cycle in the graph, with the restriction that the cycle must contain at least one white edge.

codeforcescompetitive-programming
CF 105992I - 真相

We are given a rooted tree with root fixed at node 1. Each node has a person who permanently behaves in one of two ways: either they always tell the truth or they always lie.

codeforcescompetitive-programming
CF 105992G - 矩阵

We are asked to fill an $n times n$ grid with distinct positive integers, all bounded by about $n^2 + 40n$, so essentially a tight range just slightly larger than the number of cells.

codeforcescompetitive-programming
CF 105992H - V 我 112.5

We are given a single integer x, which represents a percentage tax or surcharge applied to a fixed base cost. The base cost is always 50 units. The final amount to pay is the base cost plus an additional percentage of that base cost.

codeforcescompetitive-programming
CF 105992E - Djangle 的数据结构

We are maintaining an array of positive integers under two types of range operations. The first operation replaces every element in a segment with a fixed value.

codeforcescompetitive-programming
CF 105992C - 饺子

We are given several independent datasets. In each dataset there are multiple kinds of dumplings. Each kind has a limited supply, and each eaten dumpling from that kind gives a reward that decreases as you keep eating more from the same kind.

codeforcescompetitive-programming
CF 105992B - 审判

We are given a large number of attack types, say $k$ of them. A “scenario” is defined by a vector of non-negative integers $(a1, a2, dots, ak)$, where each $ai$ is at most $n$, and the total sum $a1 + cdots + ak$ does not exceed $M$.

codeforcescompetitive-programming
CF 105992D - 与或博弈

We are given two non-negative integers a and b, and a target pair x and y. Two players alternate turns, with the first player (gsh) trying to transform the current state into exactly (x, y) within a bounded number of moves, while the opponent (AI) tries to prevent this from…

codeforcescompetitive-programming
CF 105986L - 等价交换

We are given a system of items, where each item can eventually become “energized” if it is either directly chosen at the start or can be produced through recipes.

codeforcescompetitive-programming
CF 105986K - Capoo's stack

We are given multiple independent test cases. In each test case there are several Capoo, each with a positive strength value. We want to choose some of them and arrange them into a vertical stack. The stack has a constraint that only the top Capoo is unrestricted.

codeforcescompetitive-programming
CF 105986B - 最短路图

We are given a set of nodes where node 1 is the source of all distances, and we are also given a multiset of weighted edges whose endpoints are completely flexible.

codeforcescompetitive-programming
CF 105986D - 恋恋的心跳大冒险 Ⅲ

The tree describes a rooted structure where every node carries an integer label, interpreted as a “gem energy level”. For any node $u$, if we choose $u$ as a starting point, we look at all nodes in its subtree and consider the multiset of their energy values.

codeforcescompetitive-programming
CF 105986H - 最大节点和

We are given a perfect full binary tree of height $n$. This means the tree has $n$ levels, the root is at level $n$, each internal node has exactly two children, and all leaves are at level $1$. Every leaf is assigned either $0$ or $1$.

codeforcescompetitive-programming
CF 105981K - Yet Another Connecting Problem

The statement you provided is incomplete, so I can’t reconstruct what “Yet Another Connecting Problem” is asking or derive a correct solution. Right now I only see the title and some metadata, but the actual input format, constraints, and task description are missing.

codeforcescompetitive-programming
CF 105981L - Yet Another Another Connecting Problem

The statement you provided is incomplete: There is no actual description of what the problem asks, so it’s impossible to write a correct editorial or derive any solution.

codeforcescompetitive-programming
CF 105981J - Uniform Random Descent Process

We are given a process that repeatedly shrinks a single integer. Starting from a value m = n, one operation replaces it with a uniformly random integer from the range [0, m-1]. The process stops once the value becomes 0.

codeforcescompetitive-programming
CF 105981I - The Dream-Quest

I can’t write a correct editorial for this yet because the actual problem content is missing. Right now, the statement only shows the title “The Dream-Quest” with no description of what the input represents, what needs to be computed, or any constraints.

codeforcescompetitive-programming
CF 105981H - Simai

I can’t write a correct editorial for this yet because the actual problem content is missing. Right now I only see the label “H” with empty input/output sections, so there’s no way to reconstruct what Simai is asking, what the operations are, or what needs to be computed.

codeforcescompetitive-programming
CF 105981G - Portal 2

I can’t reliably write a correct Codeforces-style editorial from this because the actual problem statement for 105981G - Portal 2 isn’t included (it only shows “G”).

codeforcescompetitive-programming
CF 105981E - Neuro's New Game

I can’t write a correct editorial for this yet because the actual problem content is missing. Right now the statement only shows the title (“Neuro’s New Game”) but no description of the rules, input format, or what needs to be computed.

codeforcescompetitive-programming
CF 105981F - Portal

I can’t write a correct editorial for this problem yet because the actual statement content is missing. Right now, all that is provided is the label “F” and the title “Portal”, but no description of the input format, output format, constraints, or rules of the system.

codeforcescompetitive-programming
CF 105981A - A Slide B Slide

I can’t reliably reconstruct Codeforces Gym 105981A from the available statement text, because the problem statement is truncated and OCR-garbled in multiple critical parts (especially the definition of the operations/constraints involving the sequences and what exactly is…

codeforcescompetitive-programming
CF 105981D - Keine's Prefix Sum

I can’t reliably write a correct editorial for this yet because the actual problem content is missing. Right now the prompt only shows the title “Keine’s Prefix Sum” but no statement, constraints, or input-output behavior.

codeforcescompetitive-programming
CF 105981B - Bricked Blast Furnaces

I can’t write a correct editorial for this problem yet because the actual problem statement content is missing (it only shows “B” with empty input/output).

codeforcescompetitive-programming
CF 105977M - 致谢

The problem gives a fixed historical table describing 11 editions of a programming contest series in Fujian. Each edition has an organizing university, and each university is associated with a short English abbreviation.

codeforcescompetitive-programming
CF 105977I - 割点

We are asked to construct an undirected simple connected graph on vertices labeled from 1 to n, with very specific structural constraints tied to articulation points and vertex degrees. For every vertex except 1 and n, we are given a binary indicator.

codeforcescompetitive-programming
CF 105977J - 构造大师周三金

We start with a positive integer and are allowed to repeatedly modify it. One move consists of choosing a number that divides the current value, adding it to the current value, and never using the same chosen addend twice across the whole process.

codeforcescompetitive-programming
CF 105977L - 众数

We are given a sequence of integers, and we process it incrementally by prefixes. For each prefix, we conceptually look at every non-empty subset of its indices.

codeforcescompetitive-programming
CF 105977E - 卡牌游戏

We are given a sequence of $2n$ card values arranged in a fixed top-to-bottom order. After this, the cards are dealt strictly by position: cards in odd positions go to one player and cards in even positions go to the other player.

codeforcescompetitive-programming
CF 105977H - 难以控制的滑板火箭

We are given a grid of size $n times m$ where each cell is either free or blocked. The start is always the top-left cell $(1,1)$ and the goal is the bottom-right cell $(n,m)$. Movement is not the standard four-direction grid walk.

codeforcescompetitive-programming
CF 105977G - 炒股高手

The problem gives a sequence of stock prices over $n$ days, but the prices are encoded in logarithmic form. On day $i$, the actual price is $e^{ai}$, where $ai$ is a positive integer.

codeforcescompetitive-programming
CF 105977B - XCPC

We start with a pile of identical base tokens, each initially considered as a “bronze level” unit worth 1 point. There are four possible grades of items: iron, copper, silver, and gold, with values 1, 2, 3, and 4 respectively.

codeforcescompetitive-programming
CF 105977D - 二叉树

We are given an undirected tree. This tree is not arbitrary in origin: it is formed by taking two perfect binary trees and connecting them with exactly one extra edge. After this connection, the structure is still a tree, but it is no longer a perfect binary tree.

codeforcescompetitive-programming
CF 105977A - We are watching you!

We are given several independent test cases. In each test case, there is a string S consisting of lowercase letters, and a second sequence of integers c[i] that describe values assigned to states of a deterministic automaton built from suffixes of S.

codeforcescompetitive-programming
CF 105973K - Math Madness

We are given several test cases. In each test case, we receive an array of integers, and we must count how many index pairs $(i, j)$ with $1 le i le j le n$ satisfy a certain arithmetic condition involving greatest common divisor and least common multiple of the two chosen…

codeforcescompetitive-programming
CF 105973J - Sublime Replacement

We are given an array where some positions are already fixed and some positions are marked as unknown with value −1. We are allowed to replace each unknown position with any positive integer up to $10^9$.

codeforcescompetitive-programming
CF 105973I - Statue on a Permutation

We are given a permutation that we are allowed to construct, and a starting position for a token placed on that permutation. From that starting point, two players alternately move the token.

codeforcescompetitive-programming
CF 105973G - MEX-imum Beauty

We are given an array, and we look at every contiguous subarray. For each subarray, we do a two-stage transformation. First, we replace it by its sequence of prefix maximums.

codeforcescompetitive-programming
CF 105973E - The Perfect Spider Web

We are given a convex polygon in the plane, described by its vertices in counter-clockwise order. Each edge of the polygon connects consecutive vertices, and the last vertex connects back to the first. We must choose a point strictly inside this polygon.

codeforcescompetitive-programming
CF 105973F - Divisible Perfection

We are given a string of digits, and we treat every contiguous substring as a number in base 10. The requirement is extremely strong: for every possible substring, the integer value formed by that substring must be divisible by the length of that substring.

codeforcescompetitive-programming
CF 105973B - Red Dead Redemption 2

We are given several test cases. In each test case, there is a list of items, each item has an integer value. The task is to split the items into two non-empty groups such that within each group, every pair of items is “compatible”, meaning their values share no common…

codeforcescompetitive-programming
CF 105973D - Symmetric Swap

We are given two arrays, and we are allowed to transform each array using two kinds of operations: cyclic shifts and a special swap operation that exchanges a prefix with a suffix of equal length.

codeforcescompetitive-programming