brain

tamnd's digital brain — notes, problems, research

41239 notes

CF 104566E - Infinite Parenthesis Sequence

We start with a finite string of parentheses, and then extend it into a doubly infinite sequence by repeating it periodically in both directions.

codeforcescompetitive-programming
CF 104566C - Halting Problem

We are asked to construct an initial ordering of players in a knockout tournament. There are three types of players, Rock, Paper, and Scissors, with fixed counts.

codeforcescompetitive-programming
CF 104566D - Pixel Art

We are given a grid with $n$ rows and $m$ columns, initially completely white. We then paint $k$ disjoint segments on this grid.

codeforcescompetitive-programming
CF 104566B - Red Black Tree

We are given a weighted tree rooted at node 1. Some vertices are initially colored red, including the root, and all other vertices are black.

codeforcescompetitive-programming
CF 104566A - Live Love

We are given a binary-like sequence, but instead of bits it consists of two labels: PERFECT and NON-PERFECT. The sequence has fixed length n, and exactly m of its positions must be PERFECT while the remaining n - m are NON-PERFECT.

codeforcescompetitive-programming
CF 104568D - Freeform Factory

We are given a bipartite system with workers on one side and machines on the other, both of size $N$. Each worker initially knows how to operate some subset of machines. Every day, all workers arrive in an arbitrary order.

codeforcescompetitive-programming
CF 104568A - Rather Perplexing Showdown

We are asked to construct an initial ordering of players in a knockout tournament. There are three types of players, Rock, Paper, and Scissors, with fixed counts.

codeforcescompetitive-programming
CF 104568B - Red Tape Committee

We are asked to assemble a committee of exactly K people from a pool of N candidates. Each candidate behaves independently, and each one has a known probability Pi of voting “Yes”. A vote is always either Yes or No, so each candidate is a biased coin flip.

codeforcescompetitive-programming
CF 104568C - The Gardener of Seville

We are given a rectangular grid of size $R times C$. Each cell must be filled with one of two diagonal slash types, either / or .

codeforcescompetitive-programming
CF 104569D - Go++

We are asked to design two tiny concurrent programs that share a single boolean register. The register starts at 0 and can be overwritten by instructions that force it to 0 or 1.

codeforcescompetitive-programming
CF 104569C - Rebel Against The Empire

We are given a set of asteroids in 3D space. Each asteroid has an initial position and a constant velocity, so its location at time $t$ is a straight line in space. We start on asteroid 0 at time 0, and we want to reach asteroid 1.

codeforcescompetitive-programming
CF 104569B - Forest University

We are given a collection of courses that form a prerequisite forest. Each course has a single outgoing edge to its prerequisite, or no prerequisite at all. This guarantees that the structure is a directed forest of rooted trees, where edges point from a node to its parent.

codeforcescompetitive-programming
CF 104569A - Teaching Assistant

We are given a sequence of days, and on each day we are allowed to perform exactly one action among three choices: we can request a Coding problem set, request a Jamming problem set, or submit the most recently requested problem set that has not yet been submitted.

codeforcescompetitive-programming
CF 104570F - Random Noise

We are working with an array of 20-bit integers that changes over time through point updates, range operations, and probabilistic bit flips.

codeforcescompetitive-programming
CF 104570D - Balanced Permutation

We are asked to construct a permutation of the numbers from 1 to n such that there exists a split point where the sum of the prefix equals the sum of the suffix. Among all such valid permutations, we must output the one that is lexicographically smallest.

codeforcescompetitive-programming
CF 104570C - Super Palindrome

We are given a binary string and asked to count how many of its contiguous substrings satisfy a fairly strict structural property. A substring is considered valid if it is a palindrome, and if we remove its last character, the remaining prefix is still a palindrome.

codeforcescompetitive-programming
CF 104570B - Two Arrays Game

We are given two arrays of the same length, and both players ultimately interact with a shared “board” formed from those arrays. Each position holds a number, and once a number is taken it becomes zero and cannot be used again.

codeforcescompetitive-programming
CF 104570A - Coins

We are given a small “currency system” consisting of three coin types: coins worth 1, coins worth 10, and coins worth 100.

codeforcescompetitive-programming
CF 104573J - Stacking Trick

We are given a line of stacks, each stack holding some number of blocks. We are allowed to move blocks only between neighboring stacks, and we may also remove blocks from the two ends of the line by pushing them off the table.

codeforcescompetitive-programming
CF 104573I - Iguana Islands

We are given a line of islands. Each island has a fruit type and an initial quantity. On every day, a contiguous segment of islands is exposed to visitors; everything outside that segment is unavailable due to storms.

codeforcescompetitive-programming
CF 104573H - Go Iguanas!

The crash is not coming from the game logic itself but from a broken test harness / input handling layer combined with unsafe assumptions about input structure. From the traceback: the failure happens during assertion setup, not during the algorithmic computation.

codeforcescompetitive-programming
CF 104573G - Iguana Walking

We are given a directed graph where each iguana sits on a node from 1 to N, and every node has exactly one outgoing edge defined by the array p. In one time step, every iguana moves simultaneously from i to p[i].

codeforcescompetitive-programming
CF 104573F - Egg

We are given a collection of eggs, and each egg can be used in one of three ways: it can be fried, it can be scrambled, or it can be ignored completely. Each choice yields a different satisfaction value for that egg, and the values are independent across eggs.

codeforcescompetitive-programming
CF 104573D - XP Challenge

We are given a sequence of enemies, each with some health, and a creature with an initial amount of health points. The goal is to decide whether she can defeat every enemy in order while ensuring her own health never drops to zero or below. There are two attack options.

codeforcescompetitive-programming
CF 104573C - Iridescent Iguanas

We are given a collection of iguanas, each identified by an ID from 1 to N. Every iguana has two attributes: a number of scales and a number of colors. The goal is to rank these iguanas from best to worst using a pairwise comparison rule, then output the top three.

codeforcescompetitive-programming
CF 104573E - Shifty Shuffling

We are given a deck of 52 cards. Each card is represented by an integer from 1 to 13, where each value appears exactly four times.

codeforcescompetitive-programming
CF 104574H - Go Iguanas!

We are given a partially played Go board where each cell is either black, white, or empty. For each query, we are asked to imagine placing a single stone of a given color on an empty cell and decide whether that move would immediately result in at least one connected group of…

codeforcescompetitive-programming
CF 104574G - Iguana Walking

We are given a directed functional graph: each iguana i has exactly one outgoing edge to p[i], so from every node there is exactly one deterministic next position.

codeforcescompetitive-programming
CF 104574F - Egg

Each egg comes with two independent ways of extracting value: frying it gives one score, scrambling it gives another, and skipping it gives zero contribution. The constraint is that Ivan cannot freely choose all positive options.

codeforcescompetitive-programming
CF 104574E - Shifty Shuffling

We are given a fixed 52-card deck where each position contains a number from 1 to 13, with each value appearing exactly four times. Among these, the cards with value 1 are the aces and are the only cards that matter for winning.

codeforcescompetitive-programming
CF 104574D - XP Challenge

We are given a sequence of enemies lined up along Iggy’s escape path. Each enemy has some amount of health, and Iggy starts with a fixed amount of health as well.

codeforcescompetitive-programming
CF 104574C - Iridescent Iguanas

We are given a collection of iguanas, each described by two numbers: the number of scales and the number of camouflage colors. We must rank these iguanas from best to worst and output the top three IDs. The ordering rule is not a simple comparison of two values.

codeforcescompetitive-programming
CF 104574A - Iguana Playground

We are given two identical rectangular sheets, each of size $M times N$. We are allowed to cut each sheet into smaller axis-aligned rectangles using straight cuts parallel to the sides.

codeforcescompetitive-programming
CF 104574B - Preferred Valley

We are given a sequence of terrain heights that forms a very rigid shape: it starts high, goes down, comes up, goes down again, and finally rises again.

codeforcescompetitive-programming
CF 104579C - Gallery of Pillars

We are looking at an $N times N$ grid of unit cells, where every cell except the southwest corner contains a vertical cylindrical pillar. The observer stands at the exact center of the southwest cell and looks into the grid.

codeforcescompetitive-programming
CF 104579E - Radioactive Islands

We are planning a continuous path for a point moving from a fixed starting location on the left side of the plane to a fixed ending location on the right side.

codeforcescompetitive-programming
CF 104579D - Map Reduce

The grid describes a map made of open cells, walls, a single start cell, and a single finish cell. Movement is allowed in four directions through open cells, and walls block movement entirely.

codeforcescompetitive-programming
CF 104579B - Family Hotel

We are given a line of rooms numbered from 1 to N. Guests arrive one by one, and each guest must be assigned exactly two adjacent rooms that are both still empty at the moment of assignment. If several adjacent empty pairs exist, one of them is chosen uniformly at random.

codeforcescompetitive-programming
CF 104579A - Integeregex

We are given a very small regular-expression language over decimal strings and asked to count how many integers in a given interval match it when interpreted as a pattern over their base-10 representation without leading zeros. The expression is not a full general regex engine.

codeforcescompetitive-programming
CF 104581A - Alphabet Cake

We are given a rectangular grid representing a cake. Some cells already contain uppercase letters, and each letter appears exactly once in the entire grid. Every other cell is empty.

codeforcescompetitive-programming
CF 104581C - Play the Dragon

We are simulating a deterministic turn-based fight between two characters with asymmetric control. One side, the dragon, acts first every turn and can choose among four actions that modify either immediate damage or long-term stats.

codeforcescompetitive-programming
CF 104581B - Ratatouille

We are given a fixed recipe that tells us how many grams of each ingredient are required for one serving of a dish. For each ingredient, we also receive several packages, where each package contains a certain number of grams of that ingredient.

codeforcescompetitive-programming
CF 104582D - Fashion Show

We are working on an $N times N$ grid where each cell can either stay empty or contain a model. Models come in three flavors: plus, cross, and a special combined type that contributes more value.

codeforcescompetitive-programming
CF 104582A - Oversized Pancake Flipper

We are given a row of pancakes, each either happy side up or blank side up. We also have a flipper that always flips exactly K consecutive pancakes. Flipping reverses the state of each pancake in that segment.

codeforcescompetitive-programming
CF 104582C - Bathroom Stalls

We are given a long row of stalls where both ends are permanently occupied, and in between there are N empty stalls. People enter one by one, and each person chooses a stall based on how far it is from the nearest occupied stall on both sides.

codeforcescompetitive-programming
CF 104582B - Tidy Numbers

We are given several independent queries. Each query provides a positive integer $N$. Imagine we are counting upward from 1 to $N$, and for each number we check whether its decimal digits never decrease when read from left to right.

codeforcescompetitive-programming
CF 104584A - Steed 2: Cruise Control

We are given a straight road from west to east. Several horses are already on this road, each starting at a known position and moving east with a fixed maximum speed. These horses are polite in the sense that they never overtake each other.

codeforcescompetitive-programming
CF 104584B - Stable Neigh-bors

We are given several types of items that must be arranged on a circle of N positions. Each item type is represented by a letter, and each letter corresponds to a color or a mixture of colors.

codeforcescompetitive-programming
CF 104584C - Pony Express

We are given a directed graph with up to 100 cities. Between some pairs of cities there are one-way roads with fixed distances, and each city also owns a horse.

codeforcescompetitive-programming
CF 104585A - Ample Syrup

We are given a collection of cylindrical pancakes, each described by a radius and a height. We must choose exactly K of them and stack them vertically. The stacking order is fixed once the chosen set is decided: larger radius pancakes go lower, and smaller radius ones go higher.

codeforcescompetitive-programming
CF 104585B - Parenting Partnering

We are given a full day of 1440 minutes, and two people who must share responsibility for a baby over the entire day.

codeforcescompetitive-programming
CF 104585C - Core Training

We are given a collection of independent components, each of which works correctly with some probability. The system succeeds only if at least a threshold number of these components work.

codeforcescompetitive-programming
CF 104586J - Рудольф и портал в Рамень

We are given a set of vertical posts placed on a line, each defined by a position on the x-axis and a height. We are allowed to pick two different posts, say one as the “falling” post and one as the “target” post.

codeforcescompetitive-programming
CF 104586I - Рудольф и утерянный массив

We are given a binary array, but instead of seeing it directly, we only receive partial information in the form of short interval constraints. Each constraint says that within a segment of length at most 10, the number of ones is exactly some value.

codeforcescompetitive-programming
CF 104586H - Рудольф и подстроки

We are given an unknown string of length $n le 5000$, built from an alphabet of at most 26 characters. We cannot see the string directly. Instead, we can ask queries on any segment $[l, r]$, and the interactor returns how many distinct characters appear in that substring.

codeforcescompetitive-programming
CF 104586G - Рудольф и шахматы

We are given an 8 by 8 chessboard where some cells are marked as possible destinations of a single unknown chess move.

codeforcescompetitive-programming
CF 104586F - Рудольф и кроличьи норы

We are given a tree of caves. Each cave contains some number of balls. A character starts at a fixed cave and walks through the tree toward a leaf, but at every junction he chooses the next unvisited edge uniformly at random.

codeforcescompetitive-programming
CF 104586E - Рудольф и коктейли

We are given several independent test cases. In each one, there is an array of small integers arranged in a line. Each number represents an ingredient, and any cocktail is formed by choosing a contiguous segment of this array.

codeforcescompetitive-programming
CF 104586D - Рудольф и выпекание булочек

We are given a production system that bakes pastries using two types of machines. The first machine is special because it has a built-in fatigue cycle: it bakes one item every fixed amount of time, but after producing a fixed batch size, it must rest for a fixed cooldown…

codeforcescompetitive-programming
CF 104586B - Рудольф и сообщения

We are given a short message split into words, and we want to decide whether the special keyword “codecup” could have appeared somewhere in that message after transmission errors. The key detail is the error model.

codeforcescompetitive-programming
CF 104586C - Рудольф и квадратики

We are given a sorted list of task completion times measured in minutes from the start of training. Each time corresponds to when a single task was solved. These timestamps can be converted into calendar days by grouping every 1440 minutes into a day bucket.

codeforcescompetitive-programming
CF 104586A - Рудольф и ягоды

We are told that all berries were originally packed into identical jars, and every jar contains the same number of berries. Each jar contains only one type of berry.

codeforcescompetitive-programming
CF 104587L - Workers of the World Unite! Just Not Too Close.

We are assigning each worker a route that consists of two independent choices: a gate in the middle layer and a workstation in the final layer. Every worker starts at their own position, enters exactly one gate, and then exits through the same gate to reach a workstation.

codeforcescompetitive-programming
CF 104587K - Weighty Tomes

We are given a storage scenario that is mathematically identical to a threshold-finding experiment. There is an unknown limit $x$ such that stacking up to $x$ identical boxes on a pallet is safe, but stacking $x+1$ boxes causes failure.

codeforcescompetitive-programming
CF 104587J - Simply Sudoku

We are given a standard 9 by 9 Sudoku grid. Some cells already contain digits from 1 to 9, while empty cells are represented by zeros.

codeforcescompetitive-programming
CF 104587I - Scholar's Lawn

We are given a collection of straight walkways drawn on a plane. Each walkway is a finite line segment, and students are only allowed to move along these segments, never through open grass.

codeforcescompetitive-programming
CF 104587H - Restroom Monitor

We are given a stream of people who need to be placed into identical single-stall restrooms, where each person occupies a stall for exactly one unit of time. There are s stalls, meaning that at any moment up to s people can be inside simultaneously.

codeforcescompetitive-programming
CF 104587G - A Rank Problem

We maintain an evolving ranking of teams labeled $T1$ through $Tn$. Initially, the ranking is fixed in increasing index order, so $T1$ is first and $Tn$ is last. Then we process a sequence of match results, where each result states that one team beats another.

codeforcescompetitive-programming
CF 104587F - Over the Hill, Part 2

We are given a classical linear encryption model where fixed-size blocks of text are transformed by multiplying them with an unknown square matrix.

codeforcescompetitive-programming
CF 104587E - Over the Hill, Part 1

We are given a fixed alphabet of 37 characters consisting of uppercase English letters, digits, and the space character.

codeforcescompetitive-programming
CF 104587D - Oreperations Research

The system consists of three synchronized streams that interact only through a single active “loading position.” One stream is a line of train cars, each with a fixed required capacity.

codeforcescompetitive-programming
CF 104587A - All in the Family

We are given a rooted family structure described indirectly through parent-to-children listings, and we must answer queries about how two people are related in genealogical terms.

codeforcescompetitive-programming
CF 104587B - Kinky Word Searches

We are given a very small grid of uppercase letters, at most 10 by 10, and we want to know whether a given word can be traced on this grid by walking from cell to cell. The walk starts from any cell and moves in straight line steps on adjacent cells.

codeforcescompetitive-programming
CF 104587C - Math Trade

Each person in the input owns exactly one object and wants exactly one object. We can think of each person as a directed edge in a graph: from the object they currently have to the object they want.

codeforcescompetitive-programming
CF 104590D - Shoot the Turrets

The grid represents a city split into walkable streets and blocked buildings. On streets there are two kinds of entities: soldiers and turrets. Buildings are impassable and also block vision and movement.

codeforcescompetitive-programming
CF 104590C - Beaming With Joy

We are given a grid representing a house where each cell can contain a shooter, a wall, a mirror, or empty space. Some cells contain beam shooters that emit continuous laser beams. Each shooter can be in one of two orientations: it either fires horizontally or vertically.

codeforcescompetitive-programming
CF 104590A - Fresh Chocolate

We are given a list of groups, each group having a fixed number of people. Each group must be served in some order, and serving a group consumes whole chocolate packs of size P.

codeforcescompetitive-programming
CF 104590B - Roller Coaster Scheduling

We are given a set of seat assignments on a roller coaster train with positions numbered from front to back. Each ticket says that a specific customer must occupy a specific seat on exactly one ride, and customers may hold multiple tickets, meaning they must appear multiple…

codeforcescompetitive-programming
CF 104591D - Slate Modern

We are given a rectangular canvas, but the coordinates can be extremely large, so we should think of it as an infinite grid restricted to a huge box. Some cells are already fixed with brightness values.

codeforcescompetitive-programming
CF 104591B - Good News and Bad News

The input describes a directed graph where vertices are friends and edges are communication links. Each ordered pair tells us that one friend can send a single piece of news to another friend.

codeforcescompetitive-programming
CF 104591C - Mountain Tour

We are given a directed graph whose vertices are camps and whose edges are hiking tours. Every tour starts at a camp, ends at another camp, takes a fixed number of hours once started, and is only allowed to start at specific hours of the day, repeating every 24 hours.

codeforcescompetitive-programming
CF 104591A - Googlements

We are given a string that represents a “googlement”, which is simply a digit string of length at most 9 with a constraint tied to its length. If the string has length $L$, every digit must lie in the range $0$ to $L$, and at least one digit must be nonzero.

codeforcescompetitive-programming
CF 104596K - Where Have You Bin?

We are given a row of storage bins, each bin belonging either to one of five companies or being empty. Each occupied bin contains a positive number of items, and that number is also the cost of moving that bin’s contents elsewhere.

codeforcescompetitive-programming
CF 104595A - Falling Balls

We are given a single array of length C describing how many balls end up in each column after falling through some hidden grid. Initially, one ball is dropped into every column at the top, so there are exactly C balls.

codeforcescompetitive-programming
CF 104592D - Omnicircumnavigation

We are given a grid-based toy where balls fall from the top through a lattice of cells. Each column receives exactly one ball. Inside the grid, each cell is either empty or contains a diagonal ramp that redirects a falling ball either down-left or down-right.

codeforcescompetitive-programming
CF 104592F - Teleporters

We are given a starting point in 3D space, a target point, and up to about 150 special points called teleporters. Movement is not free: the only way to move is to choose a teleporter and perform a constrained jump. Each teleporter imposes a rule based on Manhattan distance.

codeforcescompetitive-programming
CF 104595D - Gridception

We are given a binary grid where each cell is either black or white. From this grid, we can repeatedly generate larger grids by replacing every cell with a 2×2 block of identical color.

codeforcescompetitive-programming
CF 104592E - Stack Management

We are given a collection of fixed “premade” card stacks. Each stack is an ordered sequence from top to bottom, and each card has two attributes: a value and a suit. In a test case, we do not construct stacks from scratch.

codeforcescompetitive-programming
CF 104592A - Dice Straight

We are given several independent test cases. In each test case there are multiple dice, and every die has exactly six positive integers written on its faces. When we place dice in a row, we pick exactly one face from each chosen die to be the “top” value of that die.

codeforcescompetitive-programming
CF 104592C - Spanning Planning

We are given a supply of two types of items, red chainsaws and blue chainsaws, and we want to distribute all of them among some number of jugglers.

codeforcescompetitive-programming
CF 104592B - Operation

Each test case gives a starting value and a collection of arithmetic “cards”. Every card is an operation with a fixed operand, and we are allowed to reorder these cards arbitrarily.

codeforcescompetitive-programming
CF 104593C - Edgy Baking

We are given several rectangular cookies. Each cookie contributes its perimeter to a total “crispiness score”, and we are allowed to optionally modify each cookie before baking.

codeforcescompetitive-programming
CF 104593B - Bit Party

We are given a group of robots, a collection of indistinguishable items called bits, and several cashiers. Each robot must be assigned to exactly one cashier, and each cashier can serve at most one robot.

codeforcescompetitive-programming
CF 104593A - Waffle Choppers

We are given a grid of size R by C where each cell is either empty or contains a chocolate chip. We must cut this grid using exactly H horizontal cuts and exactly V vertical cuts.

codeforcescompetitive-programming
CF 104594B - Mysterious Road Signs

We are given a supply of two types of items, red chainsaws and blue chainsaws, and we want to distribute all of them among some number of jugglers.

codeforcescompetitive-programming
CF 104594C - Transmutation

We are given a collection of metals where metal 1 is special because each gram of it directly counts as one gram of the final answer. Every other metal has exactly one synthesis rule: if we destroy one gram each of two specific metals, we obtain one gram of another metal.

codeforcescompetitive-programming
CF 104594A - Rounding Error

We are given a survey where some people have already answered, and their answers are summarized as counts per language. The total number of respondents is eventually fixed at N, but only a subset of those responses is known.

codeforcescompetitive-programming
CF 104595B - Graceful Chainsaw Jugglers

We are given a supply of two types of items, red chainsaws and blue chainsaws, and we want to distribute all of them among some number of jugglers.

codeforcescompetitive-programming
CF 104595C - Costume Change

We are given an $N times N$ grid where each cell contains an integer. The absolute value represents a “color”, while the sign represents the “material”. So every cell encodes a single combined label: a signed integer.

codeforcescompetitive-programming
CF 104596J - Taxed Editor

We are given a sequence of books, and each book must be read from start to finish before moving to the next one. Each book has a length in pages and a deadline measured in days.

codeforcescompetitive-programming