brain

tamnd's digital brain — notes, problems, research

41650 notes

CF 2195B - Heapify 1

We are given a permutation of integers from 1 to n and can perform a specific type of swap: for any index i from 1 to n/2, we can swap the element at position i with the element at position 2i.

codeforcescompetitive-programmingimplementationsortings
CF 2195C - Dice Roll Sequence

We are given a sequence of numbers from 1 to 6, and we are allowed to change any element to any other value from 1 to 6. The goal is to transform the sequence so that every pair of neighboring elements behaves like valid transitions on a standard dice.

codeforcescompetitive-programmingdpgreedy
CF 2195A - Sieve of Erato67henes

We are given several very small collections of integers, each collection containing at most five numbers, and we are asked whether we can pick some non-empty subset whose product is exactly 67. Each test case is independent.

codeforcescompetitive-programmingmathnumber-theory
CF 2196F - Indivisible

We are asked to construct a graph with a given number of vertices n and edges m such that it cannot be split into two parts where the sums of degrees of each part are equal. The graph must be simple, with no loops or multiple edges.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgraphs
CF 2196E2 - Fuzzy Concatenation (Hard version)

We are given a source string s and a target string t. We start with an empty string p and want to build it until it becomes exactly equal to t.

codeforcescompetitive-programmingbinary-searchbitmasksdata-structuresdpgreedystring-suffix-structures
CF 2196E1 - Fuzzy Concatenation (Easy Version)

We are given a source string s and a target string t. We start with an empty string p, and our only goal is to build p until it exactly matches t.

codeforcescompetitive-programmingbinary-searchbitmasksbrute-forcedata-structuresgreedystring-suffix-structures
CF 2196D - Double Bracket Sequence

We are given a string consisting of round brackets "(" and ")", and square brackets "[" and "]". The string has even length.

codeforcescompetitive-programmingdata-structuresdpexpression-parsingflowsgreedystrings
CF 2196C2 - Interactive Graph (Hard Version)

We are asked to reconstruct a hidden directed acyclic graph (DAG) by interacting with a system that enumerates all paths in lexicographic order. Each query allows us to ask for the $k$-th path.

codeforcescompetitive-programmingcombinatoricsdfs-and-similardpgraphsinteractive
CF 2196A - Game with a Fraction

We are given two integers, $p$ and $q$, representing a fraction $frac{p}{q}$. Alice and Bob play a turn-based game where on each turn a player can decrease $p$ by 1 (if $p 0$) or decrease $q$ by 1 (if $q 1$). Alice goes first.

codeforcescompetitive-programminggamesmath
CF 2196C1 - Interactive Graph (Simple Version)

We are given a directed acyclic graph with up to 15 vertices. The edges are unknown, but we are allowed to probe the graph through an oracle. Each query asks for the k-th path in the lexicographically sorted list of all valid directed paths in the graph.

codeforcescompetitive-programmingbinary-searchcombinatoricsdfs-and-similardpgraphsinteractive
CF 2196B - Another Problem about Beautiful Pairs

We are given an array and we want to count pairs of positions where a very specific relationship holds between the values at those positions and their distance in the array.

codeforcescompetitive-programmingbrute-forcemathtwo-pointers
CF 2197A - Friendly Numbers

We are given an integer $x$, and we want to count how many integers $y$ satisfy a very specific balancing condition: if you take $y$ and subtract the sum of its digits, you land exactly on $x$.

codeforcescompetitive-programmingbinary-searchbrute-forceexpression-parsingmathschedules
CF 2199I - Strange Process

We start with a very constrained system: one array begins as all ones, another array is all zeros, and a third array c provides a sequence of target values between 1 and 50.

codeforcescompetitive-programming*special
CF 2199H - Sum of MEX

We are given an array of length $n$ where each element is an integer from $-1$ to $n$. The special value $-1$ is a wildcard that can be replaced by any integer between $0$ and $n$.

codeforcescompetitive-programming*specialcombinatoricsdata-structuresdpmath
CF 2199F - Self-Produced Sequences

We are given an integer array and asked to count subsequences that are "self-produced." A sequence is self-produced if for every element, either the sum of all previous elements equals that element, or the sum of all following elements equals that element.

codeforcescompetitive-programming*specialcombinatoricsmath
CF 2199G - Jammer

We are asked to find positions on a rectangular grid where we can place a jammer such that it always intercepts a robot moving from the bottom-left corner $(0,0)$ to the top-right corner $(n,m)$, while remaining invisible at the start and end points.

codeforcescompetitive-programming*specialmath
CF 2199E - Supersequence

We are given an initial array $a$, and we want to imagine building a longer array $b$ that contains all elements of $a$ in order (not necessarily consecutively), but between every pair of adjacent elements in $b$, the values must differ by exactly 1.

codeforcescompetitive-programming*specialbinary-searchgreedy
CF 2199A - Game

Alice and Bob play a three-round card game where each round has independent scores between 0 and a maximum k. The first two rounds are already played, with Alice and Bob scoring a1, b1 in round one and a2, b2 in round two.

codeforcescompetitive-programming*special
CF 2199D - Two Arrays

We are given two arrays, each sorted in non-decreasing order, and each having an odd number of elements. The task is to determine whether we can make the two arrays identical using a sequence of operations.

codeforcescompetitive-programming*specialmath
CF 2199C - Minesweeper

We are asked to build a grid with exactly two rows and some number of columns. Each cell can either contain a mine or be empty.

codeforcescompetitive-programming*specialconstructive-algorithmsgreedy
CF 2199B - Two Towers

We start with two stacks of blocks. The first stack has height a, the second has height b. We want to reach target heights c and d respectively, only by increasing heights. There are two allowed operations. The first operation increases exactly one of the towers by one block.

codeforcescompetitive-programming*specialgreedymath
CF 2200H - Six Seven

We are given an array of positive integers, and we define a number as special if the power of 6 that divides it is strictly greater than the power of 7 that divides it.

codeforcescompetitive-programmingdivide-and-conquermathnumber-theorystringstrees
CF 2200G - Operation Permutation

We are given a starting integer $x$ and a list of $n$ operations, each of which modifies $x$ by either addition, subtraction, multiplication, or division by a positive integer. The twist is that the operations are applied in a random order: all $n!

codeforcescompetitive-programmingcombinatoricsdpmathprobabilities
CF 2200F - Mooclear Reactor 2

We are given a collection of particles, each with an energy value and a reactivity limit. A particle's reactivity determines the maximum number of other particles that can coexist with it in the reactor.

codeforcescompetitive-programmingbrute-forcedata-structuresgreedyimplementationsortings
CF 2200D - Portal

We are given a permutation arranged on a line and two special cutting points, called portals. These portals divide the array into segments and define where elements can be extracted from and reinserted.

codeforcescompetitive-programminggreedysortings
CF 2200E - Divisive Battle

We are given an array of positive integers and two players who alternate turns, starting with Alice. The game evolves by either ending immediately if the current array is already non-decreasing, or by performing a single allowed operation on a chosen element.

codeforcescompetitive-programminggamesgreedymathnumber-theory
CF 2200A - Eating Game

We are given a circular table with n players, each having a certain number of dishes they must eat. Players take turns sequentially around the table, and during a player’s turn, if they have any dishes left, they must eat exactly one.

codeforcescompetitive-programminggreedy
CF 2200C - Specialty String

We are given a string consisting of lowercase letters, and the game involves repeatedly replacing pairs of equal letters with asterisks, provided that all characters between them have already become asterisks.

codeforcescompetitive-programmingbrute-forcegreedystrings
CF 2200B - Deletion Sort

We are given several independent test cases. In each one, we start with a short array of positive integers and repeatedly remove elements until the remaining array is sorted in non-decreasing order.

codeforcescompetitive-programmingbitmasksbrute-forcegreedysortings
CF 2201G - Codeforces Heuristic Contest 1001

We are given a grid of size $n times n$ where each cell can be thought of as a vertex labeled by its row and column $(r,c)$. Two vertices are connected if the squared Euclidean distance between them is exactly 13.

codeforcescompetitive-programmingconstructive-algorithms
CF 2201F2 - Monotone Monochrome Matrices (Hard Version)

We start with an $n times n$ grid that is completely empty, and we gradually paint some cells black. After each paint operation, we must decide whether the current black-white pattern avoids a very specific forbidden configuration involving two rows and two columns.

codeforcescompetitive-programmingconstructive-algorithmsdata-structureshashingmath
CF 2201F1 - Monotone Monochrome Matrices (Medium Version)

We are maintaining an $n times n$ grid that starts completely empty in the sense that every cell is white. Over time, we flip certain cells to black, one at a time, and after each flip we must decide whether the current black-white pattern satisfies a structural restriction…

codeforcescompetitive-programmingdata-structureshashing
CF 2201E - ABBA Counting

We are given a string T of even length n, consisting of the characters 'a', 'b', and '?'. The question asks us to count all possible strings S that match T wherever T specifies a character (i.e., S[i] = T[i] when T[i] is not '?

codeforcescompetitive-programmingfftmathnumber-theorystrings
CF 2201D - Binary Not Search and Queries

We are given a sequence of integers and a set of queries that modify elements of the sequence. After each modification, we are asked to compute two values derived from the sequence: the maximum length of two subarrays that are permutations of each other, and how many pairs of…

codeforcescompetitive-programmingdata-structuresgreedyimplementation
CF 2201A1 - Lost Civilization (Easy Version)

We are given a sequence of integers that has been generated by a very simple algorithm: start with some initial sequence of length m, and repeatedly choose an element and insert its value plus one immediately after it until the sequence reaches length m + k.

codeforcescompetitive-programmingdata-structures
CF 2201C - Rigged Bracket Sequence

We are given a well-formed bracket string, meaning it behaves like a correctly nested sequence of parentheses. From this string, we choose some positions to form a subsequence, and then we perform a cyclic right shift on the characters located at those chosen positions.

codeforcescompetitive-programmingcombinatoricsdpgreedy
CF 2201A2 - Lost Civilization (Hard Version)

The problem gives us a mysterious sequence generated by an ancient algorithm. Starting from a short sequence of length m, the algorithm repeatedly inserts a new number xi + 1 after any chosen element xi until the sequence reaches length m+k.

codeforcescompetitive-programmingdata-structuresdp
CF 2201B - Recollect Numbers

We are given $2n$ cards where each number from $1$ to $n$ appears exactly twice. The cards are initially face down, and in each turn, the player flips two cards. If the flipped cards show the same number, they are removed; otherwise, they are flipped back.

codeforcescompetitive-programmingconstructive-algorithms
CF 2202A - Parkour Design

The problem is about building a sequence of moves on a 2D integer grid starting at the origin (0,0) and ending at a target point (x,y).

codeforcescompetitive-programmingmath
CF 2203F - Binary Search with One Swap

We start with an array containing the numbers from 1 to n in increasing order. Then we pick two positions i and j and swap the elements at those positions, creating exactly one disturbance in an otherwise perfectly sorted sequence.

codeforcescompetitive-programmingbinary-searchdivide-and-conquerdphashingmathtwo-pointers
CF 2203E - Probabilistic Card Game

We are asked to compute the expected score for Bob in a turn-based card game where Alice and Bob play optimally. Each round, a new card is added to a deck.

codeforcescompetitive-programmingbinary-searchdata-structuresgamesgreedymathternary-search
CF 2203D - Divisibility Game

We are given two multisets, one called a and one called b. They define a game where players do not modify a at all, but gradually consume elements from b.

codeforcescompetitive-programmingbrute-forcegamesgreedynumber-theory
CF 2203B - Beautiful Numbers

We are asked to transform a given integer into a "beautiful number" with the minimum number of digit changes. A beautiful number is defined such that applying the sum-of-digits function twice yields the same result as applying it once.

codeforcescompetitive-programmingbitmasksdpfftgreedymath
CF 2203C - Test Generator

The problem asks us to generate an array of non-negative integers that sum up to a given total s, with the additional constraint that each element must only have bits set that are also set in another number m.

codeforcescompetitive-programmingbinary-searchbitmasksgreedymath
CF 2203A - Towers of Boxes

Monocarp has n identical boxes, each weighing m units and able to support up to d units on top. He wants to stack all the boxes into towers while respecting durability: no box can support more weight than d.

codeforcescompetitive-programmingmath
CF 2204F - Sum of Fractions

We are asked to repeatedly increase fractions of the form $1/bi$ either by incrementing the numerator or decreasing the denominator if it is larger than 1.

codeforcescompetitive-programmingbinary-searchbrute-forcecombinatoricsdata-structuresgreedymathnumber-theorytwo-pointers
CF 2204G - Grid Path

We are working on a rectangular grid where we start from the top-left cell and are allowed to walk using three moves: left, right, or down. There is no upward movement, which is the key structural restriction.

codeforcescompetitive-programmingdpgraphsmatrices
CF 2204E - Sum of Digits (and Again)

We are given a multiset of digits for each test case, and we are allowed to reorder them freely. The goal is to decide whether we can arrange these digits to match a very specific structured string generated from some positive integer x.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsmath
CF 2204D - Alternating Path

We are given an undirected graph and asked to assign a direction to each edge such that some vertices become "beautiful".

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similargraph-matchingsgraphs
CF 2204A - Passing the Ball

We are given a line of students arranged from left to right, and a ball that moves deterministically according to fixed rules.

codeforcescompetitive-programmingbrute-forceimplementation
CF 2204C - Spring

Each test case describes three periodic visitors to a spring. Alice arrives every $a$ days, Bob every $b$ days, and Carol every $c$ days. On any day in the range from day $1$ to day $m$, some subset of them may arrive depending on divisibility of the day number.

codeforcescompetitive-programmingmathnumber-theory
CF 2204B - Right Maximum

We are given an array of integers and asked to simulate a very specific removal process. In each operation, we look at the current array, find the maximum element, and if multiple elements share that maximum, we choose the rightmost one.

codeforcescompetitive-programminggreedy
CF 2205G - Simons and Diophantus Equation

We are asked to count the number of ordered triples of integers $(i, j, k)$ in the range $[0, m]$ such that the equation $(i oplus j) cdot x + (j oplus k) cdot y = n$ has an integer solution for $x$ and $y$. Here $oplus$ is the bitwise XOR.

codeforcescompetitive-programmingbitmasksbrute-forcedata-structuresmathnumber-theory
CF 2205F - Simons and Reconstructing His Roads

We are given a rectangular grid representing a city, with intersections at coordinates $(i,j)$. Streets only exist between neighboring intersections, either horizontally or vertically. Each street has an integer weight and may or may not be allowed for reconstruction.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresdsugraphs
CF 2205E - Simons and Dividing the Rhythm

We are asked to count how many arrays $S$ exist such that, after a single sequence of independent subarray reversals, the resulting array equals a given array $T$.

codeforcescompetitive-programmingcombinatoricsdata-structuresdpdsumathstring-suffix-structuresstrings
CF 2205D - Simons and Beating Peaks

We are asked to transform a permutation of integers into a "cool" array. An array is cool if no element in the middle of a triplet is the maximum among its neighbors. In other words, the array must have no peaks, where a peak is a value larger than both its immediate neighbors.

codeforcescompetitive-programmingdata-structuresdivide-and-conquerdpgreedyimplementationtrees
CF 2205A - Simons and Making It Beautiful

We are given a permutation p of length n. An index i is called ugly if it is the first time the maximum value is reached at that position. More formally, i is ugly if p[i] is equal to the maximum of p[1..i].

codeforcescompetitive-programmingbrute-forceconstructive-algorithms
CF 2205B - Simons and Cakes for Success

We are asked to help Simons divide cakes among his friends. More formally, for a given number of friends $n$, we need to find the smallest positive integer $k$ such that $k^n$ is divisible by $n$. The input consists of multiple test cases, each specifying the number of friends.

codeforcescompetitive-programmingimplementationmath
CF 2205C - Simons and Posting Blogs

We are given several independent scenarios. In each one, there are several “blogs”, and each blog contains an ordered list of user IDs.

codeforcescompetitive-programminggreedysortings
CF 2206L - Onion

We are given a large set of points on a two-dimensional plane, constructed using a simple linear function modulo $n$. Specifically, each point has coordinates $(x, y)$ where $x$ ranges from $0$ to $n-1$, and $y = (a cdot x + b) bmod n$.

codeforcescompetitive-programming
CF 2206M - Deformed Balance

We are given a parenthesis string $S$, and we are allowed to add some parentheses in front of it and some at the end.

codeforcescompetitive-programming
CF 2206K - Time Display Stickers

We are given a collection of digit stickers as a string. Each character represents one sticker of that digit. The goal is to assemble as many valid time displays in the format HH:MM, where HH is a two-digit hour between 00 and 11 inclusive, and MM is a two-digit minute between…

codeforcescompetitive-programmingbinary-search
CF 2206J - Worldwide Playlist

We are given a music playlist of n unique songs arranged in some initial order a. The app plays the songs in a circular fashion: after the last song, it starts over from the first. Separately, we have a desired listening sequence b of the same n songs.

codeforcescompetitive-programmingmath
CF 2206E - Parallel Sums

We are given a sequence of n integers A = [a1, a2, ..., an], but we do not know A itself. Instead, we are provided with a sequence of parallel sums of length n - m + 1, where each sum is the sum of m consecutive elements of A. Formally, the sums are si = ai + a{i+1} + ...

codeforcescompetitive-programmingdata-structuresgeometry
CF 2206I - Growth Factor

We are counting how many ways we can build a sequence of integers when each position has an upper limit, and each element must divide the next one. More concretely, at position i we choose a value bi that cannot exceed ai.

codeforcescompetitive-programmingcombinatoricsdpmathnumber-theory
CF 2206H - Reflect Sort

We are given an integer array and a somewhat unusual operation that allows us to “reflect” values around a chosen pivot element.

codeforcescompetitive-programmingnumber-theory
CF 2206G - Extra Transition

We are given a connected undirected graph on $n$ vertices, where vertex $1$ is a start and vertex $n$ is a finish.

codeforcescompetitive-programminggraphs
CF 2206D - Christmas Tree Un-decoration

We are given a rooted tree where vertex 1 is the root, and every node carries a pile of ornaments. The only way we are allowed to remove ornaments is by selecting a vertex $u$, and then subtracting one ornament from every node on the path from the root to $u$, as long as that…

codeforcescompetitive-programmingdata-structuresdptrees
CF 2206F - Minesweeper String

We are given a string of digits, each representing a cell in a conceptual 1D array of length $n$. Each digit either corresponds to some mines if it is non-zero, or an empty cell if it is zero.

codeforcescompetitive-programmingfftnumber-theory
CF 2206C - Upside Down Dijkstra

We are given a connected undirected graph with $n$ vertices and $m$ edges, where each edge connects two vertices but its weight is unknown.

codeforcescompetitive-programmingdfs-and-similar
CF 2206B - Subtree Removal Game

We are given a rooted tree with nodes numbered from 1 to $n$, rooted at node 1. Each node may either have an integer written on it (leaves) or be empty (internal nodes).

codeforcescompetitive-programmingbinary-searchgamestrees
CF 2206A - Compare Suffixes

We are tasked with sorting the suffixes of a hidden string $S$ using an interactive judge. The string has length $n$, and we do not know its contents. We can query any two suffixes $S(i)$ and $S(j)$ to learn which is lexicographically smaller.

codeforcescompetitive-programminginteractive
CF 2207H3 - Bowser's Castle (Hard Version)

We are given a black-box function of $n$ variables. The function is not arbitrary: it is built by taking the variables $x1, x2, ldots, xn$ in order and combining them using only min and max, with the restriction that each variable appears exactly once and in that fixed…

codeforcescompetitive-programmingconstructive-algorithmsdivide-and-conquerinteractivetreestwo-pointers
CF 2207H2 - Bowser's Castle (Medium Version)

We are asked to reverse-engineer a hidden function chosen by Bowser. The function takes n integer inputs and is constructed entirely from nested min and max operations, each input appearing exactly once in order from x1 to xn.

codeforcescompetitive-programmingconstructive-algorithmsdivide-and-conquerinteractivetreestwo-pointers
CF 2207G - Toothless

We are given an n × m grid representing sand, initially all white. Some cells are marked as needy () and must be painted black. Other cells are either special (x) or normal (.), and each non-needy cell has a value: special cells are worth b and normal cells are worth a.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similardsu
CF 2207H1 - Bowser's Castle (Easy Version)

We are given an unknown function that takes a list of n values and returns a single number. The function is not arbitrary: it is built by combining the inputs using only min and max, and every input variable appears exactly once, in order.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsdivide-and-conquergreedyinteractivetrees
CF 2207F - Hanabi

The problem gives us a Hanabi-like card game where Zuko holds all cards in a single row, one for each combination of rank and color. Iroh can see the cards, but Zuko cannot.

codeforcescompetitive-programmingbinary-searchdata-structuresdpdsuflowsgraph-matchingsgraphsgreedy
CF 2207E2 - N-MEX (Counting Version)

We are asked to count arrays of nonnegative integers that satisfy a sequence of nested MEX conditions. Concretely, we are given an array a of length n. For each position i in the array, we must ensure that the (n-i+1)-th MEX of the prefix [b1, ..., bi] equals a[i].

codeforcescompetitive-programmingcombinatoricsconstructive-algorithmsmath
CF 2207E1 - N-MEX (Constructive Version)

We are asked to construct an array b from a given array a such that, for each prefix of b, a generalized MEX condition holds. Specifically, the (n-i+1)-th MEX of the first i elements of b must equal a[i].

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 2207D - Boxed Like a Fish

We are given a tree where a token starts at a fixed non-leaf vertex. The goal is to determine whether this token can be guaranteed to reach any leaf vertex if two players act in turns. One player controls the token.

codeforcescompetitive-programmingdfs-and-similardpgamesshortest-pathstrees
CF 2207C - Where's My Water?

The grid can be understood more simply if we ignore the 2D picture and focus on each column independently. In column i, there are ai dirt tiles at the bottom, and all tiles above them up to height h are water. So the number of water tiles in column i is h - ai.

codeforcescompetitive-programmingdata-structuresdivide-and-conquerdpmath
CF 2207A - 1-1

We are given a binary string and a single operation that can be applied repeatedly. The operation only affects positions that are strictly inside the string, and only when that position is surrounded by ones on both sides.

codeforcescompetitive-programminggreedystrings
CF 2207B - One Night At Freddy's

We are asked to simulate a night at Freddy Fazbear’s Pizzeria in terms of danger management. Each animatronic accumulates danger every second, and the night lasts for a fixed number of seconds.

codeforcescompetitive-programminggamesgreedysortings
CF 2208D1 - Tree Orientation (Easy Version)

We are given a binary reachability matrix for a directed graph on $n$ nodes. The matrix tells us, for every ordered pair $(i, j)$, whether node $i$ can reach node $j$ through directed edges.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similardsugraphsgreedymatricestrees
CF 2208E - Counting Cute Arrays

We are given an array of length $n$ with integers ranging from $-1$ to $n$. The $-1$ values are placeholders that can take any non-negative integer.

codeforcescompetitive-programmingcombinatoricsdp
CF 2208D2 - Tree Orientation (Hard Version)

We are given a directed reachability matrix of a tree after all its edges have been assigned directions, and we need to reconstruct a tree and its edge directions that produce exactly the same reachability information.

codeforcescompetitive-programmingdfs-and-similardsugraphsgreedysortingstrees
CF 2208B - Cyclists

We are given a deck of n cards, each with an energy cost. Bob wants to play a special "win-condition" card as many times as possible without exceeding a total energy budget m. On each turn, Bob can select a card from only the first k positions in the current deck.

codeforcescompetitive-programmingbrute-forcegamesgreedyimplementationmathsortings
CF 2208C - Stamina and Tasks

We are given a sequence of tasks, each with a point value and a difficulty percentage. You start with a stamina of 1. For each task, you can either skip it or complete it.

codeforcescompetitive-programmingdpgreedymath
CF 2208A - Bingo Candies

We are given a square grid of size $n times n$ representing a board where each cell contains a candy of a certain color. The color of a candy is denoted by an integer, and different integers represent different colors.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 2209F - Dynamic Values And Maximum Sum

We are given a tree of n vertices, where each vertex has an integer value. We can perform k operations, and in each operation, we choose a vertex to root the tree at. Once a vertex is chosen as the root, its value is added directly to the total and then set to zero.

codeforcescompetitive-programmingdata-structuresgreedyimplementationtrees
CF 2209E - A Trivial String Problem

We are given a string and a set of queries. For each query, we take a substring defined by its endpoints, and for every prefix of this substring, we compute the maximum number of pieces it can be split into such that each piece is itself a prefix of the substring.

codeforcescompetitive-programmingbrute-forcedphashingstring-suffix-structuresstrings
CF 2209D - Ghostfires

The problem asks us to construct a sequence of ghostfires in three colors: red, green, and blue. OtterZ has a limited number of each color, denoted by $r$, $g$, and $b$. The goal is to place as many ghostfires as possible in a row while avoiding two constraints.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 2209A - Flip Flops

We are given a sequence of monsters, each with a strength value. We also start with an initial combat power. At any point, we can either defeat a monster if our current power is at least its strength, or we can spend a limited number of special items to increase a monster’s…

codeforcescompetitive-programminggreedy
CF 2209C - Find the Zero

We are asked to find a position of a zero in a hidden array of length $2n$, where each integer from $1$ to $n$ occurs exactly once and all remaining positions are zeros.

codeforcescompetitive-programmingconstructive-algorithmsinteractive
CF 2209B - Array

We are given an array of integers, and for each element, we need to determine how many elements to its right can be “dominated” by it, in a specific sense.

codeforcescompetitive-programminggreedy
CF 2210C1 - A Simple GCD Problem (Easy Version)

We are given an array of integers where every element can potentially be changed once. However, each position has a strict constraint: any replacement value must lie in the range from 1 up to the original value at that position, and it must differ from the original value.

codeforcescompetitive-programminggreedynumber-theory
CF 2210F - A Simple Problem

We are given a permutation of integers from 1 to n and a series of queries, each asking about a contiguous subarray of this permutation.

codeforcescompetitive-programmingbinary-searchdata-structuresgreedymathtrees
CF 2210E - Binary Strings are Simple?

We are dealing with an interactive reconstruction problem where the hidden object is a binary string of length $n$. We do not observe the string directly.

codeforcescompetitive-programmingconstructive-algorithmsimplementationinteractivenumber-theory
CF 2210C2 - A Simple GCD Problem (Hard Version)

We are given two arrays of equal length. Think of the first array as the current values written on a line of positions, and the second array as upper bounds that control how far each position is allowed to be changed.

codeforcescompetitive-programmingdpgreedynumber-theory
CF 2210D - A Simple RBS Problem

We are given two balanced bracket strings of equal length. Both strings are guaranteed to be regular bracket sequences, meaning every prefix has at least as many opening brackets as closing ones and the total counts match.

codeforcescompetitive-programmingconstructive-algorithmsmathstringstrees