brain

tamnd's digital brain — notes, problems, research

43815 notes

CF 106170G - Nearest Strings

We are given several short strings made of lowercase letters, and for each string we want to find another string in the same set that is “closest” under a specific distance measure.

codeforcescompetitive-programming
CF 106167D - Decrypting Zodiac

We are given two strings of equal length. One is the observed encrypted text, and the other is a candidate original message that we believe might have been encrypted to produce it. The encryption process is two-layered.

codeforcescompetitive-programming
CF 106164H - Home Workout Playlist

We are given a sequence of song “hype” values in a fixed order, and we are allowed to delete some songs while keeping the remaining ones in their original relative order. From the remaining subsequence, we want a very structured pattern.

codeforcescompetitive-programming
CF 106163B - Shortest Path

We are given a complete graph on n cities, where every pair of cities has a direct road. The cost of that direct road is not uniform: it depends on the bitwise AND of the two city values.

codeforcescompetitive-programming
CF 106161G - GCD of Subsets

We are given a collection of items. Each item has a weight and a value, but for some items exactly one of these two numbers is missing and must be assigned by us as a positive integer not exceeding one billion. Two greedy procedures will later run on the completed dataset.

codeforcescompetitive-programming
CF 106159C - Creating a Playlist

We are given a sequence of songs, each associated with a value that can be positive or negative. We want to select a subset of these songs to maximize the total sum of selected values, but there is a spacing restriction: if we choose a song at position i, then we are forbidden…

codeforcescompetitive-programming
CF 106158B - Magic Circle

We have $n$ wizards arranged in a circle, indexed from 1 to $n$. Each wizard starts with a very large identical mana value, so initially all wizards are tied. Then we apply $q$ rituals. Each ritual defines a sequence of affected wizards.

codeforcescompetitive-programming
CF 106153D - 琪露诺的无限循环小数

The task revolves around deciding whether a given fraction produces a terminating decimal or an infinite repeating decimal when written in base 10. Each test case gives an integer denominator, and we implicitly consider the fraction $frac{1}{n}$.

codeforcescompetitive-programming
CF 106151I - runnerups

We are given an array of distinct performance scores recorded over time. Each query provides a small set of time indices, and from those indices we consider every possible interval formed by choosing two of them as endpoints, including choosing the same index twice only when…

codeforcescompetitive-programming
CF 106144C - Monocarp, Polycarp and Brackets

We are given a string of brackets. Two players alternately remove characters from the ends of this string. On each move, a player picks either the leftmost or rightmost character of the current string and deletes it.

codeforcescompetitive-programming
CF 106142F - Сделать максимальным

We are given an array of integers, and for every position we must answer a separate optimization question about that position’s value. The element at index i is treated as a fixed reference element.

codeforcescompetitive-programming
CF 106141J - Exercise for Dania

We are given an array and for every prefix of this array we must compute a value formed from all unordered pairs inside that prefix.

codeforcescompetitive-programming
CF 106136N - In Filtration

We are working on an infinite grid where a white king starts at a given coordinate and must eventually capture all black rooks. The king moves like a standard chess king, meaning it can step to any of the eight neighboring cells in one move.

codeforcescompetitive-programming
CF 106132D - Permutation Swaps

We start with the identity permutation, meaning the array contains numbers from 1 to n in increasing order. We are allowed to repeatedly apply a recursive construction that behaves like a binary splitting process.

codeforcescompetitive-programming
CF 106130A - \%\%\%自动机

The task reduces to constructing a single string based on an input integer. We are given a number $n$, and we must output a line consisting of exactly $n$ identical characters, where each character is the percent symbol %.

codeforcescompetitive-programming
CF 106129K - Karlsruhe Skyline

We are asked to construct a single permutation of the numbers from 1 to n, interpreted as building heights along a row. Two integers a and b describe how many buildings are visible when looking from the left end and from the right end respectively.

codeforcescompetitive-programming
CF 106084H - Chopsticks

We start with a collection of chopsticks grouped by type. Each type contributes a known number of identical items. From the full pool, we randomly select exactly 2n chopsticks without replacement.

codeforcescompetitive-programming
CF 106084D - Palindromic Distance

We are given a string for each test case and we want to measure how far it is from being a palindrome, where “distance” is the standard edit distance with insertions, deletions, and substitutions allowed.

codeforcescompetitive-programming
CF 106082K - Security Fence

We are given a simple closed fence described by its corner points in clockwise order. The fence forms a convex polygon, so every interior angle is less than 180 degrees and every line segment between two interior points stays inside the region.

codeforcescompetitive-programming
CF 106082I - Share Auction

I can’t write a correct editorial for this problem yet because the actual problem statement is missing. Right now I only see the title “Share Auction” with no rules about bids, constraints, input format, or what needs to be optimized.

codeforcescompetitive-programming
CF 106082B - Simplified Calendar System

I’m missing the actual problem statement for Codeforces 106082B - Simplified Calendar System. Right now the input/output sections are empty in your prompt, so there’s no way to correctly reconstruct: - what the calendar system defines (days, months, weeks, etc.

codeforcescompetitive-programming
CF 106073M - Minas Gerais' walls

We are given a one-dimensional wall made of consecutive segments, each segment having an initial height. We are allowed to perform exactly one reinforcement operation.

codeforcescompetitive-programming
CF 106073H - How many teams?

Each student in this problem can be represented by a bitmask of length $K$, where the $j$-th bit indicates whether the student has a particular frontend skill.

codeforcescompetitive-programming
CF 106073C - Collatz polynomial

We are given a polynomial where every coefficient is either 0 or 1, so the polynomial is best thought of as a set of powers of x. If the coefficient of $x^k$ is 1, we include that term, otherwise we do not.

codeforcescompetitive-programming
CF 106072H - Tree Shuffling

We are given a tree where every vertex initially carries a distinct label equal to its index. The only allowed action is a single global operation that changes some of these labels. In that operation, we first pick a simple path in the tree.

codeforcescompetitive-programming
CF 106072C - Jiaxun!

We are given a pool of programming problems, each problem already labeled by exactly which of three students can solve it. Every problem falls into one of seven categories depending on its solvability set among students 1, 2, and 3.

codeforcescompetitive-programming
CF 106068J - Washing Machine

We are given a fixed amount of time, measured in hours, during which electricity is available. Each hour corresponds to exactly one washing cycle of a machine. There are several colors of clothes, and each color has a certain number of items that must all be washed.

codeforcescompetitive-programming
CF 106068D - Ba3d Khamsa

We are given a string, and we are asked multiple independent queries on it. Each query focuses on a contiguous substring. For that substring, we are allowed to modify characters, where one operation means replacing a single character with any other lowercase English letter.

codeforcescompetitive-programming
CF 106059M - Median Replacement

We are given an array, and we repeatedly apply a randomized operation on it. One step of the process picks an index uniformly at random and overwrites that position with the median of the remaining elements.

codeforcescompetitive-programming
CF 106059H - Huge Subsets

We are given an array of positive integers. For each $k$, we look at all ways to choose exactly $k$ elements and record the sum of each such choice. This produces a multiset $Sk$, where repetition matters because different subsets can produce the same sum.

codeforcescompetitive-programming
CF 106059B - Binary Palindromes

We are given a binary string $s$. We are allowed to cut it into a sequence of contiguous pieces, and the cut points are completely flexible, meaning every split of the form “choose $k$ and break into $k$ substrings” is valid, and all such splits are counted.

codeforcescompetitive-programming
CF 106057H - Mr. Benzene's Bachelor Trip

We are given two integers, $k$ and $m$. Think of building a target sum $n$ by splitting it into exactly $k$ ordered parts, where each part is a non-negative integer. Two decompositions are different if any position in the $k$-tuple differs.

codeforcescompetitive-programming
CF 106057C - Prime Dominion

We are given an integer array and we want to examine every contiguous segment of it. For each segment, we compute the greatest common divisor of all elements inside that segment.

codeforcescompetitive-programming
CF 106054H - Hidden divisor

We are given a multiset of divisors of an unknown integer $X$, but one divisor is missing. In total, $X$ has exactly $N+1$ positive divisors, and we are given $N$ of them.

codeforcescompetitive-programming
CF 106054C - Circularly

We are given a permutation of length $N$, meaning it contains each number from 1 to $N$ exactly once. From this permutation, we define a transformation called “taking a semi-fixed point”: an index $x$ is counted if applying the permutation twice brings us back to $x$…

codeforcescompetitive-programming
CF 106047L - Difficult Constructive Problem

We are given a binary string where some positions are already fixed as 0 or 1, while others are unknown and marked with ?. We must replace every ? with either 0 or 1. After filling the string, we look at adjacent pairs and count how many times consecutive characters differ.

codeforcescompetitive-programming
CF 106047K - Are you a bot?

We are given a target array $b$ of length $n$. Our task is not to compute a value from a permutation, but to reconstruct a permutation $a$ of numbers from $1$ to $n$ such that a derived function computed from $a$ matches $b$.

codeforcescompetitive-programming
CF 106047H - Not Another Path Query Problem

We are given an undirected graph where each edge carries a 60-bit weight. A path between two vertices is evaluated not by summing or minimizing weights, but by taking the bitwise AND of all edge weights along that path.

codeforcescompetitive-programming
CF 106047E - Computational Geometry

We are given a convex polygon with vertices listed in counterclockwise order. From this polygon, we must choose three vertices, call them $a$, $b$, and $c$, also in counterclockwise order along the boundary.

codeforcescompetitive-programming
CF 106047B - Be Careful 2

We are working inside an axis-aligned rectangle whose lower-left corner is fixed at the origin and whose upper-right corner is at $(n, m)$. Inside this rectangle there are $k$ forbidden lattice points.

codeforcescompetitive-programming
CF 106047C - Connected Intervals

We are given a tree with vertices labeled from 1 to n, and these labels also define a linear order. For any interval [l, r], we look at the vertices whose labels lie in this range and consider the subgraph induced by them in the original tree.

codeforcescompetitive-programming
CF 106039C - Echoes of the Jade Library

We are given a sequence of N strings, each string representing a “scroll” written with lowercase letters. From each scroll, we care about all substrings that are palindromes, and we treat two substrings as the same if their character sequences are identical, regardless of…

codeforcescompetitive-programming
CF 106039A - Yuyuan Market

We are given a sequence of length $2N$, where each value from $1$ to $N$ appears exactly twice. You can think of it as pairs of identical symbols placed along a line. The task is to choose pairs of equal symbols under a strict movement rule.

codeforcescompetitive-programming
CF 106039M - Nomad

We are given a fixed number of nights, D, and a collection of N possible places where a person can sleep. Each place i comes with a constraint di that limits how many consecutive nights can be spent in that place.

codeforcescompetitive-programming
CF 106039L - Game of Life

We are given a very small grid, at most 8 by 8, where each cell can be in one of three states. A cell can be alive, dead, or blocked. Blocked cells never change and also never participate as active contributors in the dynamics. The system evolves in discrete steps.

codeforcescompetitive-programming
CF 106039K - Cake Hater

We are given a set of ingredients and a list of ingredients that Antonio refuses to use. The recipe is split into several stages, and each stage specifies a subset of ingredients required for that step. When Antonio prepares a stage, he simply omits every ingredient he dislikes.

codeforcescompetitive-programming
CF 106039I - Bath

We are given a simple polygon representing a room, with the first vertex acting as a door. Inside this polygon lies a single point representing a towel. A person starts at the door vertex, walks entirely within the polygon, reaches the towel, and must return to the same door.

codeforcescompetitive-programming
CF 106039H - The Wisdom of Master Wei

We are given two starting years, one for Master Wei and one for Kai. From those years onward, each person accumulates “experience” equal to the number of years that have passed since they started programming.

codeforcescompetitive-programming
CF 106039G - Incompatible Pairs

We are given a sequence consisting only of two types of symbols, an opening bracket ( representing a Yang dancer and a closing bracket ) representing a Yin dancer. Each ( must be matched with a later ) to form a valid pairing, and every dancer participates in exactly one pair.

codeforcescompetitive-programming
CF 106039E - Complexity of Quicksort

We are given a sequence of distinct integers and a specific version of quicksort that behaves in a very particular way. The pivot is always chosen as the middle index of the current segment, not by value but by position.

codeforcescompetitive-programming
CF 106039D - The Seals of Shanghai

We are given a sequence of integers, and we are allowed to choose a modulus value $M$ with $1 < M le 10^9$. Once $M$ is fixed, each “move” consists of picking a remainder value $x$, and in that move we remove all numbers whose value modulo $M$ equals $x$.

codeforcescompetitive-programming
CF 106038B - Astana

We are given a chronologically sorted list of distinct integers, where each integer represents a day on which Bernardo went to the gym. The goal is to determine the longest streak of consecutive calendar days present inside this list.

codeforcescompetitive-programming
CF 106038E - Guadalajara

We are given a short string of up to 15 characters representing coins in a line. Each coin is either H (heads) or T (tails).

codeforcescompetitive-programming
CF 106033K - Kindergarten Problem

The problem statement you provided is incomplete. It only contains the label “K”, with no description of the input format, constraints, or required output.

codeforcescompetitive-programming
CF 106033A - ABABABABA

The task is deceptively minimal: there is no meaningful structure to process, and the entire problem reduces to producing a specific string consisting of alternating characters.

codeforcescompetitive-programming
CF 106038K - Online

We are trying to reconstruct an unknown binary string of length $N$ by interacting with a judge. Each time we submit a candidate string, the judge compares it against the hidden password and returns how long the two strings match from the beginning.

codeforcescompetitive-programming
CF 106038H - Campo Grande

We are given a set of distinct fish names, all equally likely to be chosen. Jake wants to identify the chosen fish by asking yes or no questions, and he is allowed to ask any question he wants, as long as the answer partitions the remaining candidates into two groups.

codeforcescompetitive-programming
CF 106038C - João Pessoa

We are given a circular arrangement of parentheses. The string contains only '(' and ')', and the total number of opening and closing brackets is equal. We are allowed to take a prefix of the string and move it to the end, effectively rotating the string.

codeforcescompetitive-programming
CF 106033C - Conveyors

The problem statement is missing from the prompt (the input/output sections are empty), so there’s no way to reliably reconstruct what Codeforces 106033C “Conveyors” is asking.

codeforcescompetitive-programming
CF 106033I - Imprisoned XII

I can’t write a correct editorial for this yet because the actual problem statement is missing (it only shows “I”).

codeforcescompetitive-programming
CF 106033G - Grid Game

I can’t write a correct Codeforces editorial from that input because the actual problem content is missing. Right now, the statement is just: with empty input/output sections.

codeforcescompetitive-programming
CF 106038L - Campina Grande

There are several independent groups of items, each group representing a competition. For each competition $i$, Fmota initially owns $ai$ shirts. Time is measured in years starting from year 0 up to year $k$.

codeforcescompetitive-programming
CF 106038G - Dhaka

There are $n$ tuk-tuks arranged in a strict ranking where position 1 is the best and position $n$ is the worst. Each tuk-tuk has a hidden score, and the ordering is always strictly determined by these scores: higher score means better position, and all scores are distinct at…

codeforcescompetitive-programming
CF 106038D - Luxor

We are given a sequence of integers representing transactions that are accumulated one by one into a running sum. The machine computing this sum has a fixed integer range determined by a parameter $k$, so the running total must always stay inside a symmetric interval around zero.

codeforcescompetitive-programming
CF 106033L - Limited Rooks

The prompt is missing the actual problem statement, input format, and output requirements. Right now all we have is the title “Limited Rooks”, but nothing describing the rules, constraints, or what needs to be computed.

codeforcescompetitive-programming
CF 106033J - Journey

The problem statement for Codeforces 106033J - Journey is missing from your prompt (it only shows “J” with no description, input, or output details). Without the actual statement, it’s not possible to write a correct or meaningful editorial.

codeforcescompetitive-programming
CF 106033H - Harmony Graph

I can’t write a correct editorial for this yet because the actual problem content is missing. Right now the statement is effectively just “H”, with no description of the graph structure, operations, input format, or required output.

codeforcescompetitive-programming
CF 106033E - Educational Problem

The problem statement for “Codeforces 106033E” is not actually included here beyond a placeholder (“E”). Without the actual description, constraints, or input/output format, it’s impossible to derive a correct solution or write a meaningful editorial.

codeforcescompetitive-programming
CF 106033D - Disregard the Light

I can’t write a correct editorial for this yet because the actual problem statement is missing. Right now I only see the title “106033D - Disregard the Light”, but there is no description of the rules, input format, or what needs to be computed.

codeforcescompetitive-programming
CF 106033F - Fair Gambling

This request cannot be completed faithfully as written because the problem statement is missing. The only content provided under Problem Statement is: with no description of rules, input format, output format, constraints, or samples.

codeforcescompetitive-programming
CF 106033B - BaCoder Testing Procedure

The input describes a sequence of independent test cases, where each test case consists of a small structured configuration that must be validated under a fixed procedure defined by the problem.

codeforcescompetitive-programming
CF 106038J - Gramado

We are given a collection of items, where each item has two values attached to it. One value represents a benefit, interpreted as “how much you learn”, and the other represents a cost or pain, interpreted as “how much it hurts”.

codeforcescompetitive-programming
CF 106038F - Chapecó

We are given a ranking of $n$ teams, ordered from best position $1$ to worst position $n$. Each position has an associated “happiness” value, but instead of being arbitrary, the sequence follows a very specific shape: it first never increases as we go from position $1$…

codeforcescompetitive-programming
CF 106038A - Salvador

We are tracking a vote among four fixed candidates, the turtles Rafael, Leonardo, Donatello, and Michelangelo. Each candidate already has some number of votes, and there is a pool of remaining votes that have not yet been cast.

codeforcescompetitive-programming
CF 106039J - The Messenger's Disguise

We are given an undirected graph representing cities connected by roads, where each road has the same travel cost. A traveler starts at a source city S and wants to reach a destination city T.

codeforcescompetitive-programming
CF 106039F - Chinese Innovation

We are given a weighted undirected graph of cities connected by normal roads, where every road can be used in both directions and has a fixed travel cost. In addition to roads, cities may contain special teleportation devices of different types.

codeforcescompetitive-programming
CF 106039B - The Search for Balance

We are given up to 35 power-ups, each of which contributes a fixed change to two attributes: attack and defense. Starting from zero in both dimensions, we choose any subset of these power-ups, apply all chosen ones (order does not matter because addition is commutative), and…

codeforcescompetitive-programming
CF 106047I - Heap

We are given a sequence of values that are inserted one by one into an initially empty binary heap array. Each insertion uses the standard “sift-up” procedure: the new element is appended at the end, and then it is repeatedly swapped with its parent while the heap property…

codeforcescompetitive-programming
CF 106047F - Puzzle: Sashigane

We are given an $n times n$ grid where every cell is white except for exactly one black cell that must remain uncovered.

codeforcescompetitive-programming
CF 106047A - Colorful Segments

We are given several test cases, and each test case consists of a collection of segments on the real number line. Every segment covers a closed interval from $li$ to $ri$, and each segment is labeled with one of two colors, either red or blue.

codeforcescompetitive-programming
CF 106054N - Nothofagus antarctica

We are given a set of points on a 2D grid, each point representing the position of a tree that must be protected. The government wants to build a fence that is an axis-aligned simple closed boundary, meaning its sides are parallel to the coordinate axes.

codeforcescompetitive-programming
CF 106054I - Inés and her compitas

We are given a repeated decision process over multiple rounds. In each round there is a group of $N+1$ players: Inés and $N$ others. Each round presents two possible mechanisms for distributing gold. In the first mechanism, a subset of players chooses to “share”.

codeforcescompetitive-programming
CF 106054F - Feeding the goat

We are given a convex polygon that represents a fenced garden. One vertex is special: the goat is tied to this vertex with a rope of length $L$. The goat can move freely outside the polygon, but it cannot pass through the fence, and the rope itself cannot cross the fence either.

codeforcescompetitive-programming
CF 106054A - Artifact to print

We are given a single string of fixed length ten, consisting only of uppercase Latin letters. From this string, we are allowed to delete characters, but we are not allowed to rearrange what remains.

codeforcescompetitive-programming
CF 106057K - Dreaming of National IUPC

The task is intentionally minimal: there is no input to process and no computation to perform. The only requirement is to produce a single fixed sentence exactly as specified in the output format.

codeforcescompetitive-programming
CF 106057F - A Perfect Path

We are given a tree where every node carries an integer value. For multiple queries, each query provides two nodes u and v, and we must decide whether the product of all values along the unique simple path between u and v forms a perfect square.

codeforcescompetitive-programming
CF 106057B - Dartboard

We are given a stack of concentric convex polygons, one inside another, where each polygon fully contains the previous one. Each layer has an associated score.

codeforcescompetitive-programming
CF 106059I - Ice Sliding

The grid can be seen as a board of ice tiles and walls. From any starting ice cell, a move consists of choosing an initial direction and then continuously sliding in that direction until an obstacle stops the motion.

codeforcescompetitive-programming
CF 106059F - Forbidden Spell Sequence

We are building strings of length $n$ using a fixed alphabet of exactly seven symbols, from $a$ to $g$. Every position in the string is chosen independently from this alphabet, but not every resulting string is allowed. The restriction comes from a set of forbidden rules.

codeforcescompetitive-programming
CF 106059A - Angle Problem

We are given a fixed list of points on a plane, stored in order, and we are asked to answer many independent queries. Each query selects a contiguous segment of these points and also gives a viewpoint located strictly above all points.

codeforcescompetitive-programming
CF 106068I - The judges problem

Ten judges each pick a number between 1 and 10, representing which problem they want added to the contest. After all votes are collected, the selected problem is the one with the highest number of votes.

codeforcescompetitive-programming
CF 106068F - Good Luck Syria

The task is intentionally minimal. We are given a single string, and the input is always the same fixed token. The output must reproduce that token exactly, without modification, interpretation, or transformation.

codeforcescompetitive-programming
CF 106068C - Stones Game

We are given a pile of stones. Two players alternate turns, and on each turn a player removes some positive number of stones. The restriction is that the number of stones removed must be strictly smaller than the most significant bit value of the current pile size.

codeforcescompetitive-programming
CF 106072J - Reconstruct the tree

We are given a tree with nodes labeled from 1 to N, but the tree itself is lost. What remains is a list of pairs of nodes that were remembered as being at maximum possible distance in that tree, meaning each listed pair has distance equal to the tree’s diameter.

codeforcescompetitive-programming
CF 106072F - Square Permutation I

We are given two permutations of the same length, and each position represents a paired choice between two values, one coming from the first permutation and one from the second. At every index we are allowed to “activate” some transformation on the values at that index.

codeforcescompetitive-programming
CF 106072B - Rectangular Wooden Block

We are given a 3D wooden block composed of unit cubes arranged in a grid of size $L times W times H$. Each cube $(i,j,k)$ can be reinforced at some cost, and if we choose to reinforce it, we pay $V(i,j,k)$.

codeforcescompetitive-programming
CF 106073K - Knockout, swiss and other kinds of tournaments

We are asked to design a tournament population so that a very specific elimination system can run without ever getting stuck. Each player starts with zero wins and zero losses. A match always produces a winner and a loser.

codeforcescompetitive-programming
CF 106073F - Frangolino ali na mesa

We are given a sequence of commands processed by a robot that moves between restaurant tables and records orders. The robot starts at table 1.

codeforcescompetitive-programming
CF 106073B - Baralho Alho

We start with a deck of N positions. Each position initially holds a card with some value, and we are given a target arrangement describing what value we want at each position after repeated shuffles.

codeforcescompetitive-programming
CF 106082J - Desert Travel

I can’t write a correct Codeforces editorial for this yet because the actual problem content is missing. What you provided (“Desert Travel”, “Hard fence”, empty input/output section) doesn’t contain the rules of the problem: there’s no description of the…

codeforcescompetitive-programming