brain

tamnd's digital brain — notes, problems, research

41650 notes

CF 1284F - New Year and Social Network

We are given two different spanning trees over the same set of $n$ vertices. One tree, call it $T1$, represents the main network, and the second tree $T2$ is a backup structure. Each edge in $T1$ is a potential failure point.

codeforcescompetitive-programmingdata-structuresgraph-matchingsgraphsmathtrees
CF 1284E - New Year and Castle Construction

We are given a set of points in the plane, with the restriction that no three points lie on a single line. For every point (p), we want to count how many subsets of exactly four other points can form a simple quadrilateral that strictly contains (p).

codeforcescompetitive-programmingcombinatoricsgeometrymathsortings
CF 1284A - New Year and Naming

We are given two circular lists of strings. The first list has size $n$, the second has size $m$. Each year $y$ produces a name by taking the $y$-th string from the first list and the $y$-th string from the second list, both indexed cyclically, and concatenating them.

codeforcescompetitive-programmingimplementationstrings
CF 1284B - New Year and Ascent Sequence

We are given a collection of integer sequences, and we consider ordered pairs of them. For any pair of sequences $sx$ and $sy$, we concatenate them to form a longer sequence $sx + sy$.

codeforcescompetitive-programmingbinary-searchcombinatoricsdata-structuresdpimplementationsortings
CF 1284D - New Year and Conference

Each lecture in the conference has two possible time schedules, depending on which venue is chosen. If we pick venue A, every lecture follows its A-interval. If we pick venue B, every lecture follows its B-interval.

codeforcescompetitive-programmingbinary-searchdata-structureshashingsortings
CF 1283E - New Year Parties

We are given a set of people placed on integer points on a line. Each person starts at a fixed coordinate and is allowed to move at most one step left, stay where they are, or move one step right.

codeforcescompetitive-programmingdpgreedy
CF 1283F - DIY Garland

We are given a tree with $n$ vertices, where each vertex represents a lamp. One of these lamps is directly connected to a power source, and from it power spreads through directed connections formed by the wires of the tree.

codeforcescompetitive-programmingconstructive-algorithmsgreedytrees
CF 1283D - Christmas Trees

We are given a set of fixed points on a number line, each representing a Christmas tree. We are also asked to place another set of points representing people, but with a twist: each person contributes cost equal to the distance to the nearest tree, and we want to choose all…

codeforcescompetitive-programminggraphsgreedyshortest-paths
CF 1283B - Candies Division

We are distributing a fixed number of identical candies among a fixed number of children. Each child must receive a non-negative integer number of candies, and we are allowed to leave some candies unused.

codeforcescompetitive-programmingmath
CF 1282D - Enchanted Artifact

We are interacting with a hidden binary string $s$ consisting only of characters a and b. We do not know its length, but it is at most 300. Our task is to discover $s$ using queries.

codeforcescompetitive-programmingconstructive-algorithmsinteractivestrings
CF 1282E - The Cake Is a Lie

We are given a collection of triangles that once formed a triangulation of a convex polygon with $n$ vertices. Each triangle corresponds to one cut made during a process where we repeatedly remove a boundary triangle from a convex polygon until nothing remains except the…

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresdfs-and-similargraphs
CF 1282B1 - K for the Price of One (Easy Version)

We are given several independent test cases. In each one, Vasya has a budget and a list of item prices. He wants to maximize how many items he can take from the store. The store has a special promotion with groups of two items.

codeforcescompetitive-programmingdpgreedysortings
CF 1282B2 - K for the Price of One (Hard Version)

We are given a list of item prices and a budget. Vasya wants to maximize the number of items he acquires. He has two ways to buy: he can purchase a single item at its full price, or he can activate a bundle purchase where he chooses a “base” item and simultaneously takes up…

codeforcescompetitive-programmingdpgreedysortings
CF 1281B - Azamon Web Services

We are given two uppercase strings, one representing Jeff’s current product name and another representing a competitor’s product name. We are allowed to improve Jeff’s name by swapping at most one pair of characters inside his string. We may also choose to do nothing.

codeforcescompetitive-programminggreedy
CF 1280E - Kirchhoff's Current Loss

The circuit is given as a fully parenthesized expression that builds a tree of components. Leaves are individual resistors, each represented by . Internal nodes are either series connections or parallel connections over two or more subcircuits.

codeforcescompetitive-programmingmath
CF 1280C - Jeremy Bearimy

We are given a weighted tree with $2k$ vertices. On these vertices we must place $2k$ people, where the people are grouped into $k$ fixed pairs.

codeforcescompetitive-programmingdfs-and-similargraphsgreedytrees
CF 1280D - Miss Punyverse

We are given a tree where each node represents a “nesting place” that contains two types of insects: bees and wasps. Every insect votes for its own side, so bees always contribute to the bee count of a region and wasps always contribute to the wasp count.

codeforcescompetitive-programmingdpgreedytrees
CF 1280B - Beingawesomeism

We are given a grid of size $r times c$, where each cell is either $A$ or $P$. The goal is to convert every $P$ into $A$ using a special operation that behaves like a directional flood from a chosen line segment.

codeforcescompetitive-programmingimplementationmath
CF 1279F - New Year and Handle Change

We are given a string consisting of uppercase and lowercase Latin letters. The task is to apply at most a fixed number of operations, where each operation flips the case of every character in a contiguous segment of fixed length.

codeforcescompetitive-programmingbinary-searchdp
CF 1279E - New Year Permutations

We are given a permutation of the numbers from 1 to n, and a rather unusual procedure that breaks this permutation into consecutive “blocks” based on reachability through functional edges defined by the permutation itself.

codeforcescompetitive-programmingcombinatoricsdp
CF 1279C - Stack of Presents

The situation is a stack of uniquely numbered items, where only the top of the stack is directly accessible. A sequence of operations asks us to repeatedly remove specific items in a given order.

codeforcescompetitive-programmingdata-structuresimplementation
CF 1278E - Tests for problem D

We are given a tree with n labeled vertices. The task is not to manipulate the tree directly, but to construct a completely different object: n line segments on the number line, using the integers from 1 to 2n exactly once as endpoints.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similardivide-and-conquertrees
CF 1277B - Make Them Odd

We are given several independent test cases. In each test case, we start with a list of positive integers. One operation lets us pick a value $c$, but only if it is even, and then we simultaneously replace every occurrence of $c$ in the array by $c/2$.

codeforcescompetitive-programminggreedynumber-theory
CF 1276C - Beautiful Rectangle

We are given a multiset of integers, and we are allowed to select some of them and arrange the selected elements into a rectangular grid. Every chosen element occupies exactly one cell, and the grid is completely filled with chosen values.

codeforcescompetitive-programmingbrute-forcecombinatoricsconstructive-algorithmsdata-structuresgreedymath
CF 1276A - As Simple as One and Two

We are given a string consisting of lowercase letters. Certain length-3 patterns are considered “bad”: specifically, the substrings "one" and "two". A string becomes unacceptable if any such bad triple appears anywhere inside it.

codeforcescompetitive-programmingdpgreedy
CF 1275A - Скрытый друг

We are given a directed friendship graph of $n$ users, where each user lists some other users as friends. The important detail is that friendship is not guaranteed to be mutual. If user $u$ lists $v$, it does not imply that $v$ lists $u$.

codeforcescompetitive-programming*special
CF 1275E2 - Контрольная сумма

We are working with a byte array, and a checksum function, CRC32, that compresses the entire array into a single 32-bit value.

codeforcescompetitive-programming*special
CF 1272B - Snow Walking Robot

We are given a sequence of moves for a robot on an infinite grid starting from the origin. Each character in the string tells the robot to move one step in one of the four cardinal directions.

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementation
CF 1271B - Blocks

We are given a line of blocks, each painted either black or white. The only allowed move is to pick two neighboring blocks and flip both of them at the same time, turning white into black and black into white.

codeforcescompetitive-programminggreedymath
CF 1270I - Xor on Figures

We are given a toroidal grid of size $2^k times 2^k$, where each cell contains a 60-bit integer. The grid wraps around both horizontally and vertically, so shifting beyond an edge brings us back to the opposite side.

codeforcescompetitive-programmingconstructive-algorithmsfftmath
CF 1270G - Subset with Zero Sum

We are given an array of integers where each position i has a value a[i] constrained in a tight interval that depends on its index. The i-th element is never too negative and never too large: it always lies between i − n and i − 1.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similargraphsmath
CF 1270H - Number of Components

The array defines a complete ordering between positions: for every pair of indices $i < j$, we draw a directed comparison that becomes an undirected edge if the value on the left is smaller than the value on the right.

codeforcescompetitive-programmingdata-structures
CF 1270B - Interesting Subarray

We are given several test cases, and each test case provides an array of integers. The task is to determine whether there exists a contiguous segment of this array whose spread is large enough compared to its length.

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 1270F - Awesome Substrings

We are given a binary string and asked to count how many of its contiguous substrings satisfy a very specific structural constraint. A substring is considered valid if it contains at least one 1, and if its total length is divisible by the number of 1s inside it.

codeforcescompetitive-programmingmathstrings
CF 1270E - Divide Points

We are given a collection of points on a plane, each with integer coordinates, and we must split them into two nonempty groups. After splitting, every pair of points produces a distance value, since we consider Euclidean distances between all pairs.

codeforcescompetitive-programmingconstructive-algorithmsgeometrymath
CF 1270C - Make Good

We are given an array of nonnegative integers, and we are allowed to append at most three additional numbers. The goal is to make the final multiset of numbers satisfy a very specific algebraic condition: the sum of all elements must equal twice their bitwise XOR.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsmath
CF 1270D - Strange Device

We are given an unknown array of distinct integers. We cannot read it directly. Instead, we can query any subset of exactly k positions, and the device returns the position and value of the element that would rank as the m-th smallest among those k values.

codeforcescompetitive-programmingconstructive-algorithmsinteractivemathsortings
CF 1268C - K Integers

We are given a permutation of the numbers from 1 to n. The goal is to understand how expensive it is, in terms of adjacent swaps, to force the numbers 1 through k to appear as a contiguous block in increasing order somewhere inside the array.

codeforcescompetitive-programmingbinary-searchdata-structures
CF 1267J - Just Arrange the Icons

We are given a multiset of applications, each belonging to a category. The only thing that matters about a category is how many apps it contains, so the input can be compressed into frequencies of each distinct category. We must place all apps into “screens”.

codeforcescompetitive-programminggreedyimplementationmath
CF 1263E - Editor

We are maintaining a text editor that supports three kinds of operations: moving a cursor left or right along a growing line, and overwriting the character at the current cursor position.

codeforcescompetitive-programmingdata-structuresimplementation
CF 1260D - A Game with Traps

We are given a line of positions from 0 to n+1. A group of soldiers starts at position 0 together with the player character. Each soldier has a strength value, and traps placed along the line may kill soldiers whose strength is too low when they enter certain positions.

codeforcescompetitive-programmingbinary-searchdpgreedysortings
CF 1255B - Fridge Lockers

We are given a complete system of lockers where each locker belongs to one person and has a weight. We are allowed to install exactly $m$ undirected connections between distinct lockers. Each connection between locker $u$ and $v$ costs $au + av$.

codeforcescompetitive-programminggraphsimplementation
CF 1255C - League of Leesins

We are given a hidden permutation of size $n$, but we never see it directly. Instead, we see every consecutive block of three elements from that permutation. Each block is then scrambled internally, and all blocks are shuffled among themselves.

codeforcescompetitive-programmingconstructive-algorithmsimplementation
CF 1254E - Send Tree to Charlie

We are given a tree with $n$ nodes, where each node initially holds a unique label from $1$ to $n$. Someone then performs a process that is equivalent to choosing an ordering of all edges and, for each edge in that order, swapping the labels of its two endpoints.

codeforcescompetitive-programmingcombinatoricsdfs-and-similardsutrees
CF 1253D - Harmonious Graph

We are given an undirected graph on vertices labeled from 1 to n, and we are allowed to add edges. The goal is to make the graph satisfy a very specific reachability constraint that depends on the natural ordering of vertices.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similardsugraphsgreedysortings
CF 1252J - Tiling Terrace

We are given a one-dimensional yard of length $N$, where each position is either usable soil or blocked by a rock. We want to place tiles on this line to maximize total “ghost repelling power”.

codeforcescompetitive-programmingbrute-forcedp
CF 1252H - Twin Buildings

We are given several rectangular plots of land, and we want to place two identical rectangular buildings of size $A times B$.

codeforcescompetitive-programminggreedyimplementation
CF 1252F - Regular Forestation

We are given a tree with up to 4000 nodes, and we are allowed to pick a single node and remove it. Removing a node splits the tree into several connected components, each of which is itself a tree. The number of components equals the degree of the removed node.

codeforcescompetitive-programminghashingtrees
CF 1250L - Divide The Students

We are given three groups of students determined by their preferred programming language. The task is to split all students into exactly three practice groups. The only restriction is that a single group is not allowed to contain both Assembler fans and C++ fans at the same time.

codeforcescompetitive-programmingbinary-searchgreedymath
CF 1249F - Maximum Weight Subset

We are given a tree where each vertex carries a positive weight. The task is to select a subset of vertices that maximizes the sum of chosen weights, but with a strict geometric restriction: any two selected vertices must be more than $k$ edges apart in the tree.

codeforcescompetitive-programmingdptrees
CF 1249E - By Elevator or Stairs?

We are given a building with floors from 1 to n. Moving between adjacent floors can be done in two different ways: stairs or elevator. Stairs have per-floor costs a[i], and elevator has per-floor costs b[i] plus a fixed overhead c every time you start an elevator ride.

codeforcescompetitive-programmingdpshortest-paths
CF 1249D1 - Too Many Segments (easy version)

We are given a collection of integer intervals on a number line. Each interval represents coverage over all integer points inside its range. A point becomes problematic if it is covered by more than $k$ intervals at the same time.

codeforcescompetitive-programminggreedy
CF 1249C2 - Good Numbers (hard version)

We are given several independent queries. Each query provides a large integer $n$, and we must output the smallest integer $m ge n$ such that $m$ can be expressed as a sum of distinct powers of 3.

codeforcescompetitive-programmingbinary-searchgreedymathmeet-in-the-middle
CF 1249B1 - Books Exchange (easy version)

Each child starts with exactly one book, and every day all books are passed simultaneously according to a fixed permutation. If a child i gives their book to p[i], then after one day the book moves one step along this directed edge.

codeforcescompetitive-programmingdsumath
CF 1249C1 - Good Numbers (easy version)

We are working with numbers that can be decomposed using a very specific building system: powers of three, where each power can be used at most once.

codeforcescompetitive-programmingbrute-forcegreedyimplementation
CF 1249B2 - Books Exchange (hard version)

We are given a system where each child initially holds a unique book, and every day each book is passed to another fixed child according to a permutation. After one day, every book moves once; after two days, it moves again under the same rule, and so on.

codeforcescompetitive-programmingdfs-and-similardsumath
CF 1248D1 - The World Is Just a Programming Task (Easy Version)

We are given a string made only of opening and closing brackets. Think of it as a circular sequence, where we are allowed to rotate it in any way.

codeforcescompetitive-programmingbrute-forcedpgreedyimplementation
CF 1248B - Grow The Tree

We are given a multiset of stick lengths, and we must arrange all of them into a polyline starting at the origin. Each stick becomes one segment of this polyline, and every segment must be axis-aligned, meaning it is either horizontal or vertical.

codeforcescompetitive-programminggreedymathsortings
CF 1245E - Hyakugoku and Ladders

The game can be viewed as a directed line of states arranged along a fixed serpentine path on a 10 by 10 grid. Each cell corresponds to a position on this path, starting from the bottom-left cell and ending at the top-left cell.

codeforcescompetitive-programmingdpprobabilitiesshortest-paths
CF 1245D - Shichikuji and Power Grid

We are given a set of cities placed on a plane. Each city can be “powered” in one of two ways: either we directly build a power station in it, or we connect it (directly or indirectly through other cities) to a city that already has a power station.

codeforcescompetitive-programmingdsugraphsgreedyshortest-pathstrees
CF 1245C - Constanze's Machine

We receive a string that is claimed to be produced by a slightly broken writing machine. The machine normally prints each spoken letter as itself, but two special letters behave differently: if the user says w, the machine writes uu, and if the user says m, it writes nn.

codeforcescompetitive-programmingdp
CF 1244G - Running in Pairs

We are given two groups of runners, each group containing the integers from 1 to n. We must arrange each group into a permutation, one for the first track and one for the second track.

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 1244E - Minimizing Difference

We are given a list of integers and a limited budget of unit operations. Each operation lets us pick a single element and move it by exactly one step, either up or down.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsgreedysortingsternary-searchtwo-pointers
CF 1244F - Chips

We are given a circular arrangement of cells, each cell holding either white or black. The system evolves in discrete steps, and each cell updates its color by looking at a fixed local neighborhood: itself and its two adjacent cells on the circle.

codeforcescompetitive-programmingconstructive-algorithmsimplementation
CF 1244C - The Football Season

We are given a season summary for a football team, but instead of individual match results, only aggregated information is known. The team played exactly $n$ matches and accumulated a total of $p$ points.

codeforcescompetitive-programmingbrute-forcemathnumber-theory
CF 1244B - Rooms and Staircases

We are given a building with two parallel rows of rooms, one row per floor, and each row has $n$ rooms arranged left to right. From any room, movement is allowed horizontally to adjacent rooms on the same floor.

codeforcescompetitive-programmingbrute-forceimplementation
CF 1244A - Pens and Pencils

Polycarp has two types of work tomorrow: writing lectures and drawing during practical classes. For lectures he must use pens, and each pen can be used for a limited number of lectures before it dries out.

codeforcescompetitive-programmingmath
CF 1243B1 - Character Swap (Easy Version)

We are given two strings of equal length, and we are allowed to perform exactly one swap operation. The swap is constrained in a specific way: we pick one position in the first string and one position in the second string, then exchange those two characters.

codeforcescompetitive-programmingstrings
CF 1243B2 - Character Swap (Hard Version)

We are given two strings of equal length, and we are allowed to repeatedly fix them using a very specific operation: pick one character from the first string and one character from the second string, and swap them.

codeforcescompetitive-programmingstrings
CF 1242B - 0-1 MST

We are given a complete undirected graph on $n$ vertices. Every pair of vertices is connected, but edges come in only two possible weights: either 0 or 1. Among all $binom{n}{2}$ edges, exactly $m$ of them have weight 1, and every other edge implicitly has weight 0.

codeforcescompetitive-programmingdfs-and-similardsugraphssortings
CF 1239F - Swiper, no swiping!

We are given multiple connected graphs, each with up to half a million vertices and edges in total across all test cases.

codeforcescompetitive-programminggraphsimplementation
CF 1239E - Turtle

We are given a grid with exactly two rows and n columns. Every cell contains a value, and we are allowed to permute these 2n values arbitrarily between the cells.

codeforcescompetitive-programmingdpimplementation
CF 1239D - Catowice City

We are given a system of $n$ people, each of whom owns exactly one cat, forming a natural pairing between person $i$ and cat $i$.

codeforcescompetitive-programming2-satdfs-and-similargraph-matchingsgraphs
CF 1239B - The World Is Just a Programming Task (Hard Version)

We are given a bracket string and we are allowed to perform exactly one swap of any two positions, possibly the same position.

codeforcescompetitive-programmingimplementation
CF 1239C - Queue in the Train

We are given a row of seats indexed from left to right, and each seat has exactly one passenger. Every passenger has a planned time when they become ready to go to a water tank located just left of seat 1.

codeforcescompetitive-programmingdata-structuresgreedyimplementation
CF 1238E - Keyboard Purchase

We are given a fixed string that we type repeatedly using a one-finger keyboard. The keyboard is defined by choosing a permutation of the first $m$ lowercase letters, and this permutation places each letter at a unique position on a line.

codeforcescompetitive-programmingbitmasksdp
CF 1238G - Adilbek and the Watering System

The system can only run if it never becomes empty, meaning at every minute it must contain at least one liter before consumption happens. It continuously drains one liter per minute for a total of m minutes, and its storage capacity is capped at c.

codeforcescompetitive-programmingdata-structuresgreedysortings
CF 1238D - AB-string

We are given a binary string consisting only of the characters A and B. Our task is to count how many of its contiguous substrings are “good” under a specific structural condition involving palindromes.

codeforcescompetitive-programmingbinary-searchcombinatoricsdpstrings
CF 1238C - Standard Free2play

We can think of the cliff as a vertical line of heights from 1 up to h, with a special starting platform at height h. Some of these heights already contain usable platforms, while the rest are empty. You are standing at the top platform and want to reach ground level 0.

codeforcescompetitive-programmingdpgreedymath
CF 1238B - Kill `Em All

The corridor can be seen as a number line where all monsters start strictly on the positive side. Each monster is a point on this line, and Ivan repeatedly performs an operation that chooses a center point and affects every monster depending on whether it lies to the left, at…

codeforcescompetitive-programminggreedysortings
CF 1237H - Balanced Reversals

We are given two binary strings of equal even length, and we are only allowed to modify the first string. The only operation available is somewhat unusual: we pick a prefix of even length and reverse that prefix in place.

codeforcescompetitive-programmingconstructive-algorithms
CF 1237G - Balanced Distribution

We are given a circular arrangement of $n$ people, each holding some number of stones. The total number of stones is divisible by $n$, so there exists a target value $T = frac{sum ai}{n}$ such that the goal is to end with every position holding exactly $T$ stones.

codeforcescompetitive-programmingdata-structuresdpgreedy
CF 1237D - Balanced Playlist

We are given a circular playlist of tracks, each with a numeric “coolness” value. Starting from any chosen track, we keep listening forward in cyclic order, revisiting tracks as needed. While listening, we maintain the maximum coolness seen so far.

codeforcescompetitive-programmingbinary-searchdata-structuresimplementation
CF 1237F - Balanced Domino Placements

We are given a grid where some dominoes are already placed. Each domino always occupies exactly two adjacent cells. The placement has a special restriction: no row or column is allowed to contain cells from two different dominoes.

codeforcescompetitive-programmingcombinatoricsdp
CF 1237A - Balanced Rating Changes

We are given a list of integers representing rating changes from a contest. The total sum of all these changes is exactly zero, meaning gains and losses perfectly balance out before any modification. The task is to transform each value independently into a “halved” version.

codeforcescompetitive-programmingimplementationmath
CF 1237C2 - Balanced Removals (Harder)

We are given a set of points in three-dimensional space, and we must repeatedly delete them in pairs until nothing remains. The restriction is not about distance or parity, but about geometry of axis-aligned boxes. At any moment, we pick two remaining points.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsdivide-and-conquergreedyimplementationsortings
CF 1237C1 - Balanced Removals (Easier)

We are given an even number of distinct points in 3D space. The task is to repeatedly remove points in pairs until none remain.

codeforcescompetitive-programmingconstructive-algorithmsgeometrygreedy
CF 1236E - Alice and the Unfair Game

We are given a line of $n$ boxes and a single token hidden in one of them. The game proceeds in $m$ rounds. In each round Alice points to a box index $ai$, trying to locate the token.

codeforcescompetitive-programmingbinary-searchdata-structuresdpdsu
CF 1236F - Alice and the Cactus

We are given a connected undirected graph with a special structure: it is a cactus, meaning every edge belongs to at most one simple cycle. On this graph, each vertex independently survives with probability $1/2$, otherwise it is deleted together with all incident edges.

codeforcescompetitive-programmingdfs-and-similargraphsmathprobabilities
CF 1236C - Labs

We are given the integers from 1 to $n^2$, each representing a lab positioned by height, where smaller numbers are lower and larger numbers are higher.

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementation
CF 1236D - Alice and the Doll

We are given a rectangular grid with some blocked cells. Starting from the top-left corner, a token must move through the grid so that every unblocked cell is visited exactly once.

codeforcescompetitive-programmingbrute-forcedata-structuresgreedyimplementation
CF 1236A - Stones

We are given three piles of stones. From these piles, Alice can repeatedly perform two kinds of moves. One move consumes one stone from the first pile and two stones from the second pile. The other move consumes one stone from the second pile and two stones from the third pile.

codeforcescompetitive-programmingbrute-forcegreedymath
CF 1234B2 - Social Network (hard version)

We are simulating a dynamic list of conversations ordered by “recency of appearance on screen”, with a hard cap on how many conversations can be shown at once. Each incoming message is tied to a single friend ID, and every ID corresponds to exactly one conversation.

codeforcescompetitive-programmingdata-structuresimplementation
CF 1234D - Distinct Characters Queries

We are maintaining a string of lowercase letters under two kinds of operations. One operation modifies a single position in the string, changing its character.

codeforcescompetitive-programmingdata-structures
CF 1228B - Filling the Grid

We are given a grid of size (h times w), initially completely empty, and two sets of constraints that describe how far blocks of filled cells must extend from the top and from the left.

codeforcescompetitive-programmingimplementationmath
CF 1228F - One Node is Gone

We start with a perfect binary tree of height n, meaning every internal node has exactly two children and all leaves sit at the same depth. This tree contains exactly 2^n - 1 nodes and has a very rigid recursive structure: every subtree is itself a perfect binary tree.

codeforcescompetitive-programmingconstructive-algorithmsimplementationtrees
CF 1228E - Another Filling the Grid

We are filling an $n times n$ grid with integers from $1$ to $k$. The restriction is not about individual cells, but about structure: every row must contain at least one occurrence of the value $1$, and every column must also contain at least one occurrence of $1$.

codeforcescompetitive-programmingcombinatoricsdpmath
CF 1227E - Arson In Berland Forest

The input describes a finite rectangular snapshot of an otherwise infinite grid of trees. Each cell is either burned or intact, and the grid fully contains all burned cells. Outside the grid, everything is guaranteed to be unburned.

codeforcescompetitive-programmingbinary-searchgraphsshortest-paths
CF 1227G - Not Same

We are given an array where each position stores a pile of blocks. At position i, there are ai identical blocks stacked. One operation consists of choosing some set of positions and removing exactly one block from each chosen position.

codeforcescompetitive-programmingconstructive-algorithms
CF 1227F1 - Wrong Answer on test 233 (Easy Version)

We are given a fixed answer key for a multiple-choice test of length n, where each question has a known correct option. We are also considering every possible way to fill in answers for the test, where each position can take any value from 1 to k.

codeforcescompetitive-programmingdp