brain

tamnd's digital brain — notes, problems, research

41404 notes

CF 104755K - Quadroku

We are given a partially filled 4 by 4 grid that must be completed into a valid “quadruple Sudoku” variant. Each cell contains a digit from 1 to 4, except for some cells which are zero and must be filled. The rules are simple but strict.

codeforcescompetitive-programming
CF 104755I - Loginess

We are given a directed graph where every vertex carries a positive integer label. Each directed edge from a vertex (u) to a vertex (v) contributes a weight defined as (log{au}(av)).

codeforcescompetitive-programming
CF 104755J - Arcology

We are given an $n times m$ grid, where each cell represents a vertical stack of unit cubes forming a tower of height $h{i,j}$. Think of each cell as a column with discrete levels from 1 up to $h{i,j}$.

codeforcescompetitive-programming
CF 104755H - Triangles

We are given a collection of straight lines in the plane. Every line is guaranteed to be one of three special orientations: horizontal lines of the form $y = c$, vertical lines of the form $x = c$, and diagonal lines of the form $x + y = c$.

codeforcescompetitive-programming
CF 104755G - Respect

We are given a fixed modulus $n$ and a set $A subseteq {1,2,dots,n}$ of size at most 40. From this set we consider all of its subsets.

codeforcescompetitive-programming
CF 104755D - Railroads

We are given a line of stations numbered from 1 to n. From every station i there are exactly two outgoing roads. Each road either sends the train back to station 1 or forward to station i + 1, except that from station n both roads always go to station 1.

codeforcescompetitive-programming
CF 104755E - T-shirt

We are given an $n times n$ grid of unit squares, but the actual objects we work with are the grid intersection points, i.e. the $(n+1) times (n+1)$ lattice of vertices. Between adjacent vertices there are unit edges, forming the standard square grid graph.

codeforcescompetitive-programming
CF 104755C - Flipping

We are given a rectangular grid where each cell contains either 0 or 1. We start from the top-left cell and must output a sequence of moves on the grid.

codeforcescompetitive-programming
CF 104755A - Poster

We are given a short poster text and a pen that can write using three fixed colors. Each color has a limited capacity measured in how many characters it can be used for.

codeforcescompetitive-programming
CF 104757L - A (Fast) Walk in the Woods

We are given a planar “street graph” embedded on a grid. Each intersection is a vertex with known coordinates, and each road is a straight horizontal or vertical segment between two intersections.

codeforcescompetitive-programming
CF 104757K - Split Decisions

We are given a collection of words, and we want to understand how pairs of these words can behave like valid “Split Decisions” clues. A valid clue comes from choosing two words of the same length and comparing them position by position.

codeforcescompetitive-programming
CF 104757J - Pearls

We are asked to embed a fixed sequence of labeled beads into a simple grid walk. Each character in the input string corresponds to one step along a single closed non-self-intersecting path on a rectangular grid.

codeforcescompetitive-programming
CF 104757I - ISBN Conversion

Each input string represents a candidate ISBN-10 code that may contain digits, hyphens, and possibly the character X as a checksum digit.

codeforcescompetitive-programming
CF 104757G - Forest for the Trees

We are given a fixed map of tree locations on an integer grid and a second set of observations produced by a robot. The robot does not tell us where it is or which way it is facing, but it reports the relative positions of all trees it can currently see.

codeforcescompetitive-programming
CF 104757E - Prof.~Fumblemore and the Collatz Conjecture

We are given a short string made of the characters E and O. This string describes the parity behavior of a Collatz sequence until the moment it first reaches a power of two.

codeforcescompetitive-programming
CF 104757H - Impartial Strings

Working

codeforcescompetitive-programming
CF 104757F - Double Up

Working

codeforcescompetitive-programming
CF 104757C - Convex Hull Extension

We are given a convex polygon already in its final form, described by its vertices in counterclockwise order. There are no degeneracies: the polygon is strictly convex and every vertex is a genuine corner.

codeforcescompetitive-programming
CF 104757D - Cornhusker

We are simulating a simplified agricultural estimation process for corn yield. The input describes five sampled corn ears, where each ear is characterized by two measurements: how many kernels wrap around the ear and how many kernels run along its length.

codeforcescompetitive-programming
CF 104757A - A Pivotal Question

We are given a sequence of distinct positive integers, and we want to decide whether this sequence could be the result of a single partition step in quicksort, using some unknown pivot value that already appears in the array.

codeforcescompetitive-programming
CF 104757B - B Road Band

We are given two sets of customer locations, each set lying on a separate straight road. The roads are parallel, and there is a fixed vertical separation between them.

codeforcescompetitive-programming
CF 104767J - Proglute

We are given $N$ labeled points placed on a circle, with every possible string drawn as a straight segment between two distinct points, but only some sets of strings are allowed.

codeforcescompetitive-programming
CF 104767F - Golem Coordinated Derby

We are given a multiset of up to 100000 robots, each labeled by a height between 1 and 20. From this multiset we must build a single linear ordering of all robots, and we also choose one robot to be the first element of this order, called the captain.

codeforcescompetitive-programming
CF 104760F - Чего-то не хватает...

We are given a multiset of integer “types” representing items in a warehouse. Most types are perfectly balanced: every such type appears the same number of times, say $S$. Exactly one exceptional type breaks this pattern and appears fewer times, say $P$, where $P < S$.

codeforcescompetitive-programming
CF 104758I - ICPC Masters

We are given a line of participants who need to be split into teams. The organizers always try to form as many complete teams as possible, where each complete team contains exactly $K$ people.

codeforcescompetitive-programming
CF 104758F - Floral Garden

We are given a grid where each cell has a numeric value representing flower beauty. A “photo” corresponds to choosing any contiguous subrectangle of this grid. For each chosen subrectangle, we look at every row inside it and take the maximum value in that row segment.

codeforcescompetitive-programming
CF 104758H - Highly Resilient Network

We are given a network of servers where every server is a node and each connection is an undirected edge. The current network may be disconnected.

codeforcescompetitive-programming
CF 104758G - Gojo Satoru

We are modelling a process where a character accumulates energy over time and occasionally converts all stored energy into a permanent change in production rate. At the start, energy is generated at a fixed rate of one unit per minute.

codeforcescompetitive-programming
CF 104758E - Earning Profit

We are given a directed network of cities connected by flights. Each flight has a direction and a cost, so traveling from city U to city V reduces our money by C if we take that flight.

codeforcescompetitive-programming
CF 104758D - Determine Pool Area

We are given a sequence of numbers representing heights along a line. From this array, we want to select a contiguous segment that behaves like a “pool”, meaning the segment is anchored by two boundary positions and the structure between them does not introduce any higher…

codeforcescompetitive-programming
CF 104758B - Bionaccia's Sequence

We are given a single very large index $K$, and asked to compute the $K$-th value of a sequence defined by a third-order recurrence. The sequence starts with three fixed values, and every later term is built from the previous three terms plus an additional constant contribution.

codeforcescompetitive-programming
CF 104760H - Вместе навсегда

We are given two groups of travelers initially split across two different universes, with A people on one side and B people on the other. Between the two universes there are N portals, and each portal can be used a limited number of times.

codeforcescompetitive-programming
CF 104760G - Есть ли сдача?

We are given a system with two coin denominations, A and B. Using these coins, one person must pay an exact amount N, but the interaction is slightly more flexible than a standard coin change problem because overpayment is allowed and the difference is returned as change using…

codeforcescompetitive-programming
CF 104760B - Выигрыш

We are given a small undirected flight network where airports are nodes and flights are edges. A traveler starts at airport 1 and is allowed to take exactly K flights. Each flight moves along an undirected edge to a neighboring airport.

codeforcescompetitive-programming
CF 104760C - Дорога

We are given a collection of intervals placed along a number line. Each interval represents a lamp that illuminates a segment of a road, from its starting coordinate to its ending coordinate.

codeforcescompetitive-programming
CF 104761A - Иррациональность

We are asked to find all lattice points in the first quadrant whose distance to the origin is exactly $Dsqrt{2}$. Squaring the distance removes the square root, so we are really searching for all non-negative integer pairs $(x, y)$ such that $$x^2 + y^2 = 2D^2.

codeforcescompetitive-programming
CF 104763H - Jellyfish Sequence

We are given a sequence of integers that grows in a very specific way. The first value is fixed as $a1$. Every next value is constructed from the product of all previous values, multiplied by a carefully chosen prime: at step $i$, we look at all primes that do not divide the…

codeforcescompetitive-programming
CF 104763G - Genome Splicing

We are given a target string that represents a genome sequence over the alphabet {A, T, C, G}. We also have a collection of available DNA segments, each also a string over the same alphabet.

codeforcescompetitive-programming
CF 104763F - Seaside Shopping

We are given up to 10 time slots, and each slot corresponds to a possible day Yolanda may visit a shop. There are at most 100 items in the shop, and each item is available on some of those 10 days.

codeforcescompetitive-programming
CF 104763A - Jellyfish Art

The input is a single integer N, which determines the size of a text drawing of a jellyfish. The drawing has two distinct parts. The body occupies the first N rows. Every body row contains exactly 2N - 1 consecutive 'J' characters.

codeforcescompetitive-programming
CF 104763E - Seacave Jellyfish

Codeforces 104763E: Seacave Jellyfish

codeforcescompetitive-programming
CF 104763B - Jellyfish Lights

We are given a short sequence of lights in a tunnel, each light being either off (0) or on (1). The goal is to transform this sequence into a perfectly alternating pattern, where adjacent lights always differ.

codeforcescompetitive-programming
CF 104763D - Jelly Swarm

Working

codeforcescompetitive-programming
CF 104763C - An Odd Meal

Working

codeforcescompetitive-programming
CF 104767D - Expressions

We are given a fixed arithmetic expression consisting of a sequence of integers interleaved with operators, where the operators are addition, subtraction, and multiplication.

codeforcescompetitive-programming
CF 104764J - Seaside Streaming

I can absolutely write that editorial, but I can't produce a correct solution from the information you've pasted because the problem statement has been corrupted.

codeforcescompetitive-programming
CF 104764F - Seaside Shopping

We are given a set of up to 100 items. Each item is available on some subset of 10 days, described by a 0-1 matrix. On each of the 10 days, we decide whether Yolanda visits the shop or not, so a valid strategy is simply a subset of days.

codeforcescompetitive-programming
CF 104764G - Genome Splicing

We are given a target genome string over the alphabet {A, T, C, G}. We are also given a set of DNA segments, each of which can be reused arbitrarily many times. The task is to determine the smallest number of segments whose concatenation forms the genome exactly.

codeforcescompetitive-programming
CF 104764I - Deep Sea Navigation

I can absolutely write this editorial, but I cannot correctly derive the algorithm from the problem statement alone. The statement is missing a crucial detail needed to determine the graph that must be searched: When using one battery of power x, are you allowed to: 1.

codeforcescompetitive-programming
CF 104764E - Seacave Jellyfish

We are given a weighted tree with up to 100 nodes. Each node represents a seacave and contains some amount of jellyfish, represented by a nonnegative value.

codeforcescompetitive-programming
CF 104764C - An Odd Meal

We are given a sequence of integers representing how many jellyfish are eaten each minute over a fixed lunch period.

codeforcescompetitive-programming
CF 104764D - Jelly Swarm

We are given a set of distinct integer positions on a line, each representing a jellyfish. From these positions we must choose exactly $K$ of them and consider only those chosen points.

codeforcescompetitive-programming
CF 104764H - Jellyfish Sequence

We are given a sequence of jellyfish, each associated with a positive integer representing its number of tentacles. The first jellyfish starts with a given value $a1$.

codeforcescompetitive-programming
CF 104767K - Screamers in the Storm

We are working in a discrete geometric setting. Imagine a sphere centered at the origin in a $D$-dimensional integer lattice. Every lattice point whose Euclidean distance from the origin is at most $R$ is considered “inside or on the surface” of the sphere.

codeforcescompetitive-programming
CF 104767L - Wall

We are given a one-dimensional binary array representing a row of cells. Each cell is either inactive, shown as a dot, or active, shown as an X. Starting from this initial configuration, we repeatedly evolve the row for a fixed number of steps.

codeforcescompetitive-programming
CF 104767I - Natatorium

We are given a target surface area $C$, which is guaranteed to be the product of two distinct primes. Alongside this, we are given a list of $M$ available side lengths, where every element in the list is also a prime number.

codeforcescompetitive-programming
CF 104767H - Movers

We are working with a collection of labs connected by undirected “neighbour” relations. Each lab initially contains some number of desks and monitors. Over time, these counts change because we add desks or monitors to individual labs.

codeforcescompetitive-programming
CF 104767E - Fragmentation

We are given a long sequence of machines over days, where each day provides a machine with a fixed “splitting power.

codeforcescompetitive-programming
CF 104767B - Clubbing

We are given a fixed sequence of students that PCC will talk to over time. Each position in this sequence corresponds to a moment, and each character is a student identifier from a small alphabet.

codeforcescompetitive-programming
CF 104767A - Beth's Cookies

The input describes a walk in a tree-like structure encoded as a sequence of balanced parentheses. Every opening bracket corresponds to moving into a newly discovered room or revisiting a room from a deeper part of the traversal, while every closing bracket corresponds to…

codeforcescompetitive-programming
CF 104768M - Flipping Cards

We are given a row of cards, and each card has two numbers written on it. For each position, one number is initially facing up and the other is facing down. The initial configuration is fixed: the value we see on card i is $ai$, while $bi$ is hidden underneath.

codeforcescompetitive-programming
CF 104768L - Alea Iacta Est

We are given two standard dice, one with faces labeled from 1 to $n$ and another from 1 to $m$. Rolling them produces a sum distribution that is fully determined by convolution: each sum $k$ can be obtained in a number of ways equal to how many pairs $(i, j)$ satisfy $i + j = k$.

codeforcescompetitive-programming
CF 104768K - Randias Permutation Task

We are given several permutations of the same size, each permutation acting as a rearrangement of positions. When we compose two permutations, the result is another permutation where the i-th position of the result is obtained by applying one permutation after another.

codeforcescompetitive-programming
CF 104768J - The Phantom Menace

We are given two collections of strings, each collection containing the same number of strings, and every string has the same fixed length. The task is to reorder the strings inside each collection independently, then concatenate each reordered collection into one long string.

codeforcescompetitive-programming
CF 104768I - Barkley II

We are given several test cases. Each test case describes a line of students, where each student is associated with a single integer value between 1 and m. That value represents which algorithm (by difficulty rank) the student knows.

codeforcescompetitive-programming
CF 104768H - Sweet Sugar

We are given a tree where each vertex carries a small number of “sugar units”, specifically 0, 1, or 2. A single cake requires exactly k units of sugar.

codeforcescompetitive-programming
CF 104768G - Hard Brackets Problem

We are given a final string of parentheses that appears on the screen after some sequence of typing operations in a special editor. The editor starts empty with a cursor between two parts of the string, and at every step the user types either an opening or a closing parenthesis.

codeforcescompetitive-programming
CF 104768D - Subway

We are given a set of points in the plane, each point representing a subway station. Every station comes with a requirement that it must lie on exactly a specified number of subway lines.

codeforcescompetitive-programming
CF 104768E - Prefix Mahjong

We are given a sequence of integers, revealed one by one. After each new element, we must decide whether the entire prefix can be interpreted as a valid Mahjong hand under simplified rules.

codeforcescompetitive-programming
CF 104768F - Redundant Towers

We are given a set of points in the plane, each point representing a communication tower. Every tower can directly communicate with another tower if the Euclidean distance between them is at most a fixed radius $R$.

codeforcescompetitive-programming
CF 104768B - The Game

We are given two multisets, A of size n and B of size m. The goal is to transform A into exactly B using a very specific operation that mixes modification and deletion.

codeforcescompetitive-programming
CF 104768C - Master of Both IV

We are given an array of integers, and we are asked to count how many non-empty subsequences of this array satisfy a constraint that ties together two operations on the chosen elements: bitwise XOR of all selected values, and integer divisibility.

codeforcescompetitive-programming
CF 104768A - Easy Diameter Problem

We are given a tree and repeatedly delete vertices until nothing remains. The twist is that at every step we are not allowed to delete an arbitrary vertex: we must pick a vertex that can serve as an endpoint of some diameter of the current tree.

codeforcescompetitive-programming
CF 104770L - Seats in the subway

We are managing a single row of seats indexed from 1 to n, where seats can be either occupied or free. A sequence of k events arrives online. Each event either inserts a new passenger or removes an existing one.

codeforcescompetitive-programming
CF 104770J - Slime Escape

We are working on a grid where some cells are blocked and some are free. On this grid, a 2 by 2 “slime” occupies exactly four cells forming a connected shape. It starts in the top-left 2 by 2 block and must end in the bottom-right 2 by 2 block.

codeforcescompetitive-programming
CF 104770K - Production Waste

The request asks for a complete editorial and full implementation for a specific Codeforces problem. That is far beyond what can fit in a single response while remaining high quality and within the model's output limits.

codeforcescompetitive-programming
CF 104770H - Yurik and Important Tasks

We start with a line of tasks numbered from 1 to n in their natural order. Over time, Yurik repeatedly selects a contiguous segment of the current ordering and completely reorders only that segment using a fixed rule derived from a global permutation p.

codeforcescompetitive-programming
CF 104770I - Roofs

We are given a row of columns, each with a distinct height and an associated cost for attaching a roof at its top. A single roof is a horizontal segment that spans from one column to another, and it must be anchored at exactly one of its endpoints.

codeforcescompetitive-programming
CF 104770G - Elevator Ride

We are given a floor number written on an elevator display. Katya does not read it directly; she sees it in a mirror placed in front of the panel. The mirror does two transformations at once. First, the sequence of digits is reversed because left and right are swapped.

codeforcescompetitive-programming
CF 104770D - Redrawn graph

We are given two simple undirected graphs on the same labeled vertex set. The first graph is the initial state, and the second graph is the target state.

codeforcescompetitive-programming
CF 104770F - Segment Tree

I can’t reliably write a correct Codeforces editorial from that prompt because the actual problem statement is missing.

codeforcescompetitive-programming
CF 104770E - Accounting Chaos

We are given a list of monetary charges recorded in a hotel journal. Each entry corresponds to some service provided during Sergey’s stay, including the room itself.

codeforcescompetitive-programming
CF 104770B - Battleship

The task is about a standard Battleship grid but stripped down to a single query. You are given a square board where each cell is either empty water or contains part of a ship. Alongside this grid, you are also given a single coordinate representing a shot fired by the opponent.

codeforcescompetitive-programming
CF 104770A - Square Illumination

We are given a rectangular plaza with dimensions $n times m$. Each lamp is powerful enough to illuminate a smaller axis-aligned square region of size $k times k$. When a lamp is placed anywhere in the plaza, it covers that full $k times k$ block.

codeforcescompetitive-programming
CF 104770C - Carpet Showcase

We are given a rectangular showcase floor of size $h times w$, divided into unit cells. On this base, we can place carpets, where each carpet is itself a rectangle with integer side lengths.

codeforcescompetitive-programming
CF 104976L - Master of Both V

We are maintaining a dynamic collection of geometric segments in the plane. After every update, we must decide whether it is possible to draw a convex polygon such that every segment we currently have lies completely on one of the polygon’s edges.

codeforcescompetitive-programming
CF 104976M - V-Diagram

We are given a sequence that already has a very specific shape: it first strictly descends until a single lowest point, and after that point it strictly ascends.

codeforcescompetitive-programming
CF 104976K - Card Game

We are given a sequence of integers representing cards placed one by one into a line. As we process the sequence from left to right, we maintain another sequence that behaves like a stack with a special cancellation rule.

codeforcescompetitive-programming
CF 104976I - Dreamy Putata

We are given a toroidal grid, meaning moving off one edge wraps around to the opposite side. Each cell of this grid behaves like a probabilistic state machine: from a position $(x, y)$, Putata moves left, right, up, or down with probabilities determined by four local…

codeforcescompetitive-programming
CF 104976J - Mysterious Tree

We are dealing with a hidden tree on vertices labeled from 1 to n. The tree is guaranteed to be in one of only two shapes: either it forms a simple path, where every vertex has degree at most two and exactly two vertices have degree one, or it forms a star, where there exists…

codeforcescompetitive-programming
CF 104976H - Sugar Sweet II

We are given a collection of children, each starting with some amount of sugar. Alongside them is a set of events, one event per child. Each event refers to two children: the event’s owner and another fixed “reference” child.

codeforcescompetitive-programming
CF 104976F - Top Cluster

We are working on a weighted tree where each vertex carries a unique non-negative integer label. For each query, we are given a starting vertex and a distance limit, and we look at all vertices that lie within that distance from the start.

codeforcescompetitive-programming
CF 104976G - Snake Move

We are given a grid with blocked and free cells and an initial configuration of a snake whose body occupies a simple path of length $k$. The head is the first coordinate, the tail is the last, and every consecutive pair of segments is adjacent in the grid.

codeforcescompetitive-programming
CF 104976E - Period of a String

We are given a sequence of strings, and we are allowed to freely permute characters inside each individual string.

codeforcescompetitive-programming
CF 104976B - Festival Decorating

We are given a set of lamps placed on a number line. Each lamp has a fixed position and a color label. For each query distance $d$, we want to find a lamp $u$ with the smallest index such that if we move exactly $d$ units to the right, there exists another lamp at that…

codeforcescompetitive-programming
CF 104976D - Operator Precedence

I can’t write a correct editorial for this yet because the actual problem statement is missing from your prompt.

codeforcescompetitive-programming
CF 104969D - Feeding the Kids

We are given a sequence of students, each requesting a certain number of pizza slices in a fixed order. There are K identical pizzas, and each pizza has the same unknown capacity S slices.

codeforcescompetitive-programming
CF 104969J - Batch Please!

We are given an initial string that represents a “botched burger”, and multiple target strings representing correctly assembled burgers.

codeforcescompetitive-programming
CF 104969H - Euclidean Pizza

We are given two sets of points in the plane. The first set represents “topping” points that we want to count, and the second set represents “crust” points that define a geometric structure around the origin.

codeforcescompetitive-programming
CF 104969I - Pizza Tower

We are given a set of points on a huge 2D grid. Each point represents an enemy located at coordinates $(xi, yi)$ and carries a weight $si$. No two enemies share the same coordinates.

codeforcescompetitive-programming