brain

tamnd's digital brain — notes, problems, research

41641 notes

CF 105418H - AI Takeover

We start with a population of AI bots arranged in levels. Initially there are only level-n bots, and there are k of them. Time advances in fixed 5-minute steps, and at each step every bot performs exactly one action.

codeforcescompetitive-programming
CF 105418G - Odd Non Primes

We are given several independent test cases. Each test case is a sequence of integers representing a row of cards.

codeforcescompetitive-programming
CF 105418F - Oddly Even Challenge

We are asked to count how many integers in the range from 0 up to a given large number satisfy a positional digit rule. The rule depends on writing each number in decimal and looking at its digits from left to right using 1-based indexing.

codeforcescompetitive-programming
CF 105418E - Magical Coins

We are given a set of coin denominations that follow a very structured pattern: each coin is a number consisting entirely of digit 1, and the lengths grow in a special way. So we get values like 11, 111, 1111, 11111, and so on, continuing indefinitely.

codeforcescompetitive-programming
CF 105418D - Harsh and profits

The problem describes a profit process that grows in a very structured way. On the first day Harsh earns nothing, and each next day his daily gain increases by exactly one more unit than the previous increase.

codeforcescompetitive-programming
CF 105418A - Phoenix Against the Monsters

We are given a directed network of cities connected by roads, where each road has a non-negative cost representing how many monsters Phoenix must fight if he travels along it. Phoenix starts at city 1 and must reach city n using any sequence of directed roads.

codeforcescompetitive-programming
CF 105418B - Spidey and the Palindrome Sequence

We are given a string and we are allowed to rearrange its characters arbitrarily. After rearrangement, we want to split the resulting string into several consecutive blocks. Every block must be a palindrome and all blocks must have the same length.

codeforcescompetitive-programming
CF 105423E - 拼接串

We are given a long sequence of integers, each value lying between 1 and 18. From this sequence we are allowed to pick two contiguous subarrays, and then concatenate them in order to form a new sequence.

codeforcescompetitive-programming
CF 105423K - 渡劫

We are given a connected undirected graph with $n$ islands and $m$ tunnels. Each island has a cost $ai$, representing the energy needed to perform a ritual if you are currently on that island. Each tunnel connects two islands and has a travel cost.

codeforcescompetitive-programming
CF 105423J - Beautiful Sequence

We are given two permutations of the numbers from 1 to n. The task is to count how many sequences are simultaneously subsequences of both permutations, under a very specific structural constraint.

codeforcescompetitive-programming
CF 105423I - 数据检索系统

We are building a simplified membership system that behaves like a hash-filtered set with multiple hash functions. The system stores elements in a binary array of size n, initially all zeros.

codeforcescompetitive-programming
CF 105423H - 经文

We are given a target pattern string $s$ and we want to build strings of length $n$ using lowercase English letters. Inside each constructed string, we look for occurrences of $s$ as contiguous substrings.

codeforcescompetitive-programming
CF 105423G - Utakotoba

We are given a line of n positions, each holding a 15-bit non-negative integer. We are allowed to perform an operation on any adjacent pair of positions.

codeforcescompetitive-programming
CF 105423F - 阅读理解

We are given a tree that comes from a transformation process applied to some directed graph. The process runs a depth-first search, assigns discovery times, maintains a stack of vertices, and whenever a specific low-link condition is met it creates a new auxiliary node and…

codeforcescompetitive-programming
CF 105423D - Too much noise!

We are given a collection of signals. Each signal has two numeric attributes: an energy value and a frequency value. The task is to consider every ordered pair of signals and accumulate a cost defined by a product of two independent parts.

codeforcescompetitive-programming
CF 105423B - HolyK's Land

We are given a tree of cities. Each query activates a consecutive block of “movie options”, and each option corresponds to selecting all cities along the unique tree path between two given endpoints.

codeforcescompetitive-programming
CF 105423A - 贪吃蛇

We are given a set of points on a 2D plane, each representing a coin. A snake starts at the origin and can only move in two directions: right and up, meaning in whatever coordinate system we choose, its x coordinate and y coordinate never decrease along its path.

codeforcescompetitive-programming
CF 105423C - easy math

We are given a small list of numbers, each of which is a power of two. That means every element can be written as $2^{ki}$ where the exponent $ki$ is a small non-negative integer.

codeforcescompetitive-programming
CF 105424K - Apocalypse

We are given a convex polygon that represents an initial infected region on an infinite plane. Over time, the infection expands outward in a very structured but not explicitly geometric way: the only guarantee is that the “shape family” preserves radial ordering from the…

codeforcescompetitive-programming
CF 105424I - Snakes\&Snakes

We are given a one-dimensional board of size $N$, where a token starts at cell 1 and wants to reach cell $N$. Between these endpoints, some cells contain “snakes” that push the token left by a fixed amount whenever it lands there.

codeforcescompetitive-programming
CF 105424J - Binary Trees

We are given two rooted binary trees on the same set of vertices labeled from 0 to N−1. The first tree is the initial configuration, and the second tree is the target configuration.

codeforcescompetitive-programming
CF 105424D - Klyukalo

We are given a construction made of $N$ independent parts. Each part has a required standard weight $si$, and the current configuration has weight $ai$.

codeforcescompetitive-programming
CF 105427K - Karl Coder

We are given an array-like buffer of length $2N$, but $N$ is unknown. The structure of this buffer is very specific: the first $N$ positions store nonzero bytes, while the remaining $N$ positions store zeros.

codeforcescompetitive-programming
CF 105427J - Jamboree

We are given a collection of items, each with a positive size, and a fixed number of scouts. Each item must be assigned to exactly one scout. A scout can carry at most two items, and the load of a scout is the sum of the sizes of items assigned to them.

codeforcescompetitive-programming
CF 105427I - Intertwined

A rope is initially stretched from the origin to a fixed point on the positive x-axis. We then start rotating this rope counter-clockwise around whichever point is currently acting as its pivot. At the beginning, the pivot is the origin.

codeforcescompetitive-programming
CF 105427G - Groups of Strangers

We are given a social graph of employees where edges represent mutual acquaintance. The task is to split all employees into three groups such that no two people who know each other end up in the same group.

codeforcescompetitive-programming
CF 105427H - Heroes of Velmar

We are given the final board state of a two-player card game after all six turns have already been played. The board consists of three independent locations. At each location, each player may have placed up to four cards, and each card contributes a fixed power value.

codeforcescompetitive-programming
CF 105427E - Electronic Components

Each electronic component belongs to a type, and every type comes with a processing time. There are multiple copies of each type.

codeforcescompetitive-programming
CF 105427D - Die Hard

We are given three different dice. Each die has six faces, but the values on those faces are arbitrary integers between 1 and 1000 and can repeat. A game is played by first letting John choose one die, then Hans chooses one of the remaining two dice.

codeforcescompetitive-programming
CF 105427F - Factor-Full Tree

We are given a rooted tree with N vertices, where vertex 1 is the root. The task is to assign each vertex v a positive integer label xv such that ancestry in the tree is encoded purely through divisibility: a vertex u is an ancestor of v if and only if xu divides xv.

codeforcescompetitive-programming
CF 105427B - Berry Battle 2

We are simulating a turn based game on a long binary string where each position either contains a berry or is empty. A move consists of choosing an index $i$ and removing all berries in the fixed length segment from $i$ to $i+3$.

codeforcescompetitive-programming
CF 105427A - Aperiodic Appointments

We are building a binary sequence day by day, where each position is either zero or one. The first few days are fixed as zero. After that, each new day depends on the structure of what has already been generated.

codeforcescompetitive-programming
CF 105427C - Converting Romans

We are given a collection of strings, each string representing a number written in a simplified Roman numeral system. Each character is one of the standard Roman symbols I, V, X, L, C, D, M with fixed values 1, 5, 10, 50, 100, 500, 1000.

codeforcescompetitive-programming
CF 105430G - OMORI

We are given a set of $n$ hidden items, called dolls. Exactly one doll is special and behaves differently: whenever it is compared with any other doll, the result is always a tie.

codeforcescompetitive-programming
CF 105430F - BASIL

We are given an array of flower pots. Each pot has two attributes: a number of seeds and a type label. A move consists of choosing a pot that still contains seeds, removing any positive number of seeds from it, and then performing a global operation that depends on the type of…

codeforcescompetitive-programming
CF 105430E - MARI

We are given a starting value and then a sequence of ovens, each associated with a fixed number. When a cookie passes through an oven, that oven forces the current value either upward to at least the oven’s number or downward to at most the oven’s number.

codeforcescompetitive-programming
CF 105430D - KEL

We are given a large rectangle that is composed of four identical smaller rectangles. Each small rectangle has dimensions $L times W$, and they are arranged in a $2 times 2$ grid to form a big rectangle of size $2L times 2W$.

codeforcescompetitive-programming
CF 105430A - SUNNY

We are given two sorted sets of integers representing positions of vibrations on a huge number line. We are allowed to perform an operation where we pick a pivot position k, and every vibration strictly to the left of k moves one step further left, every vibration strictly to…

codeforcescompetitive-programming
CF 105430B - AUBREY

We are given a tree with values on nodes. For any choice of a root, every node induces a subtree, and inside that subtree we imagine choosing any subset of nodes. Each chosen node contributes its value via XOR, so each subset produces one XOR result.

codeforcescompetitive-programming
CF 105430C - HERO

We are given an array of positive integers, and every contiguous subarray contributes a value based on two factors: the least common multiple of all elements in that subarray and the product of its endpoint indices.

codeforcescompetitive-programming
CF 105431J - Jungle Game

We are given a list of forbidden “challenge points” in a two-dimensional integer grid. Each challenge is a pair of coordinates $(Pk, Sk)$, where both values lie between 2 and $2N$.

codeforcescompetitive-programming
CF 105431K - Knitting Pattern

We are given a circular sweater made of $N$ equally spaced positions. A knitting pattern of length $P$ must be placed repeatedly along this circle.

codeforcescompetitive-programming
CF 105431H - Hotfix

We are given a single string consisting of upper and lowercase Latin letters. Conceptually, an earlier problem would enumerate all distinct substrings of this string and output each substring together with how many times it appears in the original string.

codeforcescompetitive-programming
CF 105431I - Infinite Cash

We are tracking a person’s cash balance over time under two competing forces. Every day starts with an amount of money, and the person immediately spends half of whatever they currently have, rounding the amount spent upward.

codeforcescompetitive-programming
CF 105431G - Guessing Passwords

We are given a compressed “game log” from a Wordle-like system, but the actual guesses are lost. What remains is only the feedback grid: for each guess and each position, we know whether the character was marked gray or yellow.

codeforcescompetitive-programming
CF 105431E - Elapid Errands

We are working on an infinite grid where Carl starts at the origin and must physically walk step by step to a sequence of target coordinates, visiting them in the given order. Each move changes the position by exactly one unit in one of the four cardinal directions.

codeforcescompetitive-programming
CF 105431D - Double Deck

We are given two sequences representing the order of cards in two face-up decks. Each deck contains exactly $N cdot K$ cards, and the values come from the range $1$ to $N$.

codeforcescompetitive-programming
CF 105431F - Fence Fee

We are given a planar drawing formed by straight fence segments. Each segment connects two grid points, and together all segments form a single connected planar graph with no crossings and no redundant edges.

codeforcescompetitive-programming
CF 105431B - Baseball Court

We are given a rectangular field divided conceptually into unit grid positions, with dimensions $a times b$. We have exactly $N$ identical unit square tiles, and we must place all of them inside this grid. The placement is restricted in two structural ways.

codeforcescompetitive-programming
CF 105431C - Composed Rhythms

The task is to take a single integer $N$, representing a total number of beats in a musical rhythm, and express it as a sum of smaller building blocks. Each building block must have size either 2 or 3, and together they must sum exactly to $N$.

codeforcescompetitive-programming
CF 105431A - Avoiding the Abyss

We are given two distinct points on the integer grid, a start point and a target point. Between them lies an axis-aligned rectangular obstacle whose exact coordinates are unknown.

codeforcescompetitive-programming
CF 105434M - 战争游戏 II

We are given a tree where a defender starts at a fixed node and an attacker repeatedly chooses a node to “bomb” over several rounds.

codeforcescompetitive-programming
CF 105434N - 虚拟换乘

We are given a transport system that is essentially a single directed chain of stations from 0 to n − 1. Between station i − 1 and i, there is exactly one road segment with a fixed length, and that segment allows only certain transport modes chosen from a subset of K total…

codeforcescompetitive-programming
CF 105434L - 新生赛与邪恶计划

We have a classroom with seats labeled from 1 to n, and initially each seat is meant for the student with the same number. The final student of interest is student n, who is guaranteed to be a newcomer.

codeforcescompetitive-programming
CF 105434K - agKc 与太阳甩在身后

The grid is an $N times M$ board where every cell initially contains crystals except one special empty cell at $(X, Y)$. From that single empty starting point, we are allowed to place a device only on currently empty cells.

codeforcescompetitive-programming
CF 105434J - 炫耀快乐

We are given a line of students. Each student holds one “lucky number” between 1 and m, so the line can be seen as an array S of length n over m categories. We are allowed to assign a ranking to these m lucky numbers by choosing a permutation of 1 through m.

codeforcescompetitive-programming
CF 105434I - 轮符雨

We are given several independent test cases. In each one, there is a sequence representing rain intensity over consecutive days. Starting from zero, Soyo’s “anticipation value” changes every day based on how much the rain intensity changes compared to the previous day.

codeforcescompetitive-programming
CF 105434H - 父子局

Each test case gives a single integer $n$. The task is to split this number into two different positive integers $x$ and $y$ such that their sum equals $n$. If such a pair cannot exist, the output must be two negative ones.

codeforcescompetitive-programming
CF 105434G - Mobiusp的希望树

We are asked to construct a rooted tree on the vertices labeled from 1 to n, where 1 is fixed as the root. The structure of the tree is heavily constrained: every edge must go from a smaller label to a larger label, so labels strictly increase along any path from the root.

codeforcescompetitive-programming
CF 105434F - Starlight

We are given a permutation that represents stones placed in a line. Each day, the process removes the leftmost remaining stone from the ground and places it on top of a growing stack (a tower).

codeforcescompetitive-programming
CF 105434E - HoMaCoMoHa!

We start with a pile of identical level-1 entities. The system repeatedly allows a move whenever two entities share the same level i, provided i is not the maximum level k.

codeforcescompetitive-programming
CF 105434D - 股票交易

We are given a sequence of daily stock prices. You are allowed to pick at most one pair of days, buy on an earlier day and sell on a later day, and you earn profit equal to the increase in price divided by the number of days held.

codeforcescompetitive-programming
CF 105434C - LCT

We are given a rooted tree where node 1 is the root, and each edge has an index according to its input order. Every edge starts in an active state, meaning all nodes are initially fully connected. Each operation consists of two actions.

codeforcescompetitive-programming
CF 105434B - 全概率公式

We are given several independent data sources, each representing a platform that might contribute to a mixed dataset. Each platform contributes a known fraction of the total data, and each platform also has its own probability of being “AI contaminated”.

codeforcescompetitive-programming
CF 105434A - 你好,HWCWHer

The task describes five universities and asks us to “choose” one of them, then output its English abbreviation as a single uppercase string. There is no input, so the program does not receive any data to guide the choice at runtime.

codeforcescompetitive-programming
CF 105435E - Anime Marathon: Vivek vs. Sagar

We are given a sequence of distinct episodes, each assigned an integer enjoyment value. Two players alternate taking episodes from the remaining pool.

codeforcescompetitive-programming
CF 105435A - The world of JS (Jagjeet & Sagar)

We are given a schedule describing when Sagar is busy, and we need to decide whether Jagjeet’s chosen moment falls inside any of those busy periods. Sagar’s busy pattern starts at time a. After that, his availability alternates in a structured way: every cycle is based on b.

codeforcescompetitive-programming
CF 105435D - Hard Work

We are given a string for each test case, and we need to locate a contiguous substring that contains a specific multiset of letters. The required letters correspond to the word “hardwork”, but not in the usual frequency pattern of the word itself.

codeforcescompetitive-programming
CF 105435B - Divisor Query

We are given a sequence of queries, each describing a numeric interval $[l, r]$. For every query, we are asked to count how many integers inside that interval have a specific property related to their number of divisors.

codeforcescompetitive-programming
CF 105437J - Card Game

We are given a complete grid of cards indexed by suit and rank. For every suit from 1 to n and every rank from 1 to m, exactly one card exists, so the deck forms an n by m matrix. Two players split this entire set into two equal halves.

codeforcescompetitive-programming
CF 105437L - Variable Damage

We are building a growing army that changes over time, and after every update we want to know how long the battle can last if we assign equipment optimally. At any moment there are heroes, each with a health value, and artifacts, each with a durability value.

codeforcescompetitive-programming
CF 105437K - Choose Your Queries

We are building an array of size $n$, initially filled with zeros. We process $q$ operations one by one. Each operation gives us two distinct indices $xi$ and $yi$.

codeforcescompetitive-programming
CF 105437H - Maximum Beauty

We are given a string of lowercase letters. Its “score” is computed by splitting it into maximal contiguous segments of identical characters, then summing the square of each segment’s length. Long runs contribute disproportionately because squaring rewards concentration.

codeforcescompetitive-programming
CF 105437I - Attribute Checks

We are given a long ordered sequence of events in a game. Each event is either earning a single attribute point or encountering a check that depends on one of two stats, Strength or Intelligence.

codeforcescompetitive-programming
CF 105437G - Stores

We are given a set of fixed points on a number line, including the endpoints 0 and 10^9, which represent existing store locations in a city.

codeforcescompetitive-programming
CF 105437E - Binomial Coefficients, Kind Of

We are given many independent queries. Each query specifies a pair of indices $n$ and $k$, and we are asked to compute a value from a triangular table $C$ that is generated in a nonstandard way. The table is built row by row.

codeforcescompetitive-programming
CF 105437F - New Game

We are given a multiset of cards, each card carrying an integer value. Monocarp builds a sequence by picking cards one by one, removing them from the deck as he takes them.

codeforcescompetitive-programming
CF 105437D - Equal Halves

We are given an array of even length, split conceptually into two equal parts: the left half and the right half. We are allowed to perform exactly one swap, but the swap is heavily constrained.

codeforcescompetitive-programming
CF 105437C - Repainting Balls

We start with a collection of balls colored red, yellow, and green, with counts a, b, and c. We are allowed to repeatedly pick any single ball and repaint it into one of the other two colors.

codeforcescompetitive-programming
CF 105437B - Two Screens

We are given two target strings, one that must end up on the first screen and another that must end up on the second screen. Both screens start empty.

codeforcescompetitive-programming
CF 105437A - Cutting into Parts

We are given a single sheet and we repeatedly split it using full-length straight cuts. Every cut either goes from left to right across the entire current sheet or from top to bottom across the entire current sheet.

codeforcescompetitive-programming
CF 105442L - Watchdogs

We are given a town modeled as a tree with N locations connected by N − 1 roads. Because it is a tree, there is exactly one simple path between any two places. Each mouse is defined by two special nodes A and B, and it only moves along the unique path between them.

codeforcescompetitive-programming
CF 105442J - Rabid Rabbit

We are given a line of rabbit hutches, each containing some number of rabbits. For each query, we are handed a contiguous segment of this line, and Leonardo is only allowed to operate inside that segment. Each “day” he chooses a pair of distinct hutches inside the segment.

codeforcescompetitive-programming
CF 105442K - Fellow Sheep

We are given a long chain of identical structural segments. Each segment contains five directed paths, labeled A through E. Every path has a gate somewhere in the middle that allows only a limited number of sheep to pass before it permanently closes.

codeforcescompetitive-programming
CF 105442I - P||k Cutting

We are given an array of integers representing daily “cookie offers”. Each interval is a contiguous block of days, and for any chosen interval two different payment rules are applied to the same segment.

codeforcescompetitive-programming
CF 105442H - Ornithology

We are given two parallel rows of positions, both indexed from 0 to n − 1. The first row is already populated with birds, where multiple birds may start from the same position. The second row is initially empty, but each bird has a fixed target position on that second row.

codeforcescompetitive-programming
CF 105442G - Pray Mink

We are given a single integer written on a cookie tray, and we should think of it as a sequence of digits placed side by side.

codeforcescompetitive-programming
CF 105442E - Pigpartite Giraffe

We start with two disjoint groups of animals, pigs and giraffes. Initially, each pig may “talk” to some giraffes, and this relationship is symmetric, so a pig is connected to a giraffe if and only if that giraffe is connected back to that pig.

codeforcescompetitive-programming
CF 105442F - Hamster

We are given a rectangular grid where each cell contains a non-negative number representing larvae. A hamster starts at the top-left cell and must reach the bottom-right cell. At every step it moves to a neighboring cell that shares an edge, and it never revisits any cell.

codeforcescompetitive-programming
CF 105442D - Fishception

We are given a large collection of points on the plane. These points come from repeatedly relocating the corners of a rectangle over several days.

codeforcescompetitive-programming
CF 105442C - Reptile Eggs

We are given a line of eggs represented by a string. Each position contains a single concrete type, so the string is just a sequence of lowercase letters. Alongside this, we are given a pattern written in a restricted regular-expression language.

codeforcescompetitive-programming
CF 105442B - Cowpproximation

We are given several cows on a plane. Each cow starts at a fixed coordinate and occupies a circular region with a given radius. Every cow can move in any direction with speed at most one meter per second, and they all move simultaneously.

codeforcescompetitive-programming
CF 105442A - Flag Bearer

Each message consists of several symbols drawn as small 9 by 9 pictures. Every picture encodes one English letter using a semaphore system: a central pivot cell and two “arms” that extend from it in two distinct directions among the eight compass directions.

codeforcescompetitive-programming
CF 105444M - Methodic Multiplication

We are given two natural numbers, but they are not written in decimal form. Instead, each number is encoded using Peano arithmetic, where a number is represented as repeated applications of a successor function applied to zero.

codeforcescompetitive-programming
CF 105444K - Keep Calm And Carry Off

We are given two very large positive integers written in decimal, each potentially up to one million digits. Petra can modify these numbers using a very specific operation: she picks one of the two numbers, adds 1 to it, and simultaneously subtracts 1 from the other number, so…

codeforcescompetitive-programming
CF 105444L - Language Survey

We are given an $n times m$ grid, and each cell contains only partial information about how many of three unknown languages are spoken there. Every cell is marked either with 1 or 2.

codeforcescompetitive-programming
CF 105444J - Joining Flows

We are given a small number of chocolate faucets, each faucet producing chocolate at a fixed temperature, but with a controllable flow rate constrained to an interval.

codeforcescompetitive-programming
CF 105444H - Hiring and Firing

We are given a fixed schedule of how a company’s workforce changes over time. Each day, a known number of workers are fired and a known number are hired, and the system guarantees that the number of firings never exceeds the number of currently employed workers.

codeforcescompetitive-programming
CF 105444I - Infection Estimation

We are interacting with a system that hides an unknown number of infected people inside a population of fixed size. The only tool we have is a probabilistic group test: we choose a subset size k, and the judge randomly selects k distinct people.

codeforcescompetitive-programming
CF 105444G - Gig Combinatorics

We are given a sequence of songs in the order they were written. Each song has a label, which can only be 1, 2, or 3. We want to count how many contiguous subsequences of these songs form a valid “setlist”.

codeforcescompetitive-programming