brain

tamnd's digital brain — notes, problems, research

41497 notes

CF 104879D - Restore Permutation

We are given a hidden permutation of numbers from 1 to n. The interaction model is that we get some encoded information about this permutation, and in the second phase we receive another permutation that differs from the original in a very restricted way.

codeforcescompetitive-programming
CF 104879E - DequeQL

We are dealing with a dynamic system of nested deques. Each deque can contain other deques, forming a rooted structure that changes over time.

codeforcescompetitive-programming
CF 104879C - Public Transportation

We are given a grid of integers where each cell represents a value assigned to a point on a rectangular board. The task is to count certain geometric configurations formed by three cells, which we can think of as “triangles” aligned with the grid.

codeforcescompetitive-programming
CF 104879A - Coffee Cocktail

We are given several kinds of snacks, where each snack type can appear multiple times and each individual snack contributes some amount of caffeine.

codeforcescompetitive-programming
CF 104880G - 石子配对

We are given a multiset of stone types, where each type has a value and a quantity. Altogether there are exactly $2n$ stones, so every stone must be used exactly once in pairing. When we pair two stones with values $x$ and $y$, they contribute a score equal to $(x + y) bmod k$.

codeforcescompetitive-programming
CF 104880O - Toxel 与字符串匹配

We are given two integer arrays, one of length n and another of length m. We imagine sliding the shorter array over the longer one in every possible relative alignment, including positions where they only partially overlap.

codeforcescompetitive-programming
CF 104880N - Purble Shop

We are interacting with a hidden array of length $n$, where each position represents an item of clothing and stores a color from $1$ to $n$.

codeforcescompetitive-programming
CF 104880M - Easy XOR problem

We are given a collection of binary strings, each of equal length. You can think of each string as a number written in base 2 with a fixed number of bits.

codeforcescompetitive-programming
CF 104880L - 数列计数

We are given a digit sequence of length $n$, and every contiguous segment $[l, r]$ is interpreted as a decimal number.

codeforcescompetitive-programming
CF 104880J - while (1) replace;

We are given an unknown string consisting only of the characters a, b, and c, with length at most 10. We are not allowed to read or query the string directly. Instead, we are allowed to apply a special operation replace(x, y) multiple times.

codeforcescompetitive-programming
CF 104880K - Power Shift

We are given an array of length n, and we need to support three kinds of operations applied over ranges or single positions. One operation takes every element in a segment and replaces it by the integer square root of its current value.

codeforcescompetitive-programming
CF 104880I - 坏掉的计数器

We are given a digit display built from seven-segment components, but some of the segments are broken and always stay off. The device shows an n-digit number, and each digit is rendered independently using the standard seven-segment encoding.

codeforcescompetitive-programming
CF 104880H - 矩阵乘法

We are counting how many 8-number configurations produce a very specific kind of “matrix identity”, but the real content of the problem is simpler than it first appears. Each configuration consists of eight integers, all chosen independently from the range 1 to 99.

codeforcescompetitive-programming
CF 104880F - 火柴棒等式

We are given a mathematical expression formed using matchstick digits, either in the form $a + b = c$ or $a - b = c$, where each number is written in a fixed 7-segment style and all digits lie in the range from 0 to 999.

codeforcescompetitive-programming
CF 104880D - 无声之歌

We are given a sequence of integers and we look at all possible contiguous subarrays. Each subarray has a sum, and among all of these sums there is a maximum value, which is the classical maximum subarray sum.

codeforcescompetitive-programming
CF 104880E - Serval 的树

We are given a tree with $n$ labeled nodes. We are allowed to repeatedly perform an operation where we pick a currently existing node, remove it, and delete all edges incident to it. Each such operation counts as one step.

codeforcescompetitive-programming
CF 104880B - 毕业合照

We are given a set of people moving along an infinite straight line. Each person starts at a position $xi$ and then moves with constant velocity $vi$. All motion begins at the same moment, so time $t = 0$ is shared.

codeforcescompetitive-programming
CF 104880C - 咒语计数

We are given a single string made of lowercase letters. The task is to count how many ways we can pick four positions in increasing order such that the characters at those positions form the pattern c, then v, then b, then b.

codeforcescompetitive-programming
CF 104880A - Well Rested

We are given a fixed schedule encoded as a binary string of length 24. Each position corresponds to one hour of a day, starting from hour 1 up to hour 24. A character 1 means you are working during that hour, while 0 means you are resting.

codeforcescompetitive-programming
CF 104882L - Line without beginning, line without end

We are trying to recover an unknown straight line in the plane, known to have the form $y = kx + b$, where both parameters are real numbers bounded between $-100$ and $100$.

codeforcescompetitive-programming
CF 104882J - Just a map editor

We are given an $n times m$ rectangular grid and must fill each cell with either 0 or 1. A cell belongs to a connected component if it is part of a maximal group of equal values where movement is allowed only between side-adjacent cells.

codeforcescompetitive-programming
CF 104882K - Key anagram

Codeforces 104882K: Key anagram

codeforcescompetitive-programming
CF 104882I - Ideal 2B

We are given a non-negative integer up to one trillion and we need to print a shortened representation of it. The goal is not just compression, but a very specific kind of approximation: we want a string no longer than four characters that represents a number which does not…

codeforcescompetitive-programming
CF 104882H - Have fun taking tests

We are dealing with an interactive multiple-choice test. The test contains $n$ questions, and each question has exactly two possible answers, where exactly one is correct. We do not know the correct answers in advance, and we cannot query them directly.

codeforcescompetitive-programming
CF 104882F - Fine arts museum

We are given up to eight “trees”, each defined by two parameters. Each tree consists of a vertical trunk and a triangular crown drawn with ASCII characters.

codeforcescompetitive-programming
CF 104882E - Efficient synchronization

We are maintaining a collection of k independent versions of the same array of size n. Initially, all k arrays are identical and equal to a given base array. Over time, we process two kinds of operations that are timestamped.

codeforcescompetitive-programming
CF 104882G - Grandma's Cubes

We are given a sequence of dice outcomes, one per throw. At each position Masha is allowed to announce any number from 1 to 6, independent of the real roll, and her score is the sum of all announced numbers. The twist is a “surveillance rule” tied to the value 6.

codeforcescompetitive-programming
CF 104882D - Delicious pies

We are given a row of pies indexed from left to right, where each pie is either cabbage or mushroom. Two children repeatedly take pies from this row according to a positional rule: one child targets every 3rd remaining pie, the other targets every 7th remaining pie.

codeforcescompetitive-programming
CF 104882C - Creative archery

We are building a square target made of unit blocks, where the side length is an even integer $x$. The square is not uniformly colored. Instead, it consists of concentric square “rings”.

codeforcescompetitive-programming
CF 104882B - Before contest

Two players assign a numeric score to the same problem using two different formulas. One takes the length of the statement and raises it to the power of the code length, while the other swaps the roles.

codeforcescompetitive-programming
CF 104882A - A+B?

We are counting integer pairs $(a, b)$ that satisfy a simple linear constraint: their sum is fixed to a given value $n$, and both numbers must lie inside a symmetric interval centered at zero.

codeforcescompetitive-programming
CF 104883E - 宝石合成

We are given a sequence of gemstones, each with an integer level. The only operation allowed is to take a contiguous block of at least two identical levels and merge it into a single gemstone whose level increases by one.

codeforcescompetitive-programming
CF 104883I - Would You Like Some Modulo?

We are given a sequence of large integers, and a range of values from L to R. For each integer x in this range, we repeatedly apply a modulo operation using the sequence A1, A2, ..., An in order.

codeforcescompetitive-programming
CF 104883H - Rolling Star

We are given a total number of credits and two aggregated statistics computed over a hidden list of courses. Each course has an integer credit value and an integer score between 60 and 100.

codeforcescompetitive-programming
CF 104883G - What if ...?

We are given a loop that runs over all integers from 1 to n. Inside the loop, there is a chained if-else structure with m conditions, producing m+1 possible branches.

codeforcescompetitive-programming
CF 104883F - 二分查找

We are dealing with a hidden permutation of length $n$, where every integer from $1$ to $n$ appears exactly once.

codeforcescompetitive-programming
CF 104883D - 生活在树上

This problem requires deriving and proving a constructive algorithm, together with a complete verified implementation.

codeforcescompetitive-programming
CF 104883C - 更小但是异或之后至少有 x 个 1

We are given a large integer a written as a binary string, and a nonnegative integer x. We must construct another integer b that does not exceed a, and among all such valid b, we want the maximum possible value of b.

codeforcescompetitive-programming
CF 104883B - 奥术之尘

Each account comes with a certain amount of “arcane dust”, and there is a fixed list of card decks, each requiring a specific dust cost to be fully crafted.

codeforcescompetitive-programming
CF 104883A - rnm,退钱!

We are given a chronological log of a player’s account balance in a virtual currency system. Each record changes their balance in one of three ways: they either receive currency by paying real money, spend currency in the game, or do something irrelevant that does not affect…

codeforcescompetitive-programming
CF 104885F - Очередная задача про запросы на перестановках

We are given a permutation of size $n$ and a set of range queries. Each query is defined by an interval $[l, r]$.

codeforcescompetitive-programming
CF 104885E - Хорошие-хорошие подотрезки

We are given an array and we work with its prefix sums. Let pref[i] denote the sum of the first i elements, with pref[0] = 0. A subarray [l, r] is called good when its sum is zero, which is equivalent to pref[r] - pref[l-1] = 0, or pref[r] = pref[l-1].

codeforcescompetitive-programming
CF 104885D - Время на марсе

We are given a time interval on a clock, written in hours and minutes, from a starting moment H1:M1 to an ending moment H2:M2.

codeforcescompetitive-programming
CF 104885B - Посчитай

The task describes a simple numerical construction based on repeatedly summing powers of an integer $k$. For each query, we are given a base value $k$ and a length $n$, and we must compute the value obtained by adding the first $n$ powers of $k$, starting from $k^1$.

codeforcescompetitive-programming
CF 104885C - Очередная задача на конструктив

We are building two sequences of decimal digits under a shared budget constraint. The process constructs both sequences in parallel, and at each step we spend part of a fixed total sum to append digits.

codeforcescompetitive-programming
CF 104885A - Детали и ресурсы

We are given a production setup with several workers. Each worker produces a fixed number of identical parts, and every part consumes a fixed amount of metal. All produced metal is then packed into containers, where each container can hold only a limited weight.

codeforcescompetitive-programming
CF 104886D - GCD Counting

We are given multiple test cases. In each one, we receive an array of positive integers bounded by a limit $m$. The task is not to construct anything, but to count.

codeforcescompetitive-programming
CF 104886F - Interval removal

The material you provided does not include the actual problem statement. The input and output sections are empty, and the core description of what “interval removal” is supposed to do is missing.

codeforcescompetitive-programming
CF 104886E - Random Tree Path Match

We are given a rooted tree with a weight on every vertex. For each query, we look at two nodes, take the unique simple path from the root to each of them, and then try to “align” these two root-to-node paths.

codeforcescompetitive-programming
CF 104886C - Fair Grading

We are given a list of professors, each of whom assigns a score to a student. The final score is computed in a very specific way: all scores are sorted, then the smallest and largest values are discarded, and the remaining values are summed. There is one allowed intervention.

codeforcescompetitive-programming
CF 104886A - Schedule Problem

The task is to determine whether a given time schedule is feasible by checking if all required time intervals can be satisfied simultaneously.

codeforcescompetitive-programming
CF 104886B - Easy Geometry

The brute-force view is to treat the river contact point as a variable point $P = (x, 0)$ and minimize the function $$f(x) = sqrt{(x-x1)^2 + y1^2} + sqrt{(x-x2)^2 + y2^2}.

codeforcescompetitive-programming
CF 104887N - Networks Make the Net Work

We are given an undirected graph where vertices are named computers and edges are cables between them. Each test case describes one such network. Originally, each of Alice, Bob, and Cindy started with a specific fixed structure on five computers.

codeforcescompetitive-programming
CF 104887L - LC BB ND CNDY

The transformation starts with a messy phrase containing letters, spaces, punctuation, and mixed casing, and reduces it to a sequence of consonants only.

codeforcescompetitive-programming
CF 104887J - Jolly Divisors

For every integer $n$, we are asked to look for divisors $d$ with a stronger-than-usual property: not only must $d$ divide $n$, but $d^k$ must also divide $n$. Among all such divisors, we take the largest one for each $n$.

codeforcescompetitive-programming
CF 104887K - Kyuuing Theory

We are given a fixed order of students in a queue. Each student needs a fixed amount of time to complete their exam, and there are $k$ instructors who can process students in parallel.

codeforcescompetitive-programming
CF 104887I - Injurious Company

We are given a starting point in the plane and a fixed sequence of moves. Each move has two pieces of information: a maximum length $Ki$ and a constraint on direction type, either horizontal or vertical.

codeforcescompetitive-programming
CF 104887H - Harana

Each position in the input represents a note in a song. At position i, there is an intended note si and Bob actually sings bi. If nothing else changed, the mismatch at position i is simply the absolute difference between these two values.

codeforcescompetitive-programming
CF 104887F - Five-Needle Telegraph

The structure in this problem is a rotated grid that looks like a diamond. Each position in this diamond contains a letter, except the middle horizontal line of length $n$, which contains needles instead of letters.

codeforcescompetitive-programming
CF 104887D - Dragon These Nuts

We are given a multiset of strengths associated with positions 1 through n, and we are allowed to output a permutation of these positions.

codeforcescompetitive-programming
CF 104887G - Ghost Gym

Working

codeforcescompetitive-programming
CF 104887E - Experiment! AMOGUS Edition

Working

codeforcescompetitive-programming
CF 104887C - Canonizing Cannonade

We are working on an $r times c$ grid where some cells contain soldiers. The goal is to place exactly $m$ soldiers so that a specific “destruction game” has a very precise difficulty.

codeforcescompetitive-programming
CF 104887B - Balarila

We are given a single lowercase string. We are allowed to choose an ordered pair of distinct consonants, written as x followed by y. In a modified counting system, every occurrence of the adjacent substring xy is treated as one character instead of two.

codeforcescompetitive-programming
CF 104887A - ABCs of Men and Women, Part 2

We are given a timeline of cooking assignments for three people, encoded as a string where each character is one of A, B, or C. Each position represents one day, and exactly one person cooks on that day.

codeforcescompetitive-programming
TAOCP 7.2.2.1 Exercise 362

We restart from the definition of the object being counted and keep the modification from Exercise 360 precise.

taocpmathematicsalgorithmsvolume-4simple
CF 104895B - Two avenues

I can’t reliably write a correct editorial for “Codeforces 104895B - Two avenues” without the actual problem statement.

codeforcescompetitive-programming
CF 104895D - Serious Business

The problem statement is missing from your prompt (both the “Problem Statement” and input/output sections are empty), so there isn’t enough information to reconstruct what Codeforces 104895D - Serious Business is asking.

codeforcescompetitive-programming
CF 104895C - Strange sum

I can’t reliably write a correct editorial yet because the actual problem statement for Codeforces 104895C - Strange sum is missing from your prompt.

codeforcescompetitive-programming
CF 104895A - Good arrays

I can’t reliably write a correct editorial yet because the actual problem statement for CF 104895A - Good arrays is missing from your prompt.

codeforcescompetitive-programming
CF 104896A - Plane stretching

We are given a set of points in the plane, and we repeatedly apply a geometric transformation: every point keeps its y-coordinate unchanged while its x-coordinate is multiplied by a given factor α.

codeforcescompetitive-programming
CF 104896C - Third grader's task

We are given two integer arrays, which we should think of as multisets of symbols. From the first array, we can form any permutation, meaning any ordering of the same elements. From the second array, we get a fixed reference sequence.

codeforcescompetitive-programming
CF 104901M - Almost Convex

We are given a set of points in the plane, with no duplicates and no three collinear. From these points we want to form polygons whose vertices are chosen from the set. A valid polygon must be simple, meaning its edges do not intersect except at consecutive vertices.

codeforcescompetitive-programming
CF 104901B - Graph Partitioning 2

We are given a tree, and we want to “cut” some edges so that the remaining connected components all have very specific sizes: each component must contain exactly k or k + 1 vertices.

codeforcescompetitive-programming
CF 104901L - Ticket to Ride

We are given a line of cities from 0 to n, and between every adjacent pair we may or may not place a rail segment. Choosing a subset of these segments determines a collection of connected intervals on the line. A ticket is a triple (l, r, v).

codeforcescompetitive-programming
CF 104901J - Computational Intelligence

We are given two line segments in the plane. From each segment, a point is chosen uniformly along its length, independently of the other segment. For every test case, we need the expected Euclidean distance between these two random points.

codeforcescompetitive-programming
CF 104901K - Rainbow Subarray

We are given an integer array and we are allowed to modify it a limited number of times. Each modification increases or decreases a single element by exactly one.

codeforcescompetitive-programming
CF 104901I - Strange Sorting

We are given a permutation, meaning an array of length $n$ containing every integer from $1$ to $n$ exactly once in some order. Our task is to transform this array into increasing order using a specific operation that modifies a contiguous segment.

codeforcescompetitive-programming
CF 104901G - Gifts from Knowledge

We are given a binary matrix, but the only operation we are allowed is to optionally reverse each row. Reversing a row flips it horizontally, so the first column becomes the last, the second becomes the second last, and so on.

codeforcescompetitive-programming
CF 104901H - Basic Substring Structure

Working

codeforcescompetitive-programming
CF 104901F - Say Hello to the Future

We are given an array of problem difficulties, and we want to count how many valid ways exist to split the index range from 1 to n into contiguous segments.

codeforcescompetitive-programming
CF 104901D - Largest Digit

We are given two closed integer intervals. One interval describes the possible values of an integer $a$, and the other describes the possible values of an integer $b$.

codeforcescompetitive-programming
CF 104901E - I Just Want... One More...

Working

codeforcescompetitive-programming
CF 104901C - Turn on the Light 2

We are asked to design, for each test case, a connected simple graph that uses exactly $m$ edges and as few or as many vertices as we choose (but at most $m+1$), under a degree constraint $d$.

codeforcescompetitive-programming
CF 104901A - Many Many Heads

We are given a string that looks like a bracket sequence containing round and square brackets. This string is not necessarily a valid bracket sequence.

codeforcescompetitive-programming
CF 104915D - Шторы

We are given a line of hooks indexed from 1 to n. The two boundary hooks, 1 and n, are considered already used before the process begins. After that, the system repeatedly performs a deterministic operation on the remaining unused hooks.

codeforcescompetitive-programming
CF 104916B - Прогнозы

The setting is a very small round robin tournament with four teams, which we can think of as nodes A, B, C, and D, and a complete set of six possible matches between every pair of teams.

codeforcescompetitive-programming
CF 104916E - Фонари

The system models a park with multiple lanterns, each lantern holding a lamp that eventually burns out. Every lamp has a known lifetime, so each lantern can be thought of as producing an “expiration event” at a specific time.

codeforcescompetitive-programming
CF 104916D - Камышовый кот

We are given a sequence of events ordered by time. At each time moment, the cat catches some number of mice. Multiple catches may happen at the same time moment, so the raw input can contain repeated timestamps with associated counts.

codeforcescompetitive-programming
CF 104916A - Зарядка для кота

We are simulating a simple interaction between a cat and a moving glowing point on a 2D grid. The point changes position step by step, and after each move we evaluate what the cat does in response.

codeforcescompetitive-programming
CF 104916C - CAT

We are given a string consisting of uppercase Latin letters, and we are interested in counting how many ordered subsequences of the form “C-A-T” exist inside it.

codeforcescompetitive-programming
CF 104921C - Word on the Paper

We are given several independent 8 by 8 character grids. Each grid is mostly filled with dots, but somewhere inside it a single word is hidden. The word is written straight down in exactly one column, occupying consecutive rows without interruption.

codeforcescompetitive-programming
CF 104921A - Rook

The input describes positions of a rook on a standard 8 by 8 chessboard. Each position is given in algebraic notation, where a letter from a to h identifies the column and a digit from 1 to 8 identifies the row.

codeforcescompetitive-programming
CF 104922I - Paired roads

I don’t have the actual statement of Codeforces 104922I - Paired roads, so I can’t reliably reconstruct the problem or derive a correct editorial.

codeforcescompetitive-programming
CF 104922H - Lunch

I can’t write a correct editorial for this yet because the actual problem statement is missing. Right now I only see the title “104922H - Lunch”, but no description of the input, output, or rules.

codeforcescompetitive-programming
CF 104922G - Space accident

I can’t reliably write a correct Codeforces editorial for “104922G - Space accident” because the actual problem statement (what is being asked, what the input/output represent, and the constraints) is missing here.

codeforcescompetitive-programming
CF 104922D - Hard problem

The problem statement section is empty, so there isn’t enough information to reconstruct what Codeforces 104922D is asking.

codeforcescompetitive-programming
CF 104922F - Tournament

I can’t reliably write an editorial for Codeforces 104922F - Tournament because the actual problem statement is missing from your prompt. Right now I don’t know: - what structure the “tournament” refers to (bracket, graph, game outcomes, DP on tree, etc.

codeforcescompetitive-programming
CF 104922E - Colorful graph

I can’t write a correct editorial for this yet because the actual problem statement (what “Colorful graph” asks for, input format, and output definition) is missing from your prompt.

codeforcescompetitive-programming
CF 104922A - You need to train more

I’m missing the actual problem statement for Codeforces 104922A - “You need to train more” in your prompt, and I can’t reconstruct it reliably from the title alone.

codeforcescompetitive-programming