brain

tamnd's digital brain — notes, problems, research

43815 notes

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
CF 1227D2 - Optimal Subsequences (Hard Version)

We are given a fixed array of integers and many queries. Each query asks us to imagine picking exactly $k$ elements from the array while preserving their original order. Among all such subsequences of length $k$, we first want the one with the maximum possible sum.

codeforcescompetitive-programmingdata-structuresgreedy
CF 1227C - Messy

We are given a sequence of parentheses and are allowed to apply an operation that reverses any contiguous segment.

codeforcescompetitive-programmingconstructive-algorithms
CF 1227B - Box

We are given a non-decreasing array q, which is claimed to be produced from some hidden permutation p by taking prefix maxima. At every position i, q[i] equals the largest value among the first i elements of p.

codeforcescompetitive-programmingconstructive-algorithms
CF 1227D1 - Optimal Subsequences (Easy Version)

We are given a sequence of numbers and, for each query, we must imagine selecting exactly k elements from this sequence while preserving their original order. Among all such subsequences, we first care about maximizing the sum of chosen values.

codeforcescompetitive-programmingdata-structuresgreedy
CF 1225F - Tree Factory

We are given a rooted tree where vertex labels already obey a strict ordering constraint: every node except the root has a parent with a smaller label.

codeforcescompetitive-programmingconstructive-algorithmsgreedytrees
CF 1225D - Power Products

We are given a sequence of positive integers and asked to count how many pairs of indices produce a product that is a perfect k-th power. In other words, for two distinct elements $ai$ and $aj$, we want to know whether their product can be written as $x^k$ for some integer $x$.

codeforcescompetitive-programminghashingmathnumber-theory
CF 1225C - p-binary

We are given a positive target number $n$. We also fix an integer $p$, which shifts a family of numbers of the form $2^x + p$, where $x ge 0$. Each such value is a single “building block”, and we are allowed to reuse the same block any number of times.

codeforcescompetitive-programmingbitmasksbrute-forcemath
CF 1223F - Stack Exterminable Arrays

We are given an array and a peculiar cancellation process that behaves like a stack with annihilation. We scan the array from left to right, maintaining a stack. When we see a value, if the stack top is different, we push it.

codeforcescompetitive-programmingdata-structuresdivide-and-conquerdphashing
CF 1223G - Wooden Raft

We are given a collection of logs, each with an integer length. From these logs we are allowed to cut pieces, but we are not allowed to glue pieces together. The goal is to assemble a rectangular raft structure that requires two kinds of side lengths, call them x and y.

codeforcescompetitive-programmingbinary-searchmathnumber-theory
CF 1223E - Paint the Tree

We are given a tree where every edge has a weight. The task is to assign colors to vertices under a very specific rule: each vertex receives exactly $k$ colors, and any particular color can appear at most twice across the entire tree.

codeforcescompetitive-programmingdpsortingstrees
CF 1223B - Strings Equalization

Each query gives two strings of the same length. You are allowed to repeatedly apply an operation on either string: pick two neighboring characters and overwrite one with the other.

codeforcescompetitive-programmingstrings
CF 1223A - CME

We are given a number of matches and we want to arrange them into a valid arithmetic equation of the form “a + b = c”, where each number is strictly positive.

codeforcescompetitive-programmingmath
CF 1221F - Choose a Square

Something went wrong. If this issue persists please contact us through our help center at help.openai.com.

codeforcescompetitive-programmingbinary-searchdata-structuressortings
CF 1221B - Knights

We are filling an $n times n$ chessboard where every cell must contain either a white knight or a black knight. The goal is not about placing pieces to avoid attacks, but rather to maximize how many pairs of opposing-colored knights can attack each other under standard knight…

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1221D - Make The Fence Great Again

We are given a sequence of fence boards, each with an initial height and a cost per unit increase in height. One operation lets us pick a board and increase its height by exactly one, paying its per-unit cost each time. We can repeat this any number of times for any board.

codeforcescompetitive-programmingdp
CF 1221E - Game With String

We are given a binary string made of two types of characters: empty cells denoted by . and blocked cells denoted by X. Two players alternate turns, starting with Alice.

codeforcescompetitive-programminggames
CF 1220G - Geolocation

We are given a fixed set of points in the plane, which we can think of as antennas. For each query, there is an unknown integer point in a bounded grid, and we are told the squared distances from that point to all antennas.

codeforcescompetitive-programminggeometry
CF 1220F - Gardener Alex

We are given a permutation of length $n$. From this permutation, a binary tree is constructed in a deterministic way: the smallest value in a segment becomes the root of that segment, and the remaining elements are split into the left and right subsegments around it.

codeforcescompetitive-programmingbinary-searchdata-structures
CF 1220D - Alex and Julian

We are given a finite set of positive integers, but the structure we build from it is infinite. Every integer is a vertex, and each number in the set is interpreted as a “distance type”.

codeforcescompetitive-programmingbitmasksmathnumber-theory
CF 1220E - Tourism

We are given a connected undirected graph where each vertex represents a city and each city has a fixed value. Alex starts from a specific city and walks through the graph by traversing edges, with one restriction: he is not allowed to immediately traverse back along the same…

codeforcescompetitive-programmingdfs-and-similardpdsugraphsgreedytrees
CF 1220A - Cards

We are given a multiset of letters that originally came from writing several binary words, where each word is either the string "zero" representing digit 0 or "one" representing digit 1.

codeforcescompetitive-programmingimplementationsortingsstrings
CF 1218I - The Light Square

We are given three ingredients that define a transformation problem on a binary grid. First is an initial $N times N$ board of lights, each cell either on or off. Second is a target $N times N$ configuration we want to reach.

codeforcescompetitive-programming2-satdfs-and-similargreedy
CF 1218G - Alpha planetary system

We are given a network of spaceports connected by undirected shuttle routes. Each spaceport belongs to exactly one of three planets labeled X, Y, or Z. Every shuttle connects two different spaceports, and only connections between different planets exist.

codeforcescompetitive-programmingconstructive-algorithmsgraphsshortest-paths
CF 1218D - Xor Spanning Tree

We are given an undirected graph where each edge represents a wormhole between two planets and has a repair cost.

codeforcescompetitive-programmingdivide-and-conquerfftgraphs
CF 1218E - Product Tuples

We are given an array of values, and each query asks us to evaluate a very specific symmetric polynomial built from a transformed version of that array. For a fixed number $q$, we first convert every element $ai$ into $bi = q - ai$.

codeforcescompetitive-programmingdivide-and-conquerfft
CF 1218A - BubbleReactor

We are given an undirected graph with $N$ vertices and exactly $N$ edges, and no pair of vertices is connected by more than one edge.

codeforcescompetitive-programmingdpgraphs
CF 1218B - Guarding warehouses

We are given a set of non-overlapping convex polygonal regions in the plane. Each polygon represents a warehouse. Bob stands at the origin, and for every point inside any warehouse we want to know whether Bob can “see” it using a special optical device.

codeforcescompetitive-programmingdata-structuresgeometry
CF 1218C - Jumping Transformers

We are moving through a grid from the top-left cell to the bottom-right cell, and each second we can only move either one step to the right or one step down. Any valid path is therefore a monotone path with exactly $N + M - 2$ moves.

codeforcescompetitive-programmingdp
CF 1217F - Forced Online Queries Problem

The graph starts empty, but it is continuously modified by two types of operations. The first operation toggles an edge between two vertices, and the second operation asks whether two vertices are connected in the current graph.

codeforcescompetitive-programmingdata-structuresdivide-and-conquerdsugraphstrees
CF 1217A - Creating a Character

We are given a character with two base attributes: strength and intelligence. We are also given a pool of extra experience points that must all be distributed. Each point can increase either strength or intelligence by exactly one unit.

codeforcescompetitive-programmingbinary-searchmath
CF 1217E - Sum Queries?

We are given an array of integers that changes over time, and we are repeatedly asked to inspect a chosen segment of this array.

codeforcescompetitive-programmingdata-structuresgreedyimplementationmath
CF 1217D - Coloring Edges

We are given a directed graph where each edge is fixed in advance, and we must assign a color (an integer label) to every edge. The constraint is not about vertices but about directed cycles: if you look at all edges of a single color, they must not contain any directed cycle.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similargraphs
CF 1216D - Swords

We are given a collection of sword types, each type having some remaining count after a theft. For each type $i$, the value $ai$ tells us how many swords of that type are still present in the basement. Originally, every type had the same unknown quantity $x$.

codeforcescompetitive-programmingmath
CF 1216A - Prefixes

We are given a binary string made only of the characters a and b, and its length is guaranteed to be even. The task is to transform this string using the minimum number of single-character flips so that every prefix whose length is even contains exactly the same number of a…

codeforcescompetitive-programmingstrings
CF 1214H - Tiles Placement

We are given a tree with $n$ vertices, where each vertex represents a square in a pedestrian network. Each vertex must be assigned one of $k$ colors.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similartrees