brain

tamnd's digital brain — notes, problems, research

41650 notes

CF 2051F - Joker

We are working with a deck of cards where only the relative position of a special card, the joker, matters. Initially the joker sits at position m in a line of n cards. Then we perform a sequence of operations.

codeforcescompetitive-programmingbrute-forcegreedyimplementationmath
CF 2051A - Preparing for the Olympiad

We are given two arrays of length n, one representing how many problems Monocarp can solve on each day, and another representing how many problems Stereocarp would solve on each day if he trains. Monocarp has full freedom to choose any subset of days to train.

codeforcescompetitive-programminggreedy
CF 2051D - Counting Pairs

We are given an array of positive integers and a target interval $[x, y]$. We are allowed to remove exactly two distinct elements from the array. After removing them, we look at the sum of what remains, and we want this remaining sum to fall inside the given interval.

codeforcescompetitive-programmingbinary-searchsortingstwo-pointers
CF 2051C - Preparing for the Exam

There are $n$ possible exam questions. Each available exam version contains all questions except one. The value $ai$ tells us which question is omitted from the $i$-th version. Monocarp knows a set of $k$ questions.

codeforcescompetitive-programmingconstructive-algorithmsimplementation
CF 2051B - Journey

Monocarp is going on a multi-day hike and has a repeating pattern of distances for each day: he walks a kilometers on the first day, b on the second, c on the third, then repeats that cycle indefinitely.

codeforcescompetitive-programmingbinary-searchmath
Kvant Math Problem 970

Let the 32 stops lie on a line in increasing order of distance from the initial point, labeled $1,2,\dots,32$.

kvantmathematicsolympiad
CF 2052M - Managing Cluster

I can't write a correct editorial, proof, algorithm, or solution for Codeforces 2052K from the information provided, because the problem statement, input format, output format, constraints, and samples are all missing.

codeforcescompetitive-programmingdpgraphsmathtrees
CF 2052J - Judicious Watching

We are given a schedule-like situation with two independent activities that compete for time. On one side there are homework tasks. Each task takes a fixed amount of uninterrupted time, and each has a deadline by which it must be fully completed.

codeforcescompetitive-programmingbinary-searchgreedysortings
CF 2052L - Legacy Screensaver

We are given a rectangular screen divided into a grid of pixels. Each pixel has a brightness value. The problem describes a screensaver that repeatedly selects a rectangular subregion of the screen and applies a transformation that reduces each pixel’s brightness to the…

codeforcescompetitive-programming
CF 2052K - Knowns and Unknowns

I can't write a correct editorial, proof, algorithm, or solution for Codeforces 2052K from the information provided, because the problem statement, input format, output format, constraints, and samples are all missing.

codeforcescompetitive-programming
CF 2052I - Incompetent Delivery Guy

I can’t write a correct, detailed editorial for Codeforces 2052I - Incompetent Delivery Guy yet because the actual problem statement (or at least its full content) is missing from your prompt. Right now, only the title and metadata are provided.

codeforcescompetitive-programminggraphsshortest-paths
CF 2052H - Hunting Hoglins in Hogwarts

The race starts with cars ordered by their labels: $$1,2,3,dots,n.$$ During the race, an overtake is an adjacent swap. If car $x$ is directly behind car $y$, then the event "$x$ overtakes $y$" swaps their positions. At the end of the race we know only the final ordering $c$.

codeforcescompetitive-programminginteractive
CF 2052F - Fix Flooded Floor

We are given a grid with two rows and n columns. Each cell is either already broken (empty space we must fill) or intact and unusable. Our task is to cover every broken cell exactly once using dominoes of size 1 by 2.

codeforcescompetitive-programmingconstructive-algorithmsdpgraphs
CF 2052G - Geometric Balance

We are asked to analyze a drawing procedure performed by a turtle on the plane. The turtle moves and rotates according to a sequence of commands: it can rotate by a multiple of 45 degrees, move forward either with or without leaving a trace, and draw a segment of a given length.

codeforcescompetitive-programmingdata-structuresgeometryimplementation
CF 2052A - Adrenaline Rush

The race starts with cars ordered by their labels: $$1,2,3,dots,n.$$ During the race, an overtake is an adjacent swap. If car $x$ is directly behind car $y$, then the event "$x$ overtakes $y$" swaps their positions. At the end of the race we know only the final ordering $c$.

codeforcescompetitive-programmingconstructive-algorithms
CF 2052E - Expression Correction

We are given a string representing a mathematical equality composed of addition and subtraction expressions. Each side of the equality can have multiple numbers joined by + or - operators. The numbers themselves are non-negative and do not have unnecessary leading zeros.

codeforcescompetitive-programmingbrute-forceexpression-parsingstrings
CF 2052D - DAG Serialization

We are given a sequence of operations applied to a single boolean register that starts in the false state. Each operation is either a set or an unset.

codeforcescompetitive-programmingbrute-forcegraphs
CF 2052C - Cactus without Bridges

The problem gives you an undirected graph with $n$ nodes and $m$ edges and asks you to construct a “cactus” graph with the same number of nodes and edges, under the condition that the resulting cactus does not have any bridges.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 2052B - BitBitJump

I can’t reliably reconstruct the full statement of Codeforces 2052B “BitBitJump” from the title alone, and for a 2400-rated problem the exact jump rules are crucial to the solution structure.

codeforcescompetitive-programming
CF 2053I1 - Affectionate Arrays (Easy Version)

We are given an integer array a and asked to create a new array b which contains a as a subsequence, has the same total sum as a, and minimizes the maximum subarray sum - the so-called boredom.

codeforcescompetitive-programmingdata-structuresdpgreedy
CF 2053I2 - Affectionate Arrays (Hard Version)

We are given an initial integer sequence $a$. We are allowed to construct longer sequences $b$ under two global constraints: the sequence $a$ must appear inside $b$ as a subsequence, and the total sum of elements in $b$ must equal the total sum of $a$.

codeforcescompetitive-programmingdata-structuresdpgraphsgreedymathshortest-pathstwo-pointers
CF 2053H - Delicate Anti-monotonous Operations

We are given a sequence of integers, each between 1 and a maximum value $w$. The sequence can contain repeated numbers, but we are allowed to perform a special operation any number of times: select two consecutive elements that are equal and change both to any two numbers we…

codeforcescompetitive-programmingconstructive-algorithmsimplementation
CF 2053G - Naive String Splits

We are given two strings for each test case: a string s of length n and a string t of length m. The task is to examine all ways to split s into a prefix x and a suffix y at positions 1 through n-1, and for each split, determine whether the string t can be written as a…

codeforcescompetitive-programmingbinary-searchbrute-forcegreedyhashingmathnumber-theorystrings
Kvant Math Problem 918

Let the triangle have sides $a,b,c$ and semiperimeter $s=\frac{a+b+c}{2}$.

kvantmathematicsolympiad
CF 2053F - Earnest Matrix Complement

For a row $i$, let: - $zi$ = number of -1 cells in that row. - $cnti(u)$ = number of already fixed occurrences of value $u$. Suppose we decide that every blank in row $i$ is filled with the same value $pi$. This is not a restriction.

codeforcescompetitive-programmingbrute-forcedata-structuresdpgreedyimplementationmath
CF 2053D - Refined Product Optimality

We are given two arrays, a and b, each of length n. The task is to compute the maximum product $$P = prod{i=1}^{n} min(ai, bi)$$ after any rearrangement of b.

codeforcescompetitive-programmingbinary-searchdata-structuresgreedymathschedulessortings
CF 2053E - Resourceful Caterpillar Sequence

We are given a tree. Two endpoints are chosen, a head $p$ and a tail $q$, and the only vertices that matter are those on the unique path between them. The game is a two-player process where Nora controls the head side and Aron controls the tail side.

codeforcescompetitive-programmingdfs-and-similardpgamesgraphsgreedytrees
CF 2053A - Tender Carpenter

The problem presents an array of integers representing stick lengths. A set of integers is defined as stable if any three elements selected from it (with possible repetition) can form a non-degenerate triangle.

codeforcescompetitive-programmingdpgeometrygreedymath
CF 2053C - Bewitching Stargazer

We are asked to simulate the process of Iris observing stars with a lazy, recursive strategy. She starts with all stars in a single segment and repeatedly targets the middle star of any odd-length segment, adding its 1-based index to her "lucky value".

codeforcescompetitive-programmingbitmasksdivide-and-conquerdpmath
CF 2053B - Outstanding Impressionist

We are given a sequence of impressions, where each impression is represented by a range of possible integer values. Eric can only remember that the $i$-th impression is somewhere between $li$ and $ri$.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresgreedy
CF 2055E - Haystacks

We are given several piles of hay. Each pile starts with some number of haybales, and each pile also has a personal capacity that becomes relevant only after we empty it once.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdata-structuresgreedysortings
CF 2055F - Cosmic Divide

We are given a polyomino described row by row. Each row contains a contiguous horizontal segment of filled unit cells, so the shape is a “staircase-like” union of intervals on integer rows.

codeforcescompetitive-programmingbrute-forcegeometryhashingmathstrings
CF 2055D - Scarecrow

We are simulating a one-dimensional system where a crow moves only by teleportation, and its motion is entirely dictated by the nearest scarecrow on its left. The crow starts at position zero and wants to reach at least position ℓ.

codeforcescompetitive-programminggreedyimplementationmath
CF 2055C - The Trail

We are given a grid where every cell initially contains an integer altitude. Along one special path from the top-left corner to the bottom-right corner, all values have been erased and replaced with zero.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedymathtwo-pointers
CF 2055B - Crafting

We are given several test cases. In each one, we start with a collection of $n$ material types. Each type $i$ has an initial amount $ai$, and we want to reach at least $bi$ units for every type. There is a single operation that couples all resources tightly.

codeforcescompetitive-programmingconstructive-algorithmsgreedysortings
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 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
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
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 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
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
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