brain

tamnd's digital brain — notes, problems, research

41641 notes

CF 105579G - Minecraft

We are given a vertical cross-section of a Minecraft world represented as an $h times w$ grid. Each cell is either empty, a dirt block, or a gold block.

codeforcescompetitive-programming
CF 105579B - Knight's Revenge

We are given a fixed 10 by 10 chessboard-like grid. Each cell is either empty or contains an enemy. The task is to choose exactly one empty cell as a starting position. From that position, we consider all cells that a chess knight can reach in a single move.

codeforcescompetitive-programming
CF 105578L - The Grand Contest

We are given a chronological log of submissions made by two teams during a programming contest. Each submission belongs to one of the two teams, targets a problem, arrives at a specific time, and is either correct or incorrect.

codeforcescompetitive-programming
CF 105578H - Guide Map

We are given a complete graph on $n$ cities, but only $n-2$ of its edges are marked as scenic. Those scenic edges form a structure that is almost connected, in the sense that if we were allowed to add exactly one more edge, the scenic graph would become fully connected.

codeforcescompetitive-programming
CF 105578F - Light Up the Hypercube

We are working with an n-dimensional hypercube whose 2^n vertices each hold a binary light state. A move consists of choosing one of 2^n operation types.

codeforcescompetitive-programming
CF 105578D - Dot Product Game

We are given two permutations of size $n$, call them $A$ and $B$. Think of them as two aligned sequences of weights. Their interaction is measured by the dot product, where position $i$ contributes $ai cdot bi$.

codeforcescompetitive-programming
CF 105578A - Safety First

We are asked to count how many different “stable ladders” can be formed using exactly n segments, where each segment has a positive integer length and the sequence of lengths is non-increasing from left to right.

codeforcescompetitive-programming
CF 105575J - 我喜欢回文串

We are given a string that may contain lowercase letters and wildcard characters. Each wildcard can be replaced by any lowercase letter.

codeforcescompetitive-programming
CF 105575A - 统计选手

The task describes a very small computation: four integers are provided as input, and the program must output their total sum. There is no additional structure, no hidden transformation, and no dependency between the numbers beyond simple addition.

codeforcescompetitive-programming
CF 105575D - Permutation with MAX Score

We are given multiple independent queries, each query consists of a single integer $n$. For each $n$, we need to compute a value that depends on how far we can repeatedly apply a specific growth process starting from a fixed base expression derived from small integers.

codeforcescompetitive-programming
CF 105570E - Horse Racing In The Wilderness (horse)

We are given $N$ competitors. Each competitor $i$ has an unknown parameter $hi$, which represents how fast they finish. Smaller values of $hi$ always correspond to earlier finishing times, so the final ranking is exactly the ordering of all $hi$ in increasing order.

codeforcescompetitive-programming
CF 105570C - Get Out Away (getoutaway)

We are given a weighted tree of up to 500,000 nodes. Two people start from the same unknown city and then take turns moving through the tree. On a turn, the active person may move to a neighboring city as long as that city has never been visited by either person before.

codeforcescompetitive-programming
CF 105562J - Jib Job

Each crane sits at a fixed point on the plane and has a vertical tower height. From the top of each tower, we attach a rotating horizontal beam. The beam length must be a positive integer and cannot exceed the tower height.

codeforcescompetitive-programming
CF 105562K - Kruidnoten

We are working on a weighted graph where intersections are nodes and cycleways are undirected edges with positive lengths. Karlijn starts at node 1 and wants to reach node n. Some nodes contain shops.

codeforcescompetitive-programming
CF 105562D - Dutch Democracy

We are given a collection of political parties, each with a certain number of seats. A “coalition” is simply a subset of these parties. We want to count how many subsets satisfy a very specific notion of being a valid governing coalition.

codeforcescompetitive-programming
CF 105562E - Evolving Etymology

We start with a string of length n and a transformation that builds a new string from a doubled version of itself. Each application takes the current string t, forms t + t, and then keeps characters at positions 0, 2, 4, ... of that doubled string.

codeforcescompetitive-programming
CF 105400D - Cool Sort

We are given a permutation of the numbers from 1 to N arranged in a line. The goal is to transform this permutation into the sorted order 1 through N using swaps, but with a strict restriction on what swaps are allowed.

codeforcescompetitive-programming
CF 105400K - Powerful Swaps (Hard Version)

We are given an array and asked whether it can be transformed into a sorted array using adjacent swaps, but with a constraint that makes swaps progressively harder as the process goes on. The operation is not a standard swap.

codeforcescompetitive-programming
CF 105400E - Is this Segment Tree Beats?

We are given the final state of an array where every element is between 1 and 10. This array did not start in this form. Instead, it was transformed by repeatedly applying global operations over the entire array.

codeforcescompetitive-programming
CF 105327E - Enigma of the Jewelry Case

We are given an $N times N$ grid of integers representing a square jewelry box. Each cell contains a distinct number of pearls, and in the intended correct configuration the values increase strictly from left to right along every row and also increase strictly from top to…

codeforcescompetitive-programming
CF 105327L - Lecographically Maximum

We are given an array of integers, and we are allowed to repeatedly apply an operation that swaps individual bits between two numbers at the same position. If we pick two indices and a bit position, we can exchange whether that bit is 0 or 1 between the two numbers.

codeforcescompetitive-programming
CF 105327D - Decrease the Boss Strength

We are given a starting value $N$, which we can think of as the “health” of a boss. We also have $M$ operations, called spells. Each spell has two parameters $ai$ and $bi$.

codeforcescompetitive-programming
CF 105325B - Expensive Transport

We are given a directed weighted graph with a distinguished start node, node 0. A traveller moves along edges, but the cost model is not the usual shortest path.

codeforcescompetitive-programming
CF 105325E - Game on a Graph

We are given an undirected graph whose vertices are labeled from 0 to n−1. The graph is split into connected components, and the structure changes as the game progresses because vertices are permanently removed.

codeforcescompetitive-programming
CF 105323D - 战至终章

We are given a set of nodes, each representing a demon. Every node has a required strength threshold, a reward strength increase, and a set of prerequisite “keys”.

codeforcescompetitive-programming
CF 105322A - Coin

We are tracking a single participant, Eric, who starts at a fixed position among $n$ people ordered by rank. Each round pairs people into disjoint matches.

codeforcescompetitive-programming
CF 105321L - Games

We are given an array of integers and many queries, each query focuses on a contiguous segment of that array. For each segment, two players play a turn-based game where they can either pick an unused element from that segment or pass their turn.

codeforcescompetitive-programming
CF 105321E - Final Showdown

We are given a hero who starts with a fixed amount of power points. There are N weapons, and each weapon can be used at most once. Every weapon has three parameters A, B, and C.

codeforcescompetitive-programming
CF 105319A - Gym Tournament

We are given a collection of plates, each plate has a weight and a width. From these plates, we are allowed to pick some subset and then split that chosen subset into two disjoint groups, representing the left and right sides of a barbell. Plates not chosen are simply ignored.

codeforcescompetitive-programming
CF 105319I - The Math Guy

We start with an array that initially contains the integers from 1 to n in sorted order. The process repeats exactly n times, and each repetition consists of two actions performed on the current array. First, we remove the median element of the array.

codeforcescompetitive-programming
CF 105575K - 青春小M不会梦到兽耳娘

We are given several two-dimensional integer vectors. Each vector represents a step you are allowed to use, and you are allowed to take integer linear combinations of these vectors, meaning you can add or subtract them any number of times and scale them by integers.

codeforcescompetitive-programming
CF 105575G - The Greatest War

We are given three collections of integers. You can think of them as three types of resources that must be matched over time: one set represents units that “live” through damage, and the other two sets represent equipment that either protects them or increases their…

codeforcescompetitive-programming
CF 105575B - A Typical Codeforces Round

Each problem instance consists of three arrays of length $n$, which we can think of as per-problem parameters. For each index $i$, there are fixed values $ai$, $bi$, and $ci$.

codeforcescompetitive-programming
CF 105570H - The Taiko Problem (taiko)

We are given a rhythm chart of length $N$. Each position is either a note requiring a hit (D or K) or a rest (.). Every non-rest position must be assigned exactly one hand, either left or right, meaning we construct an assignment string $T$ where $T[i] in {L, R}$ if $S[i] neq '.

codeforcescompetitive-programming
CF 105570B - Growing Cucumbers (cucumber)

We are building a sequence of integers $a1, a2, dots, an$. Each value $ai$ must stay within its personal range $[1, bi]$.

codeforcescompetitive-programming
CF 105562H - Hash Collision

We are given a hidden function $f$ that maps every integer from $1$ to $n$ back into the same range. We do not see the function directly. Instead, we can ask queries of the form “apply $f$ exactly $c$ times starting from $r$” and receive the resulting value $f^c(r)$.

codeforcescompetitive-programming
CF 105562A - Alphabetical Aristocrats

We are given a collection of surnames written as free-form strings. Each surname may contain uppercase letters, lowercase letters, spaces, and apostrophes.

codeforcescompetitive-programming
CF 105556J - Swap, Splice and Modulus

We are working with an infinite sequence formed by repeating a base array of length $n$. Think of the sequence as an endless tiling of the initial block, so position $k$ always maps back to some position inside the first block using modulo arithmetic.

codeforcescompetitive-programming
CF 105400B - Spilled Milk II

Codeforces 105400B: Spilled Milk II

codeforcescompetitive-programming
CF 105400H - Pirate's Booty

We have a line of ships, each ship behaving like a container with a fixed maximum number of crate slots. Initially all ships are empty. Over time, crates are poured into a chosen ship index.

codeforcescompetitive-programming
CF 105400C - Mex Rectangle

We are given a grid of integers, and we are allowed to choose any axis-aligned subrectangle. For each such subrectangle, we compute the mex of all values inside it, and we want the maximum possible mex over all choices.

codeforcescompetitive-programming
CF 105327H - Harmonics with Interference

We are given two binary strings that were transmitted together, but some positions may have been corrupted into a wildcard symbol . One string represents a large binary number, the other represents a much smaller binary number.

codeforcescompetitive-programming
CF 105327C - Couple of BipBop

We are given an array of length $N$, and we can think of it as a “choreography”, where each position contains a move identifier. Two dancers independently pick starting positions uniformly at random, and from their chosen positions they both move forward step by step.

codeforcescompetitive-programming
CF 105325D - Jordan's Castles

We are given several independent castles. Each castle is described by a non-increasing sequence of tower heights, where each value represents how many blocks are stacked in a vertical column.

codeforcescompetitive-programming
CF 105323F - 810975

Codeforces 105323F: 810975

codeforcescompetitive-programming
CF 105323C - gcd hard version

Codeforces 105323C: gcd hard version

codeforcescompetitive-programming
CF 105322B - Game

Codeforces 105322B: Game

codeforcescompetitive-programming
CF 105322D - Iwanna

We are given a tree where each edge has a positive weight. For every query, we pick a start node s and a target node t, and we simulate a random walk with a very specific memory rule until we reach t. The process always starts at s.

codeforcescompetitive-programming
CF 105321J - Never Add Up to X

Codeforces 105321J: Never Add Up to X

codeforcescompetitive-programming
CF 105321I - Innovations in Robotics

We are given a grid with up to 1000 rows and 1000 columns. Each cell is either dry or wet. The robot must traverse the grid in a very constrained geometric way: it moves only in straight axis-aligned segments, and it can only change direction when it is currently on a dry cell.

codeforcescompetitive-programming
CF 105321C - Discovering Ngipto

We are working in a 2D desert plane that contains a simple polygon representing the footprint of a pyramid base, and a single point above the plane representing the sun.

codeforcescompetitive-programming
CF 105319J - F Less Than G

We are given two arrays of the same length. The first array contributes a cost on any segment through the sum of squares of its values, while the second array contributes a value on a segment through the bitwise OR of its elements, squared.

codeforcescompetitive-programming
CF 105319F - We Want a Lesson

We are given a sequence of short text messages, and for each one we must decide how to respond based on a single special phrase.

codeforcescompetitive-programming
CF 105319L - Hosen and The Magical Tree!

We are given a weighted tree with up to 100000 vertices. Each edge has a weight that can change over time. Alongside these updates, we must answer queries about pairs of vertices. A type 2 query gives two vertices u and v. Consider the unique simple path between them.

codeforcescompetitive-programming
CF 105319G - Less is More

We are given a positive integer $n$. For each $n$, we look at the polynomial expression $$(a+b)^n - a^n - b^n$$ and we ask for which moduli $m$ this expression is always divisible by $m$, no matter which natural numbers $a$ and $b$ we choose.

codeforcescompetitive-programming
CF 105319D - Lazy Jaber

We are given an array of integers and we want to count how many of its contiguous subarrays can be made non-decreasing after applying a very specific operation.

codeforcescompetitive-programming
CF 105319K - CP and GIT

We are given a collection of uniquely named files. Some of them are currently placed in a special area called Stage, while the rest are in Workspace. We are also given a target set of files that must end up exactly in Stage at the end, with all other files outside Stage.

codeforcescompetitive-programming
CF 105319H - Divide And Multiply

We are given an array of integers and we are allowed to repeatedly modify individual elements using two operations.

codeforcescompetitive-programming
CF 105319E - Sorting Cards

We are constructing a sequence of $N$ cards, where each card has two attributes: a number in the range $1$ to $M$, and a color in the range $1$ to $K$.

codeforcescompetitive-programming
CF 105319C - Leafilians

We are given a tree for each test case. Two players, George and Mohamed, take turns acting on this tree. On every turn, the player performs exactly one of two operations: either they remove all current leaves of the tree, or they choose a single leaf to preserve and remove all…

codeforcescompetitive-programming
CF 105321M - Balloon Market

We are given a sequence of layovers along a trip. At the start, Pedro owns up to K balloons, and he carries them through all layovers without ever replenishing inventory.

codeforcescompetitive-programming
CF 105321K - Typographic Kaleidoscope

We are given a large grid of characters consisting only of and .. Inside this grid, there is a hidden tiling: every belongs to exactly one rigid pattern, and each pattern is an unscaled copy of one of three fixed ASCII shapes representing the letters T, A, and P.

codeforcescompetitive-programming
CF 105321H - Electric Fence for Livestock

We are given a plane containing axis-aligned rectangular fences. These rectangles are disjoint in the strong sense that their boundaries do not touch at all, so the plane is partitioned into regions separated by these rectangular obstacles.

codeforcescompetitive-programming
CF 105321F - Fixture

We are given a chronological record of tennis matches played by a single player. Each match results in either a win or a loss, encoded as a binary array where 1 represents a win and 0 represents a loss. The scoring system has two independent components.

codeforcescompetitive-programming
CF 105321B - Period Search

We are given a hidden string of length $N$, but we never get to see it directly. Instead, we can ask queries about substrings, and each query asks whether a chosen substring $t = s[L..R]$ is a valid period of the entire string.

codeforcescompetitive-programming
CF 105322E - League of Legends

We are looking at a very simplified combat process between two entities with health values. Eric starts with n health points and Clamee starts with m health points.

codeforcescompetitive-programming
CF 105322C - Genshin Impact

We are given a lowercase string $S$. From this string, Eric defines a family of “forbidden words” in a slightly unusual way: take the multiset of characters in $S$, form any permutation of it, and then take any subsequence of that permutation.

codeforcescompetitive-programming
CF 105323E - LOL

We are given a string consisting only of two characters, L and O. Over this string we must support two kinds of operations on any contiguous substring.

codeforcescompetitive-programming
CF 105323A - 二度树上的染色游戏

We are given a rooted tree where every node has at most two children. The root is node 1, and each node has an associated weight. Initially only the root is colored red, all other nodes are white. The process evolves in discrete rounds.

codeforcescompetitive-programming
CF 105325A - Baq and the Distances Between Cities

We are asked to assign weights to every edge of a complete graph on $n$ labeled cities. There are $frac{n(n-1)}{2}$ undirected edges, and we must place each integer from $1$ to $frac{n(n-1)}{2}$ exactly once.

codeforcescompetitive-programming
CF 105327I - Ingredients that may Harm You

Each food item is labeled by a number, and that number should be thought of as a multiset of prime factors. If a food has value 12, it really means it contributes ingredients 2, 2, and 3.

codeforcescompetitive-programming
CF 105327F - Fractions are better when continued

We are given a recursively defined family of fractions built from a repeating nested pattern of the form “one divided by one plus something similar”.

codeforcescompetitive-programming
CF 105327B - Bacon Number

We are given a collection of movies, where each movie contains a set of actors. Two actors are considered directly connected if they appear together in at least one movie.

codeforcescompetitive-programming
CF 105400G - Powerful Swaps (Easy Version)

Codeforces 105400G: Powerful Swaps (Easy Version)

codeforcescompetitive-programming
CF 105556B - Good Array

We process a stream of numbers, and after each new element we look at the current prefix as a set. The question is whether this set could be exactly the set of all positive divisors (restricted to the range $1 ldots m$) of some integer $b$.

codeforcescompetitive-programming
CF 105562L - Limited Library

We are given a library shelving system where each shelf can hold a fixed number of books if it is used purely for books. However, a shelf can optionally also display an art piece, which reduces the effective capacity of that shelf for books.

codeforcescompetitive-programming
CF 105562I - It's a Kind of Magic

We are working with a $3 times 3$ grid filled with positive integers. The grid is considered valid when every row, every column, and both diagonals have the same product.

codeforcescompetitive-programming
CF 105562F - Flowing Fountain

We are given a vertical stack of bowls, each bowl sitting above the next one. Every bowl has a fixed capacity, and we process two kinds of operations over time. One operation pours some amount of champagne into a chosen bowl.

codeforcescompetitive-programming
CF 105562B - Binary Search

We are given an undirected graph where each vertex carries a label, either 0 or 1. A walk is formed by choosing a starting vertex and repeatedly moving along edges, writing down the label of each visited vertex. This produces a binary string.

codeforcescompetitive-programming
CF 105570I - Huge Cannon Volleyball (volleyball)

Each team is represented by a permutation of size $N$, where position $i$ corresponds to a player with some height rank. The opponent’s lineup is partially observed: some positions are known exactly, and the rest are missing.

codeforcescompetitive-programming
CF 105570F - Railway Renovation (rail)

We are given an undirected connected graph where towns are vertices and railway lines are edges. Each edge must be assigned one of two labels, Red or Blue.

codeforcescompetitive-programming
CF 105570A - Challenges in Bolivia (challenges)

I can’t reliably reconstruct the actual problem from the text you provided, and the missing parts change the meaning in a way that affects both the solution and the correctness guarantee.

codeforcescompetitive-programming
CF 105575H - YiYi Loves Beautiful Number String

We are working with a string made of decimal digits. The string changes over time through point updates, where a single position is modified, and after each modification we must decide whether the current string can be partitioned into some number of contiguous groups that…

codeforcescompetitive-programming
CF 105575F - 全能猫娘的烦恼

We are given a collection of tasks. Each task has a processing time and a deadline-like constraint that represents the latest moment by which it must be completed.

codeforcescompetitive-programming
CF 105575C - 猫娘魔法

We are given a single string that encodes a sequence of fixed-size tokens. Each meaningful token is exactly 5 characters long, and the string should be viewed as a concatenation of such 5-character blocks.

codeforcescompetitive-programming
CF 105578K - Fragile Pinball

We are given a small convex polygon, with at most six vertices, and a point-like ball moving in a straight line inside it. The ball travels continuously at constant speed, and its motion is only affected when we actively trigger reflections on polygon edges.

codeforcescompetitive-programming
CF 105578G - Guess the Polygon

We are given a simple polygon whose vertices are all integer points inside a 1000 by 1000 grid, but the vertices are presented in a completely shuffled order, so we cannot directly recover edges or adjacency.

codeforcescompetitive-programming
CF 105578C - Crisis Event: Meteorite

We are given a one-dimensional battlefield, a line of $n$ cells. Some cells initially contain characters. Over $m$ rounds, each cell receives meteorites, and these meteorites accumulate over time instead of disappearing.

codeforcescompetitive-programming
CF 105579I - Dormitory Mapping

We are given a connected undirected graph with n vertices and m edges. The vertices are already labeled with a “new” numbering from 1 to n, which is fixed in the input.

codeforcescompetitive-programming
CF 105579F - Optimal Arithmetic Sequence

We start from the number 1 and are given a multiset of small arithmetic operations. Each operation is a pair consisting of one of four symbols and a digit from 1 to 9.

codeforcescompetitive-programming
CF 105579C - The Thermotaur Labyrinth

The labyrinth can be viewed as an $N times N$ grid where each cell has a unique integer temperature. From any cell, a minotaur is allowed to move to one of the four adjacent cells if it chooses.

codeforcescompetitive-programming
CF 105580I - Satelite Internet

We are given a set of satellites, each represented as a point in the upper half-plane, and a train route that is a horizontal segment on the x-axis. There is also a single obstacle segment representing a cloud.

codeforcescompetitive-programming
CF 105580F - Volume

We are given a system that produces a total “volume”, initially at some value $M$. We want to adjust a set of $N$ independent regulators so that the final volume becomes exactly $V$.

codeforcescompetitive-programming
CF 105580B - Producer

We are given three parallel lists, each of length $N$, representing musicians of three different roles: guitarists, bassists, and drummers. Each musician has a skill value, and we must form exactly $N$ groups, where each group contains one person from each role.

codeforcescompetitive-programming
CF 105581I - Conflagration

We are given an n by n grid representing a square battlefield. Some cells are initially on fire, and the rest are empty. A knight starts on any empty cell and tries to escape by eventually moving outside the grid. Time progresses in discrete steps.

codeforcescompetitive-programming
CF 105581F - Equity

We are given an array of integers. In one move, we are allowed to pick a contiguous segment where all values are identical and increase every element in that segment by one.

codeforcescompetitive-programming
CF 105581B - Patrol

We are given a police officer who continuously patrols back and forth along a straight segment between two fixed points A and B at unit speed.

codeforcescompetitive-programming
CF 105582K - King's Island

We are asked to construct a simple polygon with exactly n vertices, where n is at most 30. Each vertex must lie on integer coordinates inside a bounded grid.

codeforcescompetitive-programming
CF 105582F - Flight Trip

We are flying on a sphere where the only reliable sensor is a stream of local time values. The target is a fixed geographic point given in latitude and longitude, and the goal is to physically reach it with very high precision.

codeforcescompetitive-programming
CF 105582B - Bar charts

We are given two ways of describing histograms built from the same underlying sorted data set. Each description splits the number line into equal-width intervals and counts how many elements of the hidden array fall into each interval.

codeforcescompetitive-programming