brain

tamnd's digital brain — notes, problems, research

43815 notes

CF 2055A - Two Frogs

We are asked to analyze a two-player game played on a row of lilypads numbered from 1 to $n$. Alice starts on lilypad $a$ and Bob on lilypad $b$, and they take turns jumping either one step left or right. A frog loses if it cannot jump to a valid, unoccupied lilypad.

codeforcescompetitive-programmingconstructive-algorithmsgamesgreedymath
CF 2056F1 - Xor of Median (Easy Version)

We are asked to work with sequences of integers of length $n$, where each element lies between 0 and $m-1$. A sequence is considered good if the counts of numbers follow a strict non-decreasing property: whenever two numbers $i < j$ both appear in the sequence, the number of…

codeforcescompetitive-programmingbitmasksbrute-forcecombinatoricsdpmath
CF 2056F2 - Xor of Median (Hard Version)

We are asked to consider sequences of length $n$, where each element is an integer between $0$ and $m-1$. A sequence is deemed "good" if the counts of the elements are non-decreasing with respect to their values: for any pair of numbers $i < j$ that both appear in the sequence…

codeforcescompetitive-programmingbitmasksbrute-forcecombinatoricsdpmath
Kvant Math Problem 675

The condition states that all subset sums of the chosen set are distinct.

kvantmathematicsolympiad
CF 2056E - Nested Segments

We are given a set of integer segments over the range [1, n]. Each segment is a closed interval [l, r]. The initial set of segments, S, is "good", meaning that for any two distinct segments in the set, either they do not overlap at all, or one is fully contained in the other.

codeforcescompetitive-programmingcombinatoricsdfs-and-similardpdsumath
CF 2056B - Find the Permutation

We are given an undirected graph whose structure is secretly generated from a hidden permutation of the vertices.

codeforcescompetitive-programmingbrute-forcedfs-and-similargraphsimplementationsortings
CF 2056D - Unique Median

We are asked to count subarrays of a given array where the median is uniquely defined. In practice, this means a subarray is good if, after sorting, the middle element (or the two middle elements, if the length is even) are equal.

codeforcescompetitive-programmingbinary-searchbrute-forcecombinatoricsdata-structuresdivide-and-conquerdp
CF 2056C - Palindromic Subsequences

We are asked to construct an integer sequence of length $n$ where each element lies between $1$ and $n$, and the sequence has the property that the number of longest palindromic subsequences exceeds $n$.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsmath
CF 2056A - Shape Perimeter

We are given a square stamp of size $m times m$ placed on an infinite grid. We repeatedly move this stamp up and right, and each time we place a full copy of the square on the paper. Each placement paints all unit cells inside that square.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 2057H - Coffee Break

We are given a sequence of coffee machines aligned along a corridor. Each machine initially has a certain number of students around it, and we can manipulate student positions using a simple operation: turning off the lights in a room.

codeforcescompetitive-programmingdata-structuresgreedymath
CF 2057E2 - Another Exercise on Graphs (hard version)

We are given an undirected weighted graph and a large number of queries. Each query picks two vertices and an integer k, and asks us to consider all possible paths between those vertices.

codeforcescompetitive-programmingbinary-searchdfs-and-similardpdsugraphsshortest-pathssortings
CF 2057G - Secret Message

The problem gives a rectangular grid where some cells are already blocked and cannot be used. The free cells, marked with "", form a figure on the grid.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similarmath
CF 2057F - Formation

We are asked to maximize the height of pupils in a line under two rules. First, the line is initially comfortable: for every pupil, the height of the next pupil is at most double the height of the current pupil.

codeforcescompetitive-programmingbinary-searchdata-structuresdpsortingstwo-pointers
CF 2057E1 - Another Exercise on Graphs (Easy Version)

We are given a connected undirected graph with up to 400 vertices and up to 400 edges. Every edge has a positive weight. For each query, we are given two vertices a and b, and a number k.

codeforcescompetitive-programmingbinary-searchbrute-forcedpdsugraphsshortest-pathssortings
CF 2057D - Gifts Order

We are given an array of integers representing sweater sizes. From any contiguous segment of this array, we define a score that depends on how spread out the values are and how long the segment is.

codeforcescompetitive-programmingdata-structuresgreedyimplementationmathmatrices
Kvant Math Problem 549

Let $N$ be a natural number and let its divisors be $d \mid N$.

kvantmathematicsolympiad
CF 2057A - MEX Table

We are asked to fill a table with n rows and m columns using each integer from 0 to nm - 1 exactly once. After filling, we compute the MEX (minimum excluded non-negative integer) for each row and each column and sum all these values. The task is to maximize this sum.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 2057C - Trip to the Olympiad

We are asked to pick three distinct students from a consecutive range of independence levels, such that a team metric is maximized. The team metric is the sum of all pairwise XORs of the three chosen levels.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsgreedymath
CF 2057B - Gorilla and the Exam

We are asked to help a gorilla efficiently clear an array using a particular deletion operation. The operation works on any contiguous subarray: you choose the minimum value in that subarray, then remove every occurrence of that minimum from the chosen segment.

codeforcescompetitive-programminggreedysortings
CF 2059E2 - Stop Gaming (Hard Version)

We are given multiple arrays of equal length and we are asked to transform them into a target configuration using a very specific operation.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdata-structureshashingstrings
CF 2059D - Graph and Graph

We are given two connected, undirected graphs that share the same set of vertices. Each graph has a token placed on one vertex initially: in the first graph at vertex s1 and in the second at vertex s2. We can repeatedly move each token along one edge in its respective graph.

codeforcescompetitive-programmingdata-structuresgraphsgreedyshortest-paths
CF 2059C - Customer Service

The problem presents a scenario where there are n queues, initially empty, and a sequence of n discrete moments. At each moment, every queue receives a certain number of new customers.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgraph-matchingsgreedymathsortings
CF 2059E1 - Stop Gaming (Easy Version)

We are given a sequence of arrays, each of length $m$, and we need to transform them into another target sequence of arrays using a special operation.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedyhashingstrings
CF 2059B - Cost of the Array

We are given an array and asked to cut it into exactly k consecutive non-empty segments. Since every element must belong to exactly one segment, this is purely a partition of the array into contiguous blocks.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedymath
CF 2059A - Milya and Two Arrays

We are given two arrays, a and b, of length n, where each array is "good" - meaning every value in the array occurs at least twice. Milya can rearrange a in any order, then she will compute a new array c where each element is the sum of the corresponding elements from a and b.

codeforcescompetitive-programmingconstructive-algorithmsgreedysortings
Kvant Math Problem 412

Model the city as a finite directed graph $G=(V,E)$ in which vertices are squares and directed edges are one-way streets.

kvantmathematicsolympiad
CF 2060C - Game of Mathletes

We are given an array of integers written on a board. The game repeatedly removes two numbers per round, but the order matters: Alice removes one number first with the intent of making Bob fail to form a good pair later, while Bob responds by removing another number to try to…

codeforcescompetitive-programminggamesgreedysortingstwo-pointers
CF 2061I - Kevin and Nivek

We are asked to determine the minimum time Kevin must invest to win at least a given number of matches against Nivek, for all possible counts from 0 to $n$.

codeforcescompetitive-programmingdivide-and-conquerdp
CF 2061H2 - Kevin and Stones (Hard Version)

We are given an undirected graph where each vertex may or may not contain a stone. Initially, some vertices are marked with stones, and we are also given a target configuration with the same number of stones.

codeforcescompetitive-programmingflowsgraphs
CF 2061H1 - Kevin and Stones (Easy Version)

Kevin has a graph where each vertex may initially contain a stone or be empty. He also has a target configuration indicating where the stones need to end up.

codeforcescompetitive-programmingflowsgraph-matchingsgraphs
CF 2061F2 - Kevin and Binary String (Hard Version)

We are given a binary string s consisting of 0s and 1s, and a target string t of the same length that can contain 0, 1, or the wildcard character ?. The operation allowed is to pick two adjacent blocks of identical characters in s and swap them.

codeforcescompetitive-programmingdata-structuresdp
CF 2061G - Kevin and Teams

We are given a set of $n$ people where every pair is either connected by a hidden binary relation, friendship or non-friendship. The relation is not known in advance, and in the interactive version it may even react to queries.

codeforcescompetitive-programmingconstructive-algorithmsgraphsinteractive
CF 2061F1 - Kevin and Binary String (Easy Version)

We are given two binary strings, s and t, of the same length. The string s can be modified using a single type of operation: swapping two adjacent blocks of identical characters.

codeforcescompetitive-programminggreedyimplementation
CF 2061A - Kevin and Arithmetic

We are given several independent test cases. In each test case, we start with a running sum equal to zero and we are allowed to reorder the given list of numbers freely. After choosing an order, we process the numbers one by one.

codeforcescompetitive-programmingmath
Kvant Math Problem 2881

Consider first the simplest nontrivial convex polygon, a triangle $A_1A_2A_3$, with a point $O$ inside.

kvantmathematicsolympiad
CF 2061E - Kevin and And

We are given a list of integers a of length n and a list of magic integers b of length m. Kevin can choose up to k operations where each operation selects an element ai and a magic bj and replaces ai with ai & bj, the bitwise AND of the two numbers.

codeforcescompetitive-programmingbitmasksbrute-forcedpgreedymathsortings
CF 2061D - Kevin and Numbers

We are given two sequences of integers: the initial sequence a of length n and the target sequence b of length m. Kevin can repeatedly take any two numbers from a whose difference is at most one, remove them, and insert their sum back into the sequence.

codeforcescompetitive-programmingbitmasksdata-structures
CF 2061C - Kevin and Puzzle

We have a line of classmates, each of whom claims a certain number of liars standing to their left. Each person is either honest, in which case their claim is exactly true, or a liar, in which case their claim may be arbitrary. Additionally, liars cannot stand next to each other.

codeforcescompetitive-programming2-satcombinatoricsdp
CF 2061B - Kevin and Geometry

We are given a multiset of stick lengths, and we must choose exactly four sticks that can form an isosceles trapezoid with non-zero area.

codeforcescompetitive-programmingbinary-searchgeometry
Kvant Math Problem 2874

Let $M$ be the midpoint of $AC$.

kvantmathematicsolympiad
CF 2062F - Traveling Salescat

We are given a set of cities, each described by two integers $ai$ and $bi$. Roads exist between every pair of cities, and the cost of traveling from city $i$ to city $j$ is defined as $max(ai + bj, bi + aj)$.

codeforcescompetitive-programmingconstructive-algorithmsdpgeometrygraphsgreedymathsortings
CF 2062H - Galaxy Generator

We are given a two-dimensional grid of size $n times n$ representing stars. A star is present at cell $(x, y)$ if the corresponding grid entry is 1.

codeforcescompetitive-programmingbitmaskscombinatoricsdp
CF 2062G - Permutation Factory

We are given two permutations of length $n$, $p$ and $q$, and our goal is to transform $p$ into $q$ using a sequence of swap operations.

codeforcescompetitive-programmingflowsgeometrygraph-matchingsgraphs
Kvant Math Problem 2865

The operation in every part is a conditional transposition: two entries are swapped exactly when the larger stands to the left.

kvantmathematicsolympiad
CF 2062E2 - The Game (Hard Version)

We are given a tree with n nodes rooted at node 1, and each node has an associated integer weight. Cirno and Daiyousei play a sequential game on this tree.

codeforcescompetitive-programmingdata-structuresdfs-and-similargamesgraphsimplementationtrees
CF 2062D - Balanced Tree

We are given a rooted tree where each node has a range of allowable values [li, ri]. Initially, each node can be assigned any value within its range. The goal is to make the tree balanced, meaning all nodes have the same final value.

codeforcescompetitive-programmingdfs-and-similardpgraphsgreedytrees
CF 2062E1 - The Game (Easy Version)

We are given a rooted tree where each node has a weight. Two players play a turn-based game. On each move, a player chooses a node whose weight is strictly larger than the weight chosen in the previous move and deletes its entire subtree.

codeforcescompetitive-programmingdata-structuresdfs-and-similargamesgraphsgreedytrees
Kvant Math Problem 2857

Let the hats be $x_1,x_2,x_3,x_4$, placed on sages $1,2,3,4$ respectively, with all values distinct in ${1,\dots,100}$.

kvantmathematicsolympiad
CF 2062B - Clockwork

We are asked to determine if we can indefinitely avoid letting any clock hit zero in a sequence of clocks. Each clock has an initial time ai. Every second, all clocks decrease by one. We can move to an adjacent clock and immediately reset its time back to ai.

codeforcescompetitive-programminggreedymath
CF 2062C - Cirno and Operations

We are given an array and allowed to repeatedly transform it using two operations: reversing it, or replacing it by its difference array, which shrinks the array by one element where each new value is the difference between consecutive elements.

codeforcescompetitive-programmingbrute-forcemath
CF 2062A - String

We are given a binary string consisting of characters 0 and 1. The goal is to convert every character in the string to 0.

codeforcescompetitive-programmingconstructive-algorithmsgreedymathstrings
Kvant Math Problem 1533

Let $\ell$ be a line through $C$.

kvantmathematicsolympiad
CF 2063F2 - Counting Is Not Fun (Hard Version)

We are given a hidden balanced bracket sequence of length $2n$. The structure of the sequence is not arbitrary: it can be fully described by a set of $n$ disjoint “matching events”, where each event connects an opening bracket at position $l$ with a closing bracket at…

codeforcescompetitive-programmingcombinatoricsdata-structuresdfs-and-similardsugraphsimplementationtrees
Kvant Math Problem 2868

We are asked whether Vasya can determine the total sum of 60 real numbers written on cards if he is allowed to ask about sums of 17-card subsets.

kvantmathematicsolympiad
CF 2063E - Triangle Tree

We are given a rooted tree with root at vertex 1. For every unordered pair of vertices (u, v), we only care about pairs where neither vertex is an ancestor of the other.

codeforcescompetitive-programmingdata-structuresdfs-and-similardpgreedytrees
CF 2063F1 - Counting Is Not Fun (Easy Version)

The problem asks us to count balanced bracket sequences under incremental constraints. We are given a balanced sequence of 2n brackets, but we do not know its content.

codeforcescompetitive-programmingcombinatoricsdata-structuresdfs-and-similardpdsugraphshashingimplementationmathtrees
CF 2063D - Game With Triangles

We are given two horizontal layers of points. One layer lies on the line $y=0$, the other lies on $y=2$. Each layer contains distinct x-coordinates.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresgeometrygreedyimplementationmathternary-searchtwo-pointers
CF 2063C - Remove Exactly Two

The problem asks us to consider a tree of n vertices and determine the maximum number of connected components that can result after removing exactly two vertices.

codeforcescompetitive-programmingbrute-forcedata-structuresdfs-and-similardpgraphsgreedysortingstrees
CF 2063A - Minimal Coprime

We are given an integer segment $[l,r]$. A segment $[a,b]$ is called coprime when the two endpoints $a$ and $b$ have greatest common divisor equal to $1$. Among all coprime segments, we only care about those that are minimal.

codeforcescompetitive-programmingmathnumber-theory
CF 2063B - Subsequence Update

We are given an array and a target segment $[l, r]$. We compute the sum of elements inside this segment, but we are allowed to perform exactly one global operation before measuring it. The operation is not a standard reversal of a subarray.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresgreedysortings
CF 2064F - We Be Summing

We are given an array of integers a of length n and a target value k. Our task is to count all contiguous subarrays of a that are epic.

codeforcescompetitive-programmingbinary-searchdata-structuresdptwo-pointers
CF 2064E - Mycraft Sand Sort

After gravity sort, the shape of the sand is completely determined by the permutation. Since $p$ is a permutation of $1 ldots n$, the final shape is always the same staircase: the first column contains $n$ blocks, the second contains $n-1$, and so on.

codeforcescompetitive-programmingcombinatoricsdata-structuresdsugreedymathsortings
CF 2064B - Variety is Discouraged

We are given a word that is already in its singular form in a very constrained toy language. Every word is constructed from a root string, and the singular form is always created by appending the suffix “us” to that root.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsgreedytwo-pointers
CF 2064D - Eating

We are given a line of slimes, each with a weight, and a special operation: a slime can eat the slime immediately to its left if its weight is at least as large, and after eating, its weight becomes the bitwise XOR of its current weight and the eaten slime's weight.

codeforcescompetitive-programmingbinary-searchbitmasksbrute-forcedata-structuresdpgreedytreestwo-pointers
CF 2064A - Brogramming Contest

We start with a binary string s and an empty string t. A move allows us to take any suffix of one string and append it to the other string. Since only suffixes may be moved, the relative order of characters never changes. Characters can only cross the boundary between s and t.

codeforcescompetitive-programminggreedystrings
CF 2064C - Remove the Ends

We are given an array of non-zero integers. At each step, we can pick any element, gain coins equal to its absolute value, and then either remove everything to its right if it is negative or everything to its left if it is positive.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdpgreedy
CF 2065H - Bro Thinks He's Him

The problem asks us to work with a binary string and queries that flip individual bits. For a string $t$, define $f(t)$ as the minimum number of contiguous blocks of identical characters that partition the string.

codeforcescompetitive-programmingcombinatoricsdata-structuresdivide-and-conquerdpmathmatrices
CF 2065G - Skibidus and Capping

We are asked to count pairs of numbers in an array where the least common multiple of the pair is a semi-prime. A semi-prime is any number that can be expressed as the product of exactly two primes, which could be the same.

codeforcescompetitive-programmingcombinatoricsmathnumber-theory
Kvant Math Problem 1558

Consider the game on small chessboards to observe patterns.

kvantmathematicsolympiad
CF 2065A - Skibidus and Amog'u

We are given a word that is already in its singular form in a very constrained toy language. Every word is constructed from a root string, and the singular form is always created by appending the suffix “us” to that root.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedyimplementationstrings
CF 2065F - Skibidus and Slay

The problem asks us to analyze a tree where each vertex has a number assigned to it, and for every number from 1 to n, we must decide if there exists a simple path in the tree where that number is the majority.

codeforcescompetitive-programmingdata-structuresdfs-and-similargraphsgreedytrees
CF 2065E - Skibidus and Rizz

The task asks us to construct a binary string of a specified length containing a fixed number of 0s and 1s such that the maximum difference between the counts of 0s and 1s in any substring is exactly k.

codeforcescompetitive-programmingconstructive-algorithmsgreedystrings
CF 2065D - Skibidus and Sigma

We are given multiple arrays of equal length, and we want to merge them in some order to maximize a special score. The score of a single array is computed by summing all its prefix sums. For example, if an array is [a, b, c], its score is a + (a+b) + (a+b+c) = 3a + 2b + c.

codeforcescompetitive-programminggreedysortings
CF 2065C2 - Skibidus and Fanum Tax (hard version)

We are given an array a and another array b. For every position in a, we have a binary-like choice: we can either leave a[i] unchanged or replace it with a transformed value obtained by picking some element b[j] and computing b[j] - a[i].

codeforcescompetitive-programmingbinary-searchgreedy
CF 2065B - Skibidus and Ohio

We are given a string composed of lowercase letters. Skibidus can repeatedly perform an operation on any pair of consecutive identical letters: he replaces the first letter with any letter and deletes the second.

codeforcescompetitive-programmingstrings
CF 2065C1 - Skibidus and Fanum Tax (easy version)

We are given an array where each position initially contains a fixed value. For every position, we are allowed one optional transformation: we can replace the value at that position with the result of subtracting it from a single fixed number.

codeforcescompetitive-programmingbinary-searchdpgreedy
Kvant Math Problem 1484

The problem asks whether space can be tessellated by congruent tetrahedra of three types: general, equifacial, and non-equifacial.

kvantmathematicsolympiad
CF 2067A - Adjacent Digit Sums

We are asked to determine whether there exists an integer n such that the sum of its digits equals a given number x, and the sum of the digits of n + 1 equals another given number y.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsmath
CF 2067C - Devyatkino

The problem gives us a positive integer n, and allows us to perform an operation where we add any number that consists entirely of the digit 9 repeated one or more times. Our goal is to make n contain at least one digit 7 using the minimum number of such operations.

codeforcescompetitive-programmingbrute-forcedfs-and-similargreedymath
CF 2068J - The Ultimate Wine Tasting Event

We are given a row of $2n$ wine bottles, exactly half white and half red. Gabriella wants to divide these bottles into two groups of $n$ each and then swap the bottles pairwise between the groups.

codeforcescompetitive-programmingcombinatoricsgreedy
CF 2068K - Amusement Park Rides

We are asked to schedule three friends to ride every attraction in an amusement park exactly once, where each ride has a periodic schedule. Each attraction operates at multiples of its own interval ai.

codeforcescompetitive-programmingflowsgraphs
CF 2068G - A Very Long Hike

We are asked to model movement across an infinite, periodic two-dimensional terrain. The park is defined by an $n times n$ matrix of altitudes that repeats infinitely in both directions.

codeforcescompetitive-programmingshortest-paths
CF 2068H - Statues

We are asked to place n statues on a 2D integer grid, starting at (0, 0) and ending at (a, b), such that the Manhattan distance between consecutive statues exactly matches a given sequence d1, ..., d{n-1}.

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 2068I - Pinball

I can't reliably write a complete editorial and correct reference solution for Codeforces 2068I from the problem statement alone. This is a 3500-rated problem whose solution depends on several nontrivial graph and shortest-path transformations.

codeforcescompetitive-programminggraphsshortest-paths
CF 2068F - Mascot Naming

I can't reliably write a complete accepted editorial for Codeforces 2068F from the statement alone. This problem's accepted solution is quite non-trivial.

codeforcescompetitive-programmingbrute-forcegreedyimplementationstrings
CF 2068D - Morse Code

We are given a set of symbols, each used with a known probability. We must assign each symbol a binary code made of two characters, dot and dash, under the restriction that no code can be a prefix of another.

codeforcescompetitive-programmingdpsortingstrees
CF 2068E - Porto Vs. Benfica

We are given a large undirected, unweighted graph representing a road network. One vertex is the starting point (Lisbon, vertex 1) and another is the destination (Porto, vertex n).

codeforcescompetitive-programmingdata-structuresdfs-and-similardsugraphsshortest-paths
Kvant Math Problem 1356

We are given a triangle with sides $a$, $b$, $c$ and the relation

kvantmathematicsolympiad
CF 2068C - Ads

Working

codeforcescompetitive-programmingbinary-searchgreedytwo-pointers
CF 2068B - Urban Planning

The task is to design a city represented as a rectangular grid of cells, each being either a park or a built-up area.

codeforcescompetitive-programmingconstructive-algorithms
CF 2068A - Condorcet Elections

We are given a directed relationship between candidates, where an input pair “a defeats b” is not a vote but a constraint on the final outcome we must simulate.

codeforcescompetitive-programmingconstructive-algorithmsgraphsgreedyprobabilities
CF 2069E - A, B, AB and BA

We are given a string consisting only of A and B. We must partition the entire string into pieces of length one or two. Single-character pieces are allowed to be "A" or "B". Two-character pieces are allowed only to be "AB" or "BA". Pieces "AA" and "BB" are forbidden.

codeforcescompetitive-programmingconstructive-algorithmsgreedysortingsstrings
CF 2069F - Graph Inclusion

We are given two undirected graphs, $A$ and $B$, on the same set of $n$ vertices. Initially, both graphs have no edges. Queries arrive one by one; each query either toggles an edge in $A$ or $B$.

codeforcescompetitive-programmingdata-structuresdfs-and-similardivide-and-conquerdsugraphs
CF 2069D - Palindrome Shuffle

We are given a string of even length, consisting only of lowercase letters. The allowed operation is to select any contiguous substring of the string and shuffle its characters arbitrarily.

codeforcescompetitive-programmingbinary-searchgreedyhashingstringstwo-pointers
binary searchdata structurestrees
CF 2069C - Beautiful Sequence

We are asked to count the number of "beautiful" subsequences in an array where every element is either 1, 2, or 3.

codeforcescompetitive-programmingcombinatoricsdpgreedytwo-pointers
CF 2069B - Set of Strangers

We are given a rectangular grid of size $n times m$ where each cell has a color represented by an integer. We can perform painting operations where in a single step we choose a set of cells that are strangers-that is, no two of them share a side-and all have the same color…

codeforcescompetitive-programminggreedymatrices
CF 2069A - Was there an Array?

We are given an array of 0s and 1s representing a “local equality” pattern for some unknown array of integers.

codeforcescompetitive-programminggraph-matchingsgreedy
CF 2070F - Friends and Pizza

We are asked to compute, for every possible number of slices k that Monocarp can eat, the number of ways to select exactly two friends such that the friends do not quarrel over any pizza and Monocarp ends up eating exactly k slices.

codeforcescompetitive-programmingbitmasksdivide-and-conquerdpfft
CF 2070E - Game with Binary String

We are given a binary string and we look at every contiguous substring. For each substring, a two-player game is played on the characters of that substring, where each move removes exactly two adjacent characters.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresdivide-and-conquergamesgreedymath