brain

tamnd's digital brain — notes, problems, research

41641 notes

CF 105864B - Поход в магазин

We are given a line of $n$ people, each holding some number of identical items. The total number of items is divisible by $n$, so there is a well-defined target value: everyone must end up with exactly $s/n$ items. Initially, the distribution is $a1, a2, dots, an$.

codeforcescompetitive-programming
CF 105869F - Red-Blue MST

We are given a connected undirected graph where every edge is labeled either red or blue and has a distinct weight. The task is not to compute a single minimum spanning tree, but to understand how spanning trees behave when we constrain how many red edges they contain.

codeforcescompetitive-programming
CF 105869A - Suspicious Submissions

We are given a collection of strings that are already sorted by nondecreasing length. For any two strings where the first one is not longer than the second, we want to decide how many ways we can make them “match” if we are allowed to replace a contiguous block of fixed…

codeforcescompetitive-programming
CF 105870C - Escape Room

We are given a universe of K keys, and a family of subsets F of these keys. Each subset A represents the set of keys that are currently usable in a maze.

codeforcescompetitive-programming
CF 105883K - Boring Tree

We are given a tree where some vertices contain stones, and we are allowed to move each stone along edges, one step at a time.

codeforcescompetitive-programming
CF 105883F - WTF Another GCD?

We maintain a dynamic collection of pairs $(v, w)$. Each operation either inserts a pair, removes one occurrence of a pair, or asks a query with a number $k$.

codeforcescompetitive-programming
CF 105883C - Large Graph

We are maintaining a graph on vertices labeled from 1 to n, but n itself can be extremely large, so large that we cannot even think of storing anything indexed by vertices directly. Initially there are no edges, and we receive a sequence of queries.

codeforcescompetitive-programming
CF 105931F - Еж на дереве

We are given a rooted tree with a weight on every vertex. The tree structure is described by a parent array, so every node except the root has exactly one parent and the whole graph is connected and acyclic.

codeforcescompetitive-programming
CF 105931C - Выборы

We are given a set of candidates indexed from 1 to n. Each candidate i starts with ai loyal supporters. In addition, there is a pool of c undecided voters who, if nothing changes, always vote for the smallest-numbered candidate among those who are still participating.

codeforcescompetitive-programming
CF 105937M - History of Terra

We are given a permutation-like array, except the values are arbitrary distinct integers rather than a contiguous range.

codeforcescompetitive-programming
CF 105937F - Beat Verdict: Precision Strike

We are interacting with a hidden integer $x$ that always lies between $1$ and $n$. We cannot see $x$ directly. Instead, we are allowed to ask up to four questions of the form “is $y x$?

codeforcescompetitive-programming
CF 105937B - Nobody Can Log In

We are given several login passwords, one per team, and each password is just a string composed of printable characters like digits, uppercase and lowercase letters, underscores, and hyphens.

codeforcescompetitive-programming
CF 105941M - 川陀航空学院

We are given an undirected graph with n nodes and m existing connections. Because the system is damaged, these connections may include duplicates, cycles, and even useless self-loops.

codeforcescompetitive-programming
CF 105941F - 幻形之路

We are given a rectangular grid where each cell is either empty or blocked. You start at the top-left cell and want to reach the bottom-right cell, moving in the four cardinal directions without leaving the grid. Normally, movement is only allowed through empty cells.

codeforcescompetitive-programming
CF 105941C - Toxel 与宝可梦图鉴

We are given an array of length $n$, where each position stores a Pokémon type represented by an integer. The array changes over time through a sequence of operations.

codeforcescompetitive-programming
CF 105945L - Route Selection

We are given a very narrow weighted grid that represents a walking map. Movement happens along grid edges, and each edge has its own travel speed, so traversing different edges costs different amounts of time.

codeforcescompetitive-programming
CF 105945G - Monetary System

We are given a strictly increasing sequence of coin denominations starting from 1. Using these coins, we define a deterministic way to “pay” any positive integer x: always use the largest possible coin first, take as many of it as possible, then move to smaller coins, and so…

codeforcescompetitive-programming
CF 105945C - Cutting Cards

We are given a permutation of cards numbered from 1 to n, and we want to understand how many different “cutting procedures” can produce a given target sequence. A cutting procedure is not just a final arrangement rule, it is a constructive process.

codeforcescompetitive-programming
CF 105946I - The Keeper vs The Overwriter

We are given a sequence of write operations applied to a sparse array of size $n$, initially empty. Each operation writes a value $x$ into position $i$. The twist is that two different systems interpret overwrites differently.

codeforcescompetitive-programming
CF 105946A - 3D

We are given an array of integers, and we need to count how many ordered triples of distinct indices form an arithmetic relation where the sum of two selected elements equals a third element in the array.

codeforcescompetitive-programming
CF 105948F - 迷宫 (I)

We are given a $2^n times 2^n$ grid of lattice points. Each cell is assigned a unique order using the Hilbert curve indexing, which is a recursive space-filling traversal that produces a permutation of all grid cells from smallest to largest index.

codeforcescompetitive-programming
CF 105948B - 小 F 的分数

We are simulating the scoring system of a simplified rhythm game where only two note types remain relevant: TAP and BREAK. Every note is judged into one of several performance categories, and each category contributes differently to the final score.

codeforcescompetitive-programming
CF 105949H - Hututu

We are given a point on an infinite integer grid and a target point. In one move, the token can change its position by stepping in a “knight-like but diagonal-biased” pattern: both coordinates change together, and the allowed absolute step pairs are (1,1), (2,2), (1,2), or…

codeforcescompetitive-programming
CF 105949C - Optimal Time

We are looking at a system that evolves on integers from 0 to N. From a current state x, each second gives you a single decision before anything else happens. If you choose the passive option, the state simply moves deterministically from x to x − 1 after one second.

codeforcescompetitive-programming
CF 105950F - Frodo and Sam

We are given two parallel sequences of rock types, each sequence being a permutation of the same set of labels. The players are allowed to trim both sequences only from the left and only from the right.

codeforcescompetitive-programming
CF 105962F - F128

We are simulating a particle moving inside a one-dimensional corridor of length $d$. The particle starts at position $k$, measured from the left wall, and initially moves to the right with speed $v$. The motion is perfectly linear between collisions.

codeforcescompetitive-programming
CF 105962A - Neymar at Santos

We are looking at a simplified financial model tied to football performance. There are $P$ teachers, each earning a fixed monthly salary $R$.

codeforcescompetitive-programming
CF 105968K - Kowtowing Our Leader

We are given an array of integers, and we are interested in pairwise products formed by choosing two elements from it.

codeforcescompetitive-programming
CF 105968F - Fraud Detection

We are given a collection of integers, each written in standard decimal form. The task is to look at each number, extract only its first non-zero digit, and count how often each digit from 0 to 9 appears as that leading digit across the entire collection.

codeforcescompetitive-programming
CF 105968C - Circulating Misinformation

We are given two sequences of strings. The first sequence represents the original collection of messages, and the second sequence represents a later, potentially corrupted stream of messages.

codeforcescompetitive-programming
CF 105973H - Substring Symphony

We are given a fixed reference string a and another string b. For any contiguous substring c taken from b, we define a function that depends on how its internal substrings compare against a. For a chosen length k, we look at every contiguous substring of c of length k.

codeforcescompetitive-programming
CF 105973C - Binomial XOR

We are given a function defined on each integer position from 1 to n. For a fixed i, we look at all binomial coefficients in the i-th column of Pascal’s triangle, starting from row i up to row n, take each value modulo 998244353, and XOR them together. That gives f(i).

codeforcescompetitive-programming
CF 105977K - VERTeX

We are given a tree with one weight attached to every node, but those node weights are hidden. Instead of node weights, every edge already tells us the sum of its endpoints: for an edge connecting u and v, we are told that this value equals the sum of the unknown positive…

codeforcescompetitive-programming
CF 105977F - 帕累托前沿

We are given a sequence of points indexed from left to right. Each position $i$ has a pair of values $(xi, yi)$. For any query interval $[l, r]$, we look only at the points inside this segment and classify a point $j$ as valid if there is no other point $k$ in the same…

codeforcescompetitive-programming
CF 105977C - 中位数

We are given an array of odd length, and we repeatedly compress it until only one number remains. Each compression step picks three consecutive elements in the current array, replaces those three values with their median, and shortens the array by two elements.

codeforcescompetitive-programming
CF 105981C - Echoes of the Runes

We are given an array of integers and asked a very specific question about its order: whether it can be transformed into a nondecreasing sequence using at most one swap of two elements.

codeforcescompetitive-programming
CF 105992L - 迷宫

The grid describes a rectangular maze where every cell contains a fixed mirror that deterministically redirects a moving ball depending on the direction from which it enters.

codeforcescompetitive-programming
CF 105992F - No explanation

We are given a collection of strings made of lowercase letters. We may choose any subset of these strings and arrange the chosen ones in any order. After concatenation, we obtain a single long string $S$.

codeforcescompetitive-programming
CF 105992A - 序列

We are given a target integer $x$, and we must construct a sequence $a$ of positive integers such that a particular combinational sum over its subsequences equals exactly $x$. For any sequence, we define $f(x)$ as the number of distinct values appearing in a sequence $x$.

codeforcescompetitive-programming
CF 106007J - Prefix GCD

We are working with arrays of length $n$, where each element is an integer between $1$ and $m$. For any fixed array, we compute a value by looking at prefixes: for each prefix ending at position $i$, we take the gcd of all elements in that prefix, and sum these gcd values over…

codeforcescompetitive-programming
CF 106007F - Meen 3mk?

The task is intentionally not a typical algorithmic problem but a fixed-response query. The program receives a single prompt-like input asking who “your uncle” is, where “uncle” is used as a cultural metaphor for dominance or superiority.

codeforcescompetitive-programming
CF 106007C - Pizza Man

We are simulating a pizza shop that serves a sequence of customers, each demanding a fixed number of pizza slices. The shop has a storage capacity of m, and at the beginning of each test case it is completely full.

codeforcescompetitive-programming
CF 106015K - Roads of the Goose

We are given a weighted undirected graph with $N$ towns and $M$ roads. Each road connects two towns and has a travel cost. The original graph is the full road system.

codeforcescompetitive-programming
CF 106015A - Welcome to the Unknown: An Over The Garden Wall Adventure!

The task is intentionally simple: the program receives a single line of input that represents an opening message from a fictional setting. Regardless of the exact wording or formatting of this line, the required behavior never changes.

codeforcescompetitive-programming
CF 105902I - DJ Mr. Spin

We are given a system where everything rotates around the origin, while a second object moves straight outward along the positive x-axis after we choose a starting time. Inside a fixed circle, there are many points attached to the rotating system.

codeforcescompetitive-programming
CF 105901C - One Must Imagine Sisyphus Happy

We are simulating a worker walking back and forth along a line of n cells. In each round, he starts at cell 1, walks to cell n, then immediately returns to cell 1. Every time he steps on a cell, he inspects it and clears weeds if they are present.

codeforcescompetitive-programming
CF 105900E - Elementary Magical School of Words

We are looking at strings of length n formed from the 26 lowercase English letters, but we do not care about the actual letters used.

codeforcescompetitive-programming
CF 105900I - Inventing Names

We are given a set of existing strings over lowercase English letters, and a maximum allowed length K. The task is to construct a new string that is not in the given set, has length at most K, and is lexicographically as small as possible among all valid choices.

codeforcescompetitive-programming
CF 105891C - gcd

We are given two very large positive integers, a and b, and for each test case we must decide whether there exists another positive integer x (bounded by $10^{18}$) that simultaneously satisfies two conditions.

codeforcescompetitive-programming
CF 105891E - Printer

We are asked to simulate a very constrained typing process that builds a target string in order, but with a twist: characters do not have to be appended only at the end of the current string.

codeforcescompetitive-programming
CF 105887G - LCA \& MST

We are given a rooted tree where node 1 is the root. Every node carries a numeric weight. From this tree we define a complete graph on the same nodes, but the edge weight between two nodes is not arbitrary: it is determined entirely by the weight of their lowest common…

codeforcescompetitive-programming
CF 106440L - PPIIIGG

We are given a string made only of the characters P, I, and G. For each test case, we must count how many subsequences of this string form a very specific structured pattern.

codeforcescompetitive-programming
CF 106435E - Рамазан и штанга 70кг

We are given a fixed sequence of days, where each day is either a training day or a rest day. We need to imagine a process that starts with a weight of 0 kilograms and evolves day by day according to the same rules every time we start from a chosen day.

codeforcescompetitive-programming
CF 106434B - Зашифрованный массив

We are given an array that we only see in a distorted form. Each element in the observed array could have originally been any integer within a fixed interval around its observed value.

codeforcescompetitive-programming
CF 106430A - Bessie and Trap

We are given a process where a character moves through a sequence of rooms in order, carrying a number of keys that changes as they progress. They start with some initial number of keys, and each room adds a fixed number of keys.

codeforcescompetitive-programming
CF 106429A - Tart Splitting

We are given a string representing a circular arrangement of elements, and another string representing a target pattern. The task is to determine whether the target pattern can be obtained by rotating the original circular arrangement.

codeforcescompetitive-programming
CF 106416L - Late and Disobedient

We are watching a one-dimensional crosswalk of length $L$, represented as the segment from $0$ to $L$. At any moment in time, each pedestrian is a moving point on the real line, starting at position $Xi$ and moving with constant velocity $Vi$, so their position at time $T$ is…

codeforcescompetitive-programming
CF 106398C - Зарядка для хомяков

We are given a row of $N$ hamsters, where $N$ is even. Each hamster is in one of two states: standing or sitting, encoded as characters X and x. In one move, we can pick a single hamster and flip its state.

codeforcescompetitive-programming
CF 106396M - 同生

We are working with a dynamic system of elements that behave like nodes in a graph, where nodes can be merged over time into larger components.

codeforcescompetitive-programming
CF 106387G - The Veneto Relay

We are given a graph where cities are connected by roads, and each road has an associated danger value. Some cities are marked as milestone cities.

codeforcescompetitive-programming
CF 106384K - 天使的羽翼和水晶

The statement provided contains only the title and no functional description of the input or output. There is no definition of the objects involved, no constraints, and no task specification to reason about.

codeforcescompetitive-programming
CF 105900A - Ascending mountains

We are given a set of mountains labeled from 1 to N, where each label also represents its difficulty level. There are M precedence rules of the form A before B, meaning Isa cannot climb mountain B unless she has already climbed mountain A.

codeforcescompetitive-programming
CF 105891J - Win

We are given a fixed lowercase string, and we are allowed to insert up to k characters anywhere in it. Insertions are flexible: we can choose both the position and the character freely each time.

codeforcescompetitive-programming
CF 105891L - easy

We are given an $n times n$ matrix where the values are filled in row-major order. The number in row $i$, column $j$ is simply $(i-1)cdot n + j$, so each row is a consecutive block of integers and every column picks one element from each block at a fixed offset.

codeforcescompetitive-programming
CF 105891I - magic

We are given an integer array of length $n$, and a fixed parameter $k$. We are allowed to repeatedly apply an operation that chooses a center position $x$ such that there are at least $k$ elements on both sides of it.

codeforcescompetitive-programming
CF 105887E - 异或问题

We are trying to place a fixed-length window of consecutive integers on the number line. We choose a starting value a, forming the segment a, a+1, ..., a+l-1, with all values required to stay within [0, n].

codeforcescompetitive-programming
CF 105887L - 栈与重复

We maintain a stack that starts empty and evolves through a sequence of operations. Each operation either pushes a value onto the stack, pops the top element, or triggers a macro-like action that repeats all previously executed operations once more.

codeforcescompetitive-programming
CF 105887I - 答辩

We are given several independent test cases. In each test case there are n students, each belonging to exactly one of m disjoint groups. A directed question network must be constructed between students.

codeforcescompetitive-programming
CF 105887D - 黄金替罪羊

We are given a sequence of moves of length $2n$, where each character instructs a step on a number line: left moves decrease position by 1 and right moves increase it by 1. Some positions in the sequence are fixed as L or R, while others are unknown and must be filled.

codeforcescompetitive-programming
CF 105828G - Время читать книги

We are given a fixed sequence of books, each with a reading time and a latest acceptable day by which it must be finished. The order of reading is not flexible: books are read in the given order from first to last.

codeforcescompetitive-programming
CF 106016L - Good Sets

We are given an array where each position has a value, and we want to form special subsets of indices. The key restriction is that any two chosen indices must be separated by at least one unused position, so we can never pick adjacent indices.

codeforcescompetitive-programming
CF 106016I - W/S TREE

We are given a tree where each node carries a numeric value, which can be positive or negative. We start from node 1 and walk along edges, collecting the value of a node the first time we visit it.

codeforcescompetitive-programming
CF 106016E - a less than b

We are given two strings of equal length, and we are allowed to modify the first string using at most one operation. That operation picks a contiguous segment and reverses it.

codeforcescompetitive-programming
CF 106016C - USD vs Liras

Each day Omar must settle a demand that is expressed in two currencies. For day i, there is a required amount of dollars ai and a conversion rate bi that tells how expensive it is to replace one dollar using liras. On that day Omar can split the payment in two parts.

codeforcescompetitive-programming
CF 106026J - Eternal Feather II

We are given a very long string length $n$, but we are not asked to construct strings explicitly. Instead, we work over strings formed from the fixed alphabet ${y, u, k, o}$, and we want to count how many such strings of length $n$ are “valid”.

codeforcescompetitive-programming
CF 106026F - 乱序法杖

Each sheep starts with an integer health value. We are given a multiset of operations that will be applied in a uniformly random order: some number of “healing” spells and some number of “damage” spells.

codeforcescompetitive-programming
CF 106026E - 简单的数据结构题

We are maintaining a long array where every element is always a 4-bit value, so each value lies in the range from 0 to 15. The array changes over time through range updates, and occasionally we are asked to compute a summary statistic over a range.

codeforcescompetitive-programming
CF 106026A - 备用账号

We are given a list of usernames, and we want to count how many unordered pairs of usernames can be considered “account variants” of each other.

codeforcescompetitive-programming
CF 106026B - 进制变换

We are given two integers, and we are allowed to transform a current value into a new value using a very specific operation.

codeforcescompetitive-programming
CF 106030M - Median Replacement

We are given a list of $n$ positions, and each position $i$ is not fixed to a single value but instead allows any integer in a range $[li, ri]$. So each valid array is formed by independently choosing one value inside each interval.

codeforcescompetitive-programming
CF 106030L - 沙堆

I can’t produce a correct editorial from what you’ve provided, because the actual problem content (input/output format, rules of the sand pile process, constraints) is missing. Right now I only see the title “沙堆” with empty input and output sections.

codeforcescompetitive-programming
CF 106030J - 骰子

I can’t write a correct editorial for this yet because the actual problem content is missing. Right now all we have is the title “骰子” (dice), but no statement, constraints, or input/output rules.

codeforcescompetitive-programming
CF 106030I - 算术

The statement you pasted only contains the title “I. 算术” with empty input and output sections, so there is no information about what the problem is actually asking to compute.

codeforcescompetitive-programming
CF 106030G - 魔弹

The problem statement you provided is incomplete. It only contains the title “G. 魔弹” without any description of the input format, output requirements, constraints, or the underlying task.

codeforcescompetitive-programming
CF 106030F - Pico Park

I can’t reliably write a correct Codeforces-style editorial for 106030F - Pico Park because the problem statement in your prompt is missing (only the title is present, with no description of inputs, outputs, or rules).

codeforcescompetitive-programming
CF 106030E - 合成大西瓜

The statement you provided is essentially empty (no input/output description or rules), so there is not enough information to write a correct editorial.

codeforcescompetitive-programming
CF 106030A - 乘积,欧拉函数,求和

I can’t reliably write a correct editorial here because the actual problem content is missing. Right now, the statement only shows a title (“product, Euler function, sum”) but no definitions, no input format, no output format, and no constraints.

codeforcescompetitive-programming
CF 106030C - 连方

I can’t write a correct editorial for Codeforces 106030C (“连方”) from what you provided, because the actual problem statement (input, output, and rules) is missing.

codeforcescompetitive-programming
CF 106503J - Stop, Grid Please No More

We are given a rectangular grid of size $n times m$. Each cell is treated as a unit square, and each square is assigned one of four possible orientations, corresponding to one of the four directions on the grid.

codeforcescompetitive-programming
CF 106503M - Until next time, SCNUCPC!

We are given a line of stalls indexed from left to right. Some positions are already fixed as active stalls, marked as C, while some positions are empty candidates marked as ?. We are allowed to turn some of the ?

codeforcescompetitive-programming
CF 106456L - Tornado Destroys the Parking Lot

The parking lot is a grid where each cell is either empty or contains a car that has a fixed direction of movement.

codeforcescompetitive-programming
CF 106456C - Crossing

We are given a grid where each cell contains a non-negative integer. A traveler starts at the top-left cell and must reach the bottom-right cell. Movement is allowed in four directions and cells may be revisited any number of times.

codeforcescompetitive-programming
CF 106456E - Simple Math

We are given a positive integer $x$, and we want to know whether there exists another positive integer $k$ such that the product $x cdot k$ becomes a number consisting only of the digit 9 in every position.

codeforcescompetitive-programming
CF 106444A - Abadi Pikosom

The underlying object in this problem is not immediately presented in a clean form. After stripping the narrative, the core structure is about permutations of $n$ elements and a quantity called “anger” that is accumulated during a process where people are processed in some…

codeforcescompetitive-programming
CF 106444G - Like a Comet

We are given a sequence of episodes, each carrying a numerical rating and a label that determines whether the episode is “excellent” or “ready”.

codeforcescompetitive-programming
CF 106443M - Meet Me Halfway

We are given a circular arrangement of buildings indexed from 0 to m − 1. Movement is only allowed to adjacent buildings on the circle, so from position i you can move to i + 1 modulo m or i − 1 modulo m, and distance between two positions is the shortest number of such…

codeforcescompetitive-programming
CF 106443D - Digits Duel

We are given a turn-based game that starts with a collection of integers, initially exactly the numbers from 2 up to $N+1$. Two players alternate turns.

codeforcescompetitive-programming
CF 106443E - Evaluation

The task is a direct format conversion problem on a fixed-size grid that represents a chessboard. The input is an 8 by 8 character matrix, where each cell is either a chess piece or an empty square.

codeforcescompetitive-programming
CF 106440G - fufu 购买计划

We are given a set of coins with values from 1 to n, each value appearing exactly once, so we are really choosing a subset of the integers 1 through n. The goal is to pick a subset whose total sum is exactly m. However, selection is restricted by additional prefix rules.

codeforcescompetitive-programming
CF 106440I - 凹包

We are given a set of points in the plane, where one of the points is fixed at the origin $O = (0,0)$. From these points we may select some subset and connect them in some cyclic order to form a simple polygon, meaning a non self-intersecting closed chain.

codeforcescompetitive-programming