brain

tamnd's digital brain — notes, problems, research

41641 notes

CF 105633H - Remodeling the Dungeon 2

The dungeon is given as a grid where only certain cells are actual rooms. Between neighboring rooms there may be doors embedded in the walls, and these doors define an undirected graph: each room is a node, and each door connects two adjacent rooms.

codeforcescompetitive-programming
CF 105632K - Brotato

A run in this game is a sequence of $n$ levels that must all be cleared in order. At each level, a single attempt either succeeds with probability $1-p$ or fails with probability $p$.

codeforcescompetitive-programming
CF 105632H - The Witness

We are given a rectangular grid where each cell is colored either black or white. The grid is naturally embedded on a vertex lattice: an $n times m$ cell grid corresponds to $(n+1) times (m+1)$ lattice vertices, and moves are allowed only along unit edges between adjacent…

codeforcescompetitive-programming
CF 105631E - Erasing Numbers

We are given a binary sequence written on a board. Each position contains either 0 or 1, and two players play alternately starting from the leftmost turn. Alice is responsible for interacting with zeros, while Bob is responsible for interacting with ones.

codeforcescompetitive-programming
CF 105629I - 倒反天罡

We are given a sequence of cats, each cat having an age and a binary label that represents whether it is believed to be “senior” or “junior”. For a query, we look only at a contiguous segment of cats, and we are allowed to select exactly $k$ cats from that segment.

codeforcescompetitive-programming
CF 105615N - Pentiment - Mark of Submission -

The statement you provided is not actually sufficient to reconstruct a Codeforces problem. What is visible is only the title, a stray “N”, and some formatting artifacts (“Lament Rain”, time/memory limits), but the core definition of the task is missing: there is no…

codeforcescompetitive-programming
CF 105608D - Два шифра

We are given two integers that represent a desired result of some hidden encoding process applied to a string of lowercase Latin letters.

codeforcescompetitive-programming
CF 105592D - Шоколадка

We start with a rectangular chocolate bar of size $n times m$. The final goal is to end up with a square chocolate, but the allowed operation is not free-form cutting.

codeforcescompetitive-programming
CF 105591B - Последовательный треугольник

We are asked whether it is possible to form a triangle whose side lengths are three consecutive natural numbers and whose perimeter equals a given value $p$. A valid triangle in this setting is fully determined by a starting integer $a$.

codeforcescompetitive-programming
CF 105588I - Items

We are given several independent test cases. In each test case, there are $n$ types of items. Each type can be used any number of times, including zero, and every item of type $i$ has a fixed weight $wi$.

codeforcescompetitive-programming
CF 105588E - Extracting Weights

We are given a fixed tree with $n$ nodes. Each node $i$ hides a value $wi$, with the root node $1$ guaranteed to have value $0$. The only way to obtain information is by querying pairs of nodes $(u, v)$.

codeforcescompetitive-programming
CF 105586C - 交通要塞

We are moving along a straight corridor divided into vertical “lanes” indexed from 0 to n + 1. Time is discrete. At each second, you either stay in your current lane or move exactly one lane to the right.

codeforcescompetitive-programming
CF 105586E - 黑塔的奇物

We are asked to arrange $n^2$ items on an $n times n$ grid. Each item has a type from $1$ to $n$, and each type appears exactly $n$ times, so the multiset is perfectly uniform.

codeforcescompetitive-programming
CF 105583D - Delicious Pizza

We are given points on the boundary of a unit circle. Each point is specified by an angle, and these points represent available endpoints for straight cuts inside the circle.

codeforcescompetitive-programming
CF 105583H - Harvest

We are given a tree where each node represents a tree in a plantation and each node initially contains some number of mango batches. Two people operate on this tree: Bob and Alice.

codeforcescompetitive-programming
CF 105582M - Maximum Paths

The structure is a complete binary tree where every node from 2 onward has a parent given by integer division by two. This makes the topology fixed and implicit: node 1 is the root, node 2 and 3 are its children, node 4 to 7 are next level, and so on up to n.

codeforcescompetitive-programming
CF 105582G - Glasses of Solutions

We are given several containers, each containing a liquid solution. For each container we know two values: the total mass of the solution and how much of that mass is salt.

codeforcescompetitive-programming
CF 105582A - Apple

We are given an undirected simple graph with at most 100 vertices and 100 edges. The task is not to “draw” anything geometrically in a computational sense, but to decide whether this graph can be interpreted as a very specific structure called an apple.

codeforcescompetitive-programming
CF 105581C - File Manager

The input describes a directory structure through a list of file paths. Each path represents a file located somewhere inside a hierarchy of directories separated by slashes.

codeforcescompetitive-programming
CF 105581J - Origami

We start with a right isosceles triangular sheet of paper. Think of it as a 45-45-90 triangle. Vitya repeatedly folds this triangle along lines that split it into two congruent parts.

codeforcescompetitive-programming
CF 105580A - Forks

We are given five collections, each collection containing exactly five integers. Each integer describes a fork by the number of tines it has. Two forks are considered identical if their integer labels match. A “set” here is really a multiset of five integers.

codeforcescompetitive-programming
CF 105580E - Millionaire

We maintain an array of bank balances indexed from 1 to N. Initially each account already contains some integer amount, and then we must process a sequence of operations that modify or query this array. There are two update operations and one query operation.

codeforcescompetitive-programming
CF 105579E - Uniform Square Tiling

We are given an $n times n$ grid representing a tiled wall. Each cell contains either a gold tile, written as G, or a silver tile, written as S. We are also given an integer $k$, and we want to choose a contiguous $k times k$ sub-square of this grid.

codeforcescompetitive-programming
CF 105579D - Fibonacci Grouping

We are given a line of $n$ people indexed from 1 to $n$. The process repeatedly forms a group from the current line by selecting all positions whose indices are Fibonacci numbers.

codeforcescompetitive-programming
CF 105578E - Light Up the Grid

We are working with a fixed 2 by 2 binary grid, so every configuration is a 4-bit state. Each operation flips bits in a specific pattern: either one cell, an entire row, an entire column, or all four cells at once.

codeforcescompetitive-programming
CF 105578B - Magical Palette

We are given a grid with $n$ rows and $m$ columns. Before filling the grid, we assign one number to each row and one number to each column. Call the row values $a1 dots an$ and the column values $b1 dots bm$.

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

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

codeforcescompetitive-programming
CF 105570G - Soccer (soccer)

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

codeforcescompetitive-programming
CF 105562M - Mouse Trap

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

codeforcescompetitive-programming
CF 105562G - Glued Grid

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

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

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

codeforcescompetitive-programming
CF 105400A - Spilled Milk I

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

codeforcescompetitive-programming
CF 105400I - Lost

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

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

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

codeforcescompetitive-programming
CF 105327G - Geography of Rivers

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

codeforcescompetitive-programming
CF 105327K - Karamell

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

codeforcescompetitive-programming
CF 105327J - Journey through Colors

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

codeforcescompetitive-programming
CF 105327A - Attention to the Meeting

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

codeforcescompetitive-programming
CF 105325C - Brothers

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

codeforcescompetitive-programming
CF 105322F - Tetris

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

codeforcescompetitive-programming
CF 105321G - Garlands

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

codeforcescompetitive-programming
CF 105321N - New Dimensions

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

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

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

codeforcescompetitive-programming
CF 105321D - Duo

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

codeforcescompetitive-programming
CF 105319B - Broken String

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

codeforcescompetitive-programming
CF 106030D - 有限小数

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

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

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

codeforcescompetitive-programming
CF 106026I - Emotional Flutter

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

codeforcescompetitive-programming
CF 106026D - Fever Dash

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

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

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

codeforcescompetitive-programming
CF 106026G - Good Number

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

codeforcescompetitive-programming
CF 106016M - Random Spanning Tree

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

codeforcescompetitive-programming
CF 106016J - Arranged Marriage

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

codeforcescompetitive-programming
CF 106016H - Median Gcd

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

codeforcescompetitive-programming
CF 106016G - Mexy Permutation

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

codeforcescompetitive-programming
CF 106016F - Split

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

codeforcescompetitive-programming
CF 106016D - Least Uncommon Divisor

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

codeforcescompetitive-programming
CF 106016B - Colored Tree

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

codeforcescompetitive-programming
CF 106016A - The Beauty Of Homs

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

codeforcescompetitive-programming
CF 106007L - Equalize

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

codeforcescompetitive-programming
CF 106007M - Maximum Or Permutation

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

codeforcescompetitive-programming
CF 106007K - And X Elements

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

codeforcescompetitive-programming
CF 106007I - Reverse and Remove

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

codeforcescompetitive-programming
CF 106007H - Minimum Path

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

codeforcescompetitive-programming
CF 106007G - Nim Game In Byteland

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

codeforcescompetitive-programming
CF 106007E - Clean White Paths

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

codeforcescompetitive-programming
CF 106007A - GCD MEX

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

codeforcescompetitive-programming
CF 106007D - Master of the Arena

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

codeforcescompetitive-programming
CF 106007B - Random Shuffle?

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

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

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

codeforcescompetitive-programming
CF 105992K - 神之一手

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

codeforcescompetitive-programming
CF 105992J - 画圈

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

codeforcescompetitive-programming
CF 105992I - 真相

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

codeforcescompetitive-programming
CF 105992G - 矩阵

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

codeforcescompetitive-programming
CF 105992H - V 我 112.5

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

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

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

codeforcescompetitive-programming
CF 105992C - 饺子

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

codeforcescompetitive-programming
CF 105992B - 审判

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

codeforcescompetitive-programming
CF 105992D - 与或博弈

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

codeforcescompetitive-programming
CF 105986L - 等价交换

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

codeforcescompetitive-programming
CF 105986K - Capoo's stack

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

codeforcescompetitive-programming
CF 105986B - 最短路图

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

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

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

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

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

codeforcescompetitive-programming
CF 105981K - Yet Another Connecting Problem

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

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

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

codeforcescompetitive-programming
CF 105981J - Uniform Random Descent Process

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

codeforcescompetitive-programming