brain

tamnd's digital brain — notes, problems, research

43815 notes

CF 1826C - Dreaming of Freedom

We have a group of n programmers who are repeatedly voting to choose a single favorite among m algorithms. Each round, every programmer casts a vote for one of the remaining options.

codeforcescompetitive-programminggreedymathnumber-theory
CF 1826A - Trust Nobody

We are given a group of people where each person makes a claim about the minimum number of liars in the group. Each person either always tells the truth or always lies. Our task is to decide whether these claims are consistent and, if so, to determine a possible number of liars.

codeforcescompetitive-programmingbrute-forcegreedyimplementationsortings
CF 1827E - Bus Routes

The original logic did the following: 1. Read all intervals and sorted them by left endpoint. 2. Merged overlapping intervals into merged blocks. 3. Marked all positions covered by merged blocks as used. 4. Counted "free positions" (free = used.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsdfs-and-similargreedytrees
CF 1827F - Copium Permutation

We are given a permutation of length $n$. We are allowed to take the suffix starting at position $k+1$ and freely rearrange it, while keeping the prefix $a1 ldots ak$ fixed in place.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresgreedy
CF 1827D - Two Centroids

We are asked to process a dynamic tree that grows one node at a time. Initially, the tree has a single node labeled 1. Each query adds a new node and connects it to an existing node, forming a tree incrementally.

codeforcescompetitive-programmingdata-structuresdfs-and-similargreedytrees
CF 1827C - Palindrome Partition

We are given a string consisting of lowercase Latin letters, and we are asked to count its “beautiful” substrings. A substring is beautiful if it is an even palindrome or can be partitioned into smaller even palindromes.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresdphashingstrings
CF 1827B1 - Range Sorting (Easy Version)

We are asked to compute a “beauty” metric for all subarrays of a given array of distinct integers. The beauty of a subarray is the minimum total time needed to sort it using range-sort operations.

codeforcescompetitive-programmingbinary-searchdpdsugreedytreestwo-pointers
CF 1827B2 - Range Sorting (Hard Version)

We are given an array of distinct integers and asked to compute, for every contiguous subarray, the minimum total time required to sort it using range-sort operations.

codeforcescompetitive-programmingbinary-searchdata-structuresdpgreedy
CF 1827A - Counting Orders

We are given two arrays, a and b, each of length n. The elements in a are all distinct, while b may contain repeated numbers. The task is to count the number of ways we can reorder the elements of a so that after reordering, for every index i, the condition a[i] b[i] holds.

codeforcescompetitive-programmingcombinatoricsmathsortingstwo-pointers
CF 1828E - Palindrome Partition

The solution correctly generalizes the serial test from pairs to $k$-tuples by grouping the sequence into disjoint blocks of length $k$, ensuring independence under the null hypothesis.

codeforcescompetitive-programmingdata-structuresdphashingstrings
CF 1828F - Two Centroids

We are given a tree that grows incrementally: it starts with vertex 1, and each subsequent vertex is attached to some existing vertex in the tree. For each insertion, we are asked how many extra vertices we must add to make the tree have exactly two centroids.

codeforcescompetitive-programmingdfs-and-similar
CF 1828D1 - Range Sorting (Easy Version)

We are asked to compute a cumulative measure of "beauty" over all subarrays of a given array of distinct integers.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresdpdsugreedy
CF 1828D2 - Range Sorting (Hard Version)

We are asked to compute a "beauty" measure for every subarray of a given array of distinct integers. The array can be large, up to 300,000 elements, and the total across all test cases is bounded by the same number.

codeforcescompetitive-programmingbinary-searchdata-structuresdpgreedy
CF 1828C - Counting Orders

The solution correctly generalizes the serial test from pairs to $k$-tuples by grouping the sequence into disjoint blocks of length $k$, ensuring independence under the null hypothesis.

codeforcescompetitive-programmingbinary-searchcombinatoricssortings
CF 1828A - Divisible Array

We are asked to construct an array for each test case, where the array length is fixed to a given integer $n$. Each position $i$ in the array must contain a value that is a multiple of $i$, and every value must stay within a small fixed range up to 1000.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1828B - Permutation Swap

We are given a permutation of integers from 1 to n in some arbitrary order. Our task is to sort the permutation into ascending order by repeatedly swapping pairs of elements that are exactly k positions apart, for some fixed k.

codeforcescompetitive-programmingmathnumber-theory
CF 1829G - Hits Different

The structure in this problem is a fixed pyramid of numbered cans, where each position in the pyramid contains a square number.

codeforcescompetitive-programmingdata-structuresdpimplementationmath
CF 1829H - Don't Blame Me

We are given an array where every element is a small integer, specifically a 6-bit value. From this array, we can choose any non-empty subsequence, meaning we pick any subset of indices while preserving order, although order does not actually matter for the bitwise operation.

codeforcescompetitive-programmingbitmaskscombinatoricsdpmath
CF 1829F - Forever Winter

We are given a graph generated by a simple "snowflake" process. There is a central vertex, then $x$ vertices connected directly to the center, and then $y$ vertices connected to each of the $x$ outer vertices.

codeforcescompetitive-programmingdfs-and-similargraphsmath
CF 1829E - The Lakes

We are given a two-dimensional grid representing terrain, where each cell contains a non-negative integer indicating the depth of water at that location.

codeforcescompetitive-programmingdfs-and-similardsugraphsimplementation
CF 1829D - Gold Rush

We start with a single pile containing n gold nuggets. The only allowed move takes one existing pile and splits it into exactly two smaller piles, with a strict structure: one of the new piles must be exactly twice the size of the other.

codeforcescompetitive-programmingbrute-forcedfs-and-similardpimplementation
CF 1829B - Blank Space

The solution correctly generalizes the serial test from pairs to $k$-tuples by grouping the sequence into disjoint blocks of length $k$, ensuring independence under the null hypothesis.

codeforcescompetitive-programmingimplementation
CF 1829C - Mr. Perfectly Fine

Victor has two independent skills he wants to acquire, and each book he can read either teaches him skill 1, skill 2, both, or none. Every book also has a time cost.

codeforcescompetitive-programmingbitmasksgreedyimplementation
CF 1829A - Love Story

We are given a fixed reference string, “codeforces”, and for each test case we receive another string of the same length, exactly 10 lowercase letters. The task is to compare these two strings position by position and count how many positions contain different characters.

codeforcescompetitive-programmingimplementationstrings
Kvant Math Problem 2709

The problem can be formulated in graph-theoretic terms.

kvantmathematicsolympiad
CF 1831F - Mex Tree

We are asked to maximize the sum of MEX values over all paths in a tree where each node can be colored either 0 or 1. A path is defined as the unique simple path between any two nodes, including paths that start and end at the same node.

codeforcescompetitive-programmingbrute-forcedptrees
CF 1831E - Hyperregular Bracket Strings

We are asked to count bracket sequences of length $n$ that are globally regular, while also being locally regular on certain specified subintervals. The input gives us the length $n$ and a list of $k$ intervals $[li, ri]$.

codeforcescompetitive-programmingcombinatoricsdata-structureshashingmathnumber-theorysortingstwo-pointers
CF 1831D - The BOSS Can Count Pairs

We are given two arrays a and b of equal length n. The task is to count the number of index pairs (i, j) with i < j such that the product of the a elements at those indices equals the sum of the corresponding b elements: a[i] a[j] = b[i] + b[j].

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresmath
CF 1831A - Twin Permutations

We are given a permutation a of length n, which means it contains all integers from 1 to n exactly once in some order. Our task is to construct another permutation b of the same length such that the sequence formed by summing corresponding elements, ai + bi, is non-decreasing.

codeforcescompetitive-programmingconstructive-algorithms
CF 1831C - Copil Copac Draws Trees

We are given a tree with $n$ vertices, described as a list of $n-1$ edges. Copil Copac draws the tree step by step: he always starts with vertex 1, then repeatedly scans the list of edges in order, drawing any vertex connected to a previously drawn vertex.

codeforcescompetitive-programmingdfs-and-similardpgraphstrees
CF 1831B - Array merging

We are given two arrays, a and b, of the same length n. The task is to form a new array c of length 2n by successively taking the first element of either array until both are exhausted.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1832F - Zombies

Each entrance in this problem behaves like a stream of zombies arriving over a long time interval. For every minute in the range $[0, x)$, exactly one zombie attempts to pass through each entrance.

codeforcescompetitive-programmingbinary-searchdp
CF 1832E - Combinatorics Problem

We are asked to compute a transformed array from a pseudo-randomly generated sequence using binomial coefficients.

codeforcescompetitive-programmingbrute-forcecombinatoricsdp
CF 1832C - Contrast Value

We are given an array and a specific measure of how “change-heavy” it is: the sum of absolute differences between consecutive elements. This value captures how much the array oscillates as we walk through it left to right.

codeforcescompetitive-programminggreedyimplementation
CF 1832D2 - Red-Blue Operations (Hard Version)

We are given an array of integers, initially colored red. On each operation, you pick a single element. If it is red, you increase it by the operation number and switch it to blue. If it is blue, you decrease it by the operation number and switch it back to red.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsgreedyimplementationmath
CF 1832D1 - Red-Blue Operations (Easy Version)

We have an array of integers, each initially painted red, and a sequence of operations numbered from one onwards. On operation number $i$, if we pick a red element, it increases by $i$ and turns blue; if we pick a blue element, it decreases by $i$ and turns red.

codeforcescompetitive-programmingbinary-searchgreedyimplementationmath
CF 1832A - New Palindrome

We are asked to determine whether a palindrome string can be rearranged to form a different palindrome. A palindrome is a string that reads the same forwards and backwards, like "abba" or "racecar".

codeforcescompetitive-programmingstrings
CF 1832B - Maximum Sum

We are given an array of distinct integers and must perform exactly k deletion operations. In each operation we can either remove the largest element or remove the two smallest elements together.

codeforcescompetitive-programmingbrute-forcesortingstwo-pointers
CF 1833G - Ksyusha and Chinchilla

We are given a tree, and we are allowed to remove edges. After removing some edges, the remaining connected components must each consist of exactly three vertices, and each such component must itself still be a tree.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similardpdsugreedyimplementationtrees
CF 1833F - Ira and Flamenco

We are given an array of student skill levels, and we want to count how many ways we can choose exactly m students to form a group under two simultaneous constraints.

codeforcescompetitive-programmingcombinatoricsconstructive-algorithmsdata-structuresimplementationmathsortingstwo-pointers
CF 1833B - Restore the Weather

We are given two arrays of the same length. One array represents predicted temperatures for each day, and the other contains the actual temperatures, but the actual values are shuffled and their ordering is lost.

codeforcescompetitive-programminggreedysortings
CF 1833E - Round Dance

We are given a group of people at a festival, each of whom remembers exactly one neighbor in a round dance. Each dance is a closed cycle where every participant has exactly two neighbors, but we only know one neighbor per person.

codeforcescompetitive-programmingdfs-and-similardsugraphsshortest-paths
CF 1833D - Flipper

We are given a permutation of integers from 1 to $n$. Our goal is to perform a two-part operation exactly once to produce the lexicographically largest permutation possible.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedy
CF 1833C - Vlad Building Beautiful Array

We are given an array of positive integers, and the task is to construct a new array of the same length where all elements are positive and have the same parity, either all odd or all even.

codeforcescompetitive-programminggreedymath
CF 1833A - Musical Puzzle

We are given a target melody, which is just a string over the alphabet {a, b, c, d, e, f, g}. Vlad cannot directly build this string in arbitrary chunks. Instead, he can only record pieces of length exactly two characters, like "ab" or "gg".

codeforcescompetitive-programmingimplementationstrings
CF 1834D - Survey in Class

We have a classroom of n students and m topics. Each student has learned a continuous range of topics, from li to ri. When the teacher asks about a topic, each student either raises or lowers their hand depending on whether they know the topic.

codeforcescompetitive-programmingbrute-forcedata-structuresgreedyimplementationsortings
CF 1834F - Typewriter

The solution correctly identifies what the “improved KS test” is trying to do: it replaces the unweighted empirical process by a variance-stabilized version, dividing by the binomial standard deviation $sqrt{F(x)(1-F(x))}$.

codeforcescompetitive-programmingbrute-forcemath
CF 1834E - MEX of LCM

We are asked to find the smallest positive integer that cannot appear as the least common multiple of any contiguous subarray of a given array. The input consists of multiple test cases.

codeforcescompetitive-programmingbinary-searchdata-structuresimplementationmathnumber-theory
CF 1834A - Unit Array

Investigate the "improved" KS test suggested in the answer to exercise 6. Let $X1, X2, ldots, Xn$ be independent observations drawn from a continuous distribution function $F(x)$.

codeforcescompetitive-programminggreedymath
CF 1834C - Game with Reversing

We are given two strings of equal length. In a turn-based game, Alice can modify any single character in either string, while Bob can take an entire string and reverse it.

codeforcescompetitive-programminggamesgreedymathstrings
CF 1834B - Maximum Strength

Fedya has a collection of materials, each represented by a positive integer indicating its strength. He can combine two materials into a weapon, and the weapon's strength is the sum of the absolute differences between corresponding digits of the two numbers, aligned from the…

codeforcescompetitive-programminggreedymath
CF 1835F - Good Graph

Investigate the "improved" KS test suggested in the answer to exercise 6. Let $X1, X2, ldots, Xn$ be independent observations drawn from a continuous distribution function $F(x)$.

codeforcescompetitive-programmingbitmasksdfs-and-similargraph-matchingsgraphsimplementation
CF 1835E - Old Mobile

We are asked to compute the expected number of button presses needed to type a number on an old mobile device with an unfamiliar keyboard. The keyboard has $m$ digit buttons and a backspace. Jan, the user, cannot distinguish which button is which until he presses it.

codeforcescompetitive-programmingcombinatoricsdpprobabilities
CF 1835D - Doctor's Brown Hypothesis

We have a directed graph representing planets connected by wormholes. Each planet has exactly one battleship. The rebels want to pick either a single ship or a pair of ships that can move for exactly k hours along wormholes.

codeforcescompetitive-programmingdfs-and-similargraphsmathnumber-theory
CF 1835B - Lottery

The proposed solution directly addresses the exercise by analyzing the asymptotic behavior of the finite-$n$ Kolmogorov-Smirnov distribution.

codeforcescompetitive-programmingbinary-searchbrute-forcegreedymathtwo-pointers
CF 1835C - Twin Clusters

We are given a sequence of galaxies, each with a certain number of stars. The total number of galaxies in a test case is always a power of two, specifically $2^{k+1}$. Each galaxy has a star count between 0 and $4^k - 1$.

codeforcescompetitive-programmingbitmasksbrute-forceconstructive-algorithmsmathprobabilities
CF 1835A - k-th equality

We are asked to enumerate all equalities of the form a + b = c where a, b, and c are positive integers with exactly A, B, and C digits respectively.

codeforcescompetitive-programmingbrute-forceimplementationmath
CF 1836F - Doctor's Brown Hypothesis

We are working with a directed graph where nodes represent planets and edges represent wormholes between them. Each edge takes exactly one hour to traverse.

codeforcescompetitive-programmingdfs-and-similargraphsmathnumber-theory
CF 1836E - Twin Clusters

We are given a sequence of integers for each test case, and we are allowed to look at any contiguous segment of this sequence. For any segment, we define its value as the bitwise XOR of all elements inside it.

codeforcescompetitive-programmingconstructive-algorithmsmeet-in-the-middleprobabilities
CF 1836B - Astrophysicists

Input: This means: - t = 3 - Each test case consists of a single line containing two integers - So the test cases are: - (10, 2) - (10, 3) - (3, 4) The expected output: This indicates each test case produces two outputs per line or multiple values per case, not a single integer.

codeforcescompetitive-programminggreedymath
CF 1836D - Lottery

There are already n participants, each holding a number in the range [0, m]. Then a new participant, Bytek, joins last and chooses his own number. A random target integer t is drawn uniformly from [0, m]. After that, winners are chosen by distance to t: the k closest tickets win.

codeforcescompetitive-programmingbinary-searchimplementationtwo-pointers
CF 1836C - k-th equality

We are asked to enumerate all valid equations of the form a + b = c, but with strict digit-length constraints: a must have exactly A digits, b exactly B digits, and c exactly C digits. None of the numbers may start with zero, and all three values must be positive integers.

codeforcescompetitive-programmingbrute-forcegreedyimplementationmath
CF 1836A - Destroyer

Each robot reports a single integer that describes how many robots stand in front of it in its own line. The twist is that we are not told how many lines exist or which robot belongs to which line.

codeforcescompetitive-programmingimplementationsortings
CF 1837F - Editorial for Two

The error you are seeing, StopIteration, happens because the code is trying to consume more integers from the input iterator than exist.

codeforcescompetitive-programmingbinary-searchdata-structuresgreedyimplementation
CF 1837E - Playoff Fixing

We are asked to arrange a single-elimination tournament for $2^k$ teams where each team has a strict ranking: team 1 is the strongest, team $2^k$ is the weakest, and a stronger team always beats a weaker one.

codeforcescompetitive-programmingcombinatoricstrees
CF 1837D - Bracket Coloring

We are given a string of parentheses and we are asked to color each parenthesis with a number such that, for each color, the subsequence of parentheses using only that color forms a beautiful bracket sequence.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1837A - Grasshopper on a Line

Ah, now the bug is clear. Simply taking the maximum of the final list is not correct, because the largest number in the final list may be generated by the difference operation and might not be one of the original two numbers.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1837C - Best Binary String

We are given a string s that contains 0, 1, and ?. The question marks represent flexible positions: we can replace each ? independently with either 0 or 1. Our goal is to produce a fully binary string matching this pattern such that the cost of sorting it is minimized.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1837B - Comparison String

We are given a string that encodes local comparisons between neighboring elements of an array. Each character describes whether the next element must be larger or smaller than the current one.

codeforcescompetitive-programminggreedy
CF 1838F - Stuck Conveyor

The earlier solution implicitly assumed: We only need to satisfy density constraints in contiguous blocks of size $k$.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsinteractive
CF 1838D - Bracket Walk

We have a bracket string. A walk starts at position 1 and must eventually end at position n. At every moment we record the bracket written at the current position.

codeforcescompetitive-programmingdata-structuresgreedystrings
CF 1838E - Count Supersequences

We are asked to count how many arrays of length $m$ over the values $1$ through $k$ contain a given array $a$ of length $n$ as a subsequence. A subsequence allows elements of $a$ to appear in order, but they do not need to be contiguous.

codeforcescompetitive-programmingcombinatoricsdpmath
CF 1838A - Blackboard List

We are given a final list of integers that were produced by starting with two unknown numbers on a blackboard and repeatedly writing the absolute difference of any two numbers already present.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1838C - No Prime Differences

We are asked to construct a permutation of a grid, where every integer from 1 to $n cdot m$ is placed exactly once in an $n times m$ table.

codeforcescompetitive-programmingconstructive-algorithmsmathnumber-theory
CF 1838B - Minimize Permutation Subarrays

We are given a permutation p of length n, meaning an array containing each integer from 1 to n exactly once in some order.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1839A - The Good Array

The problem asks for the smallest number of ones needed in a binary array of length $n$ to satisfy a set of prefix and suffix constraints.

codeforcescompetitive-programminggreedyimplementationmath
CF 1839D - Ball Sorting

We are given a sequence of n balls, each painted a distinct color from 1 to n. The initial sequence may be completely scrambled. Our goal is to rearrange the balls so that the ball at position i has color i.

codeforcescompetitive-programmingdata-structuresdpsortings
CF 1839E - Decreasing Game

We are playing a two-person game on an array of positive integers. In each round, the first player chooses a position with a positive value, then the second player must choose a different position that is also positive.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similardpgreedyinteractive
CF 1839B - Lamps

We are given a collection of lamps, each with two properties: ai and bi. Initially, all lamps are off. You can turn on a lamp that is off to earn bi points.

codeforcescompetitive-programminggreedysortings
CF 1839C - Insert Zero and Invert Prefix

We are asked to construct a binary sequence step by step using a sequence of operations. We start with an empty sequence b and, in each of the n operations, we insert a zero somewhere in b and invert all elements before that position.

codeforcescompetitive-programmingconstructive-algorithms
CF 1840G1 - In Search of Truth (Easy Version)

We are given a circular arrangement of sectors numbered from 1 to some unknown integer $n$. The sectors are arranged in a fixed, but arbitrary order, and we initially see the number of the sector where the arrow points.

codeforcescompetitive-programmingconstructive-algorithmsinteractivemathmeet-in-the-middleprobabilities
CF 1840G2 - In Search of Truth (Hard Version)

We are placed in a circular arrangement of sectors numbered from 1 to $n$, but we do not know either the total number $n$ or the order of the numbers around the circle. Initially, the arrow points to a sector, and we are told its number.

codeforcescompetitive-programmingconstructive-algorithmsinteractivemathmeet-in-the-middleprobabilities
CF 1840E - Character Blocking

Thanks for providing the input/output. From the symptoms, the actual bug is clear: the previous solution was just summing ASCII values of characters in the string (ord(c)), which produces numbers like 529 or 670. The expected outputs (11088, 10010, etc.

codeforcescompetitive-programmingdata-structureshashingimplementation
CF 1840F - Railguns

We move on a grid of coordinates from (0, 0) to (n, m). Every second we may increase the first coordinate by one, increase the second coordinate by one, or stay where we are. The position after the action is the position checked against all railgun shots fired at that second.

codeforcescompetitive-programmingbrute-forcedfs-and-similardpgraphs
CF 1840D - Wooden Toy Festival

We have a small workshop with three wood carvers and a list of people who will request toys. Each toy request is represented by an integer pattern. Each carver can pre-learn one pattern perfectly.

codeforcescompetitive-programmingbinary-searchgreedysortings
CF 1840C - Ski Resort

The problem asks us to count how many ways Dima can choose consecutive vacation days at a ski resort given weather constraints.

codeforcescompetitive-programmingcombinatoricsmathtwo-pointers
CF 1840A - Cipher Shifer

The proposed solution does not attempt to address the exercise at all. Exercise 3.3.1.16 asks for an asymptotic analysis of the normalized incomplete gamma function for large $x$ and then its application to approximating $t$ in a cumulative chi-square relation.

codeforcescompetitive-programmingimplementationstringstwo-pointers
CF 1840B - Binary Cafe

We are asked to count the number of ways Toma can select desserts in a binary-themed cafe. Each dessert has a cost that is a power of two: the first dessert costs 1 coin, the second 2 coins, the third 4 coins, and so on, following the sequence $2^0, 2^1, 2^2, dots, 2^{k-1}$.

codeforcescompetitive-programmingbitmaskscombinatoricsmath
CF 1841C - Ranom Numbers

You pick an index i, remove c[i], and replace the pair (c[i-1], c[i+1]) by their sum. So locally: This is not a “subarray optimization” problem. It is a tree of merges problem: - Every element can repeatedly get absorbed into neighbors.

codeforcescompetitive-programmingbrute-forcedpgreedymathstrings
CF 1841F - Monocarp and a Strategic Game

We are asked to simulate a strategic city-building game where Monocarp can accept or reject groups of creatures arriving in his city. Each group contains a certain number of humans, orcs, elves, and dwarves.

codeforcescompetitive-programminggeometrysortingstwo-pointers
CF 1841E - Fill the Matrix

Each column of the matrix contains a black prefix and a white suffix. In column i, rows 1..ai are blocked, while rows ai+1..n are available. We must place the integers 1,2,...,m into distinct white cells.

codeforcescompetitive-programmingdata-structuresgreedymath
CF 1841D - Pairs of Segments

We are given an array of segments, each represented by two integers marking its left and right endpoints. The task is to remove as few segments as possible so that the remaining segments can be paired up in such a way that within each pair, the segments overlap, and segments…

codeforcescompetitive-programmingdata-structuresgreedysortingstwo-pointers
CF 1841B - Keep it Beautiful

We start with an empty array and receive numbers one by one. For each incoming value x, we must decide whether appending it to the current array keeps the array "beautiful". If it does, we permanently append it. Otherwise we ignore it.

codeforcescompetitive-programmingimplementation
CF 1841A - Game with Board

We start with a multiset of numbers where all values are identical and equal to one, and the size of this multiset is given by $n$. Two players alternate turns, with Alice moving first.

codeforcescompetitive-programmingconstructive-algorithmsgames
CF 1842I - Tenzing and Necklace

The problem presents a circular necklace consisting of $n$ pearls, where each pearl is connected to its neighbor by a string, and the last pearl connects back to the first. Each string has a cost in minutes to cut.

codeforcescompetitive-programmingdivide-and-conquerdpgreedy
CF 1842H - Tenzing and Random Real Numbers

We have $n$ independent random variables, each chosen uniformly from the interval $[0,1]$. Between pairs of variables we are given constraints of the form $$xi+xjle 1$$ or $$xi+xjge 1.$$ The task is to compute the probability that all constraints hold simultaneously.

codeforcescompetitive-programmingbitmasksdpgraphsmathprobabilities
CF 1842F - Tenzing and Tree

The proposed “solution” does not address the mathematical exercise at all. Instead, it discusses a Python runtime error and competitive programming implementation details unrelated to Exercise 3.3.1.

codeforcescompetitive-programmingdfs-and-similargreedyshortest-pathssortingstrees
CF 1842G - Tenzing and Random Operations

We are given an array where each element starts as a fixed value, and then we repeatedly apply a random “suffix increment” operation. In one operation we pick an index uniformly from the array, and we add a constant value v to every element from that index to the end.

codeforcescompetitive-programmingcombinatoricsdpmathprobabilities
CF 1842C - Tenzing and Balls

We are given several test cases. Each test case starts with a line of integers representing a sequence of colored balls arranged in a row.

codeforcescompetitive-programmingdp
CF 1842D - Tenzing and His Animal Friends

The proposed “solution” does not address the mathematical exercise at all. Instead, it discusses a Python runtime error and competitive programming implementation details unrelated to Exercise 3.3.1.

codeforcescompetitive-programmingconstructive-algorithmsgraphsgreedy