brain

tamnd's digital brain — notes, problems, research

43815 notes

CF 1778C - Flexible String

We are given two equal-length strings, and we are allowed to modify the first string in a very specific way. Each time we change a character in the first string, the original character at that position gets “recorded” into a special set.

codeforcescompetitive-programmingbitmasksbrute-forcestrings
Kvant Math Problem 2883

The previous solution attempted to prove nonexistence by separating cases according to the prime factorization of $n$.

kvantmathematicsolympiad
CF 1779G - The Game of the Century

The village is represented as a triangular grid of intersections. Each side of the triangle has length $n$, and the interior is subdivided into $n^2$ smaller equilateral triangles. The roads of the village run along the sides of these triangles and are one-way.

codeforcescompetitive-programmingconstructive-algorithmsgraphsshortest-paths
CF 1779E - Anya's Simultaneous Exhibition

We are asked to identify candidate masters among a group of chess players where the outcome of any head-to-head match is deterministic but may be non-transitive. That means some cycles can exist, such as player A beating B, B beating C, and C beating A.

codeforcescompetitive-programmingconstructive-algorithmsgraphsgreedyinteractivesortings
CF 1779H - Olympic Team Building

We are given a set of $n$ players, where $n$ is a power of two, and each player has a fixed positive strength. A sequence of elimination rounds is played. In each round, the current set of players is split into two equal groups.

codeforcescompetitive-programmingbrute-forcemeet-in-the-middle
CF 1779F - Xorcerer's Stones

We are given a rooted tree where each node stores a small integer value. A single operation selects a node and replaces every value in its subtree with the XOR of all values currently inside that subtree. After this assignment, every node in that subtree becomes identical.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsdptrees
Kvant Math Problem 2884

The task is to determine the smallest integer $k$ such that, after adaptive subset queries with a binary oracle that may err but never on two consecutive days, the Wizard can always guarantee that at…

kvantmathematicsolympiad
CF 1779D - Boris and His Amazing Haircut

We are asked to transform Boris's current hairstyle into a desired one using a limited set of razors, each of which can cut hair down to a fixed length over any contiguous segment.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresdpdsugreedysortings
CF 1779C - Least Prefix Sum

We are given an array of integers, and Baltic wants a specific prefix sum-the sum of the first m elements-to be the smallest among all prefix sums of the array. We are allowed to flip the sign of any element any number of times.

codeforcescompetitive-programmingdata-structuresgreedy
CF 1779A - Hall of Fame

Thalia has a line of trophies, each with a lamp that can shine either to the left or to the right. The lamp at position i illuminates all trophies strictly in the direction it points, excluding itself.

codeforcescompetitive-programmingconstructive-algorithmsgreedystrings
CF 1779B - MKnez's ConstructiveForces Task

This is a Type B problem: prove impossibility. The solution correctly identifies that the task is to show that no plane can cut a regular $n$-gonal pyramid into a regular $(n+1)$-gon when $n ge 5$.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1780D - Bit Guessing Game

The problem presents a game where we must determine a hidden integer n using only the number of set bits (1s) in its binary representation. Initially, we know how many 1s n has. We can subtract any positive integer x from n as long as it does not exceed n.

codeforcescompetitive-programmingbinary-searchbitmasksconstructive-algorithmsinteractive
CF 1780G - Delicious Dessert

We are given a string s of length n representing Tonio's dessert recipe. A substring of s is called delicious if the number of times it appears in s is divisible by its own length. The task is to count all delicious substrings of s, counting multiple occurrences separately.

codeforcescompetitive-programmingbinary-searchdsuhashingmathnumber-theorystring-suffix-structures
CF 1780F - Three Chairs

We are asked to select three friends from a group of $n$ friends, each with a unique height, such that the smallest and largest heights among the chosen three are coprime. The input gives $n$ followed by an array of $n$ distinct integers representing the heights.

codeforcescompetitive-programmingbitmasksbrute-forcecombinatoricsdata-structuresdpnumber-theorysortings
CF 1780E - Josuke and Complete Graph

Working

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresmathnumber-theory
CF 1780A - Hayato and School

We are asked to find, in an array of integers, three distinct elements whose sum is odd. The input consists of multiple test cases, each providing the array. The output must indicate whether such a triple exists, and if it does, provide any valid set of three indices.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1780B - GCD Partition

We are given an array of positive integers. Our task is to split this array into at least two contiguous subsegments, compute the sum of each subsegment, and then take the greatest common divisor (GCD) of these sums.

codeforcescompetitive-programmingbrute-forcegreedymathnumber-theory
CF 1781G - Diverse Coloring

I see exactly where prior solutions fail: the minimal cable along the walls and ceiling/floor is not simply the Manhattan distance in x + y + h, because the cable can wrap around walls, reducing the total distance in x or y by traveling along the opposite wall.

codeforcescompetitive-programmingconstructive-algorithmstrees
CF 1781H2 - Window Signals (hard version)

We are working on a grid of size $h times w$, where each cell represents a window that can either be lit or dark. A configuration is simply a subset of cells chosen as “on”, with the restriction that at most two specific cells are forbidden from being used.

codeforcescompetitive-programming
CF 1781H1 - Window Signals (easy version)

We are given a building with $h$ floors and $w$ windows on each floor, forming a grid of $h times w$. Every window can be either on or off, except for up to two broken windows that are permanently off.

codeforcescompetitive-programming
CF 1781F - Bracket Insertion

We are asked to calculate the probability that a bracket sequence formed by repeated random insertions ends up being regular. The process starts with an empty string and runs for n steps. In each step, a new two-character string is inserted at a random position.

codeforcescompetitive-programmingcombinatoricsdpmathtrees
Kvant Math Problem 2878

This is a **Type B (prove)** problem.

kvantmathematicsolympiad
CF 1781B - Going to the Cinema

Each person has a threshold value $ai$. Their decision is completely determined by the final number of people attending the cinema. Suppose exactly $k$ people go.

codeforcescompetitive-programmingbrute-forcegreedysortings
CF 1781D - Many Perfect Squares

We are allowed to choose a shift value $x$, and this shift transforms every number in a fixed set by adding $x$. After shifting, we inspect how many of the resulting numbers become perfect squares.

codeforcescompetitive-programmingbrute-forcemathnumber-theory
CF 1781E - Rectangle Shrinking

We are working on a very thin grid: only two rows, but an extremely large number of columns. Each input rectangle occupies some contiguous segment of columns and spans either row 1, row 2, or both.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresgreedyimplementationtwo-pointers
Kvant Math Problem 2880

This is a Type B (prove) problem.

kvantmathematicsolympiad
CF 1781C - Equal Frequencies

We are asked to transform a given string into a "balanced" string, where every character that appears does so the same number of times. The transformation should change as few positions as possible.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedyimplementationsortingsstrings
CF 1781A - Parallel Projection

We are working inside a rectangular room shaped like a box. A point on the floor marks where the laptop sits, and a point directly above on the ceiling marks where the projector hangs.

codeforcescompetitive-programminggeometrymath
CF 1783G - Weighed Tree Radius

We are given a tree with $n$ vertices, where each vertex has an initial weight $ai$. Distances between vertices are measured in the usual unweighted tree sense (number of edges along the path), but we define a weighted distance from vertex $v$ to vertex $u$ as $wv(u) = dv(u) +…

codeforcescompetitive-programmingdata-structuresdivide-and-conquerimplementationtrees
CF 1783D - Different Arrays

We start with a fixed integer array. The process described in the problem does not allow arbitrary modifications.

codeforcescompetitive-programmingbrute-forcedpimplementation
Kvant Math Problem 2877

The flaw in the previous solution is the assumption that Wolf must win on every graph, and that showing a single losing graph is sufficient to refute his strategy.

kvantmathematicsolympiad
CF 1783F - Double Sort II

We are given two rows of numbers, each row being a permutation of 1..n. Think of them as two parallel arrays where every value from 1 to n appears exactly once in each row. The only allowed move is driven by a value i, not by a position.

codeforcescompetitive-programmingdfs-and-similarflowsgraph-matchingsgraphs
CF 1783E - Game of the Year

For each boss, Monocarp would kill it on his a[i]-th personal attempt, while Polycarp would kill it on his b[i]-th personal attempt. The fight is divided into blocks of size k. Monocarp performs k attempts, then Polycarp performs k attempts, then Monocarp again, and so on.

codeforcescompetitive-programmingbrute-forcedata-structuresmathnumber-theory
Kvant Math Problem 2873

Something went wrong.

kvantmathematicsolympiad
CF 1783B - Matrix of Differences

We are asked to construct an $n times n$ grid filled with the integers from $1$ to $n^2$ exactly once. Once the grid is built, we look at every pair of cells that share a side and compute the absolute difference of their values.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1783C - Yet Another Tournament

We are in a round-robin tournament with $n+1$ participants: you and $n$ opponents labeled from 1 to $n$. Every opponent pair plays exactly once, and stronger opponents always beat weaker ones: opponent $i$ beats $j$ if $i j$. Against you, the situation is different.

codeforcescompetitive-programmingbinary-searchgreedysortings
CF 1783A - Make it Beautiful

We are given an array of integers sorted in non-decreasing order, and we need to rearrange its elements so that no element equals the sum of all previous elements. If such a rearrangement is impossible, we must report it.

codeforcescompetitive-programmingconstructive-algorithmsmathsortings
CF 1784E - Infinite Game

We are given a short string consisting of characters that can be interpreted as decisions in a repeated competitive process. Each character represents a round outcome between two players, and the string is repeated infinitely to generate an endless sequence of rounds.

codeforcescompetitive-programmingbrute-forcecombinatoricsdpgamesprobabilities
CF 1784F - Minimums or Medians

We are given the set of consecutive integers from 1 to 2n. Vika performs exactly k operations on this set. Each operation consists of either removing the two smallest integers or removing the two middle integers, which are the two integers at positions n and n+1 if the set is…

codeforcescompetitive-programming
CF 1784D - Wooden Spoon

We are asked to count, for each player in a single-elimination tournament of size $2^n$, the number of ways they can end up with a "Wooden Spoon." The tournament is deterministic: whenever two players meet, the one with the smaller number always wins.

codeforcescompetitive-programmingcombinatoricsdp
CF 1784A - Monsters (easy version)

We are given several independent scenarios. In each scenario, there are $n$ monsters arranged conceptually in a line, and each monster has some integer health value. A monster disappears once its health reaches zero. We can perform two kinds of actions.

codeforcescompetitive-programmingbrute-forcegreedy
CF 1784C - Monsters (hard version)

We are asked to find the minimum number of single-target damage spells needed to kill monsters in a game, where a powerful area-of-effect spell can also be cast once.

codeforcescompetitive-programmingdata-structuresgreedy
CF 1784B - Letter Exchange

Each person starts with exactly three letters chosen from w, i, and n. Across all people combined, there are exactly m copies of each letter, so globally the supply is already balanced. The only issue is that the letters are distributed unevenly among individuals.

codeforcescompetitive-programmingconstructive-algorithms
CF 1786A2 - Alternating Deck (hard version)

We have a deck of n cards arranged so that the colors strictly alternate, starting with white. Alice deals these cards in increasing batch sizes: first one card to herself, then two cards to Bob, three cards to Bob, four cards to Alice, five to Alice, six to Bob, seven to Bob…

codeforcescompetitive-programmingimplementation
CF 1786B - Cake Assembly Line

We are given two ordered systems on a number line. One system represents cakes, each occupying a fixed interval centered at a given position, and the other represents chocolate dispensers, each also producing a fixed interval of coverage.

codeforcescompetitive-programmingbrute-forcesortings
CF 1786A1 - Non-alternating Deck (easy version)

We are simulating a very specific dealing process from a deck of identical cards. Cards are taken from the top of the deck in increasing batch sizes. On the first move, 1 card is dealt, on the second move 2 cards, on the third move 3 cards, and so on.

codeforcescompetitive-programmingimplementation
CF 1787I - Treasure Hunt

We are asked to calculate a sum over all non-empty contiguous subarrays of a given sequence. For each subarray, we define a "beauty value" that depends on choosing two segments: the prefix of some length q and another subsegment bs..bt that may overlap with the prefix.

codeforcescompetitive-programmingdata-structuresdivide-and-conquertwo-pointers
CF 1787H - Codeforces Scoreboard

I can't reliably produce a complete editorial and accepted implementation for Codeforces 1787H from the problem statement alone. This is a 3300-rated problem whose accepted solution uses a fairly intricate convex-DP / slope-trick optimization.

codeforcescompetitive-programmingbinary-searchdata-structuresdpgeometry
CF 1787G - Colorful Tree Again

We are given a tree of n nodes, where each edge has a weight and a color. Initially, all nodes are unblocked. A path is considered good if it consists solely of edges of a single color, all edges of that color appear somewhere on the path, and all nodes on the path are unblocked.

codeforcescompetitive-programmingbrute-forcedata-structurestrees
CF 1787B - Number Factorization

The problem asks us to take an integer $n$ and factor it into a product of integers raised to positive powers, $n = prod ai^{pi}$, with the constraint that each $ai$ is composed of distinct prime numbers only.

codeforcescompetitive-programminggreedymathnumber-theory
CF 1787F - Inverse Transformation

I’m sorry, but I can’t reliably produce a complete editorial and full accepted implementation for Codeforces 1787F from memory alone.

codeforcescompetitive-programmingconstructive-algorithmsimplementationmath
CF 1787E - The Harmonization of XOR

We are given the consecutive integers from 1 to n, and we must split them into exactly k groups so that every number appears in exactly one group.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsgreedymath
Kvant Math Problem 2879

Consider small natural numbers $n$ and compute $S(n)$, $S(7n)$, and $S(9n)$.

kvantmathematicsolympiad
CF 1787D - Game on Axis

We are given an array of integers, each representing a "jump" value on points labeled from $1$ to $n$. Starting at position $1$, we move to the next position by adding the current value: if we are at $i$, we jump to $i + ai$.

codeforcescompetitive-programmingcombinatoricsdfs-and-similardsugraphsimplementation
CF 1787A - Exponential Equation

We are asked to find two integers $x$ and $y$ between 1 and $n$ inclusive such that the sum of $x^y cdot y$ and $y^x cdot x$ equals $n$. Conceptually, we are looking for a pair whose mixed exponential terms, weighted by the other number, add up exactly to $n$.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1787C - Remove the Bracket

We are given an array $a$ and a value $s$. For every internal position $i$ with $2 le i le n-1$, we must split $ai$ into two non-negative parts: $$xi + yi = ai$$ The additional condition $$(xi-s)(yi-s)ge 0$$ means that both parts must lie on the same side of $s$.

codeforcescompetitive-programmingdpgreedymath
CF 1788F - XOR, Tree, and Queries

We have a tree with $n$ vertices and $n-1$ edges. We must assign a non-negative integer weight to every edge. Some constraints are given in the form $(u,v,x)$, meaning that the XOR of all edge weights along the unique path between $u$ and $v$ must equal $x$.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsdfs-and-similardsugraphsgreedyimplementationtrees
CF 1788E - Sum Over Zero

We are given an array of integers and want to choose several segments on it. Each chosen segment must have a non-negative sum, and no two chosen segments are allowed to overlap.

codeforcescompetitive-programmingdata-structuresdfs-and-similardp
CF 1788D - Moving Dots

We are given a set of $n$ distinct dots positioned on a number line. Each dot moves toward the nearest other dot, stopping when it meets another dot. If a dot has two equally close neighbors, it moves left. Once dots meet, they merge into a single stationary point.

codeforcescompetitive-programmingbinary-searchbrute-forcecombinatoricsmathtwo-pointers
CF 1788A - One and Two

We are given a sequence of numbers where each element is either 1 or 2. Our goal is to split the sequence into two contiguous parts such that the product of numbers in the first part equals the product of numbers in the second part.

codeforcescompetitive-programmingbrute-forceimplementationmath
CF 1788C - Matching Numbers

The task asks us to pair up all integers from 1 to 2n into exactly n pairs, such that the sums of the pairs form a sequence of consecutive integers.

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 1789E - Serval and Music Game

We are given a strictly increasing sequence of positive integers, and the largest element of this sequence plays a special role. Let us call this largest value $S$. For every integer $x$ from $1$ to $S$, we derive two numbers: the floor and ceiling of $S/x$.

codeforcescompetitive-programmingbrute-forcedpimplementationmathnumber-theory
CF 1789F - Serval and Brain Power

We are asked to find the length of the longest "powerful" subsequence of a given string. A powerful string is one that can be obtained by repeating a smaller string at least twice. Formally, if some string $T'$ can be repeated $k ge 2$ times to form $T$, then $T$ is powerful.

codeforcescompetitive-programmingbitmasksbrute-forcedpgreedyimplementationstrings
CF 1789D - Serval and Shift-Shift-Shift

We are given two binary numbers a and b of length n, and we want to transform a into b using a series of XOR-shift operations.

codeforcescompetitive-programmingbitmasksbrute-forceconstructive-algorithmsimplementation
CF 1789A - Serval and Mocha's Array

We are given several test cases, each consisting of a small array of positive integers. For each array, we are allowed to reorder its elements arbitrarily. After choosing an order, we inspect every prefix of length at least two and compute the gcd of that prefix.

codeforcescompetitive-programmingbrute-forcemathnumber-theory
Kvant Math Problem 2872

Two distinct natural numbers $x$ and $y$ form a beautiful pair when

kvantmathematicsolympiad
CF 1789C - Serval and Toxel's Arrays

We are given an initial array containing distinct values, and then a sequence of updates. Each update changes exactly one position, and after every update the array still contains distinct values.

codeforcescompetitive-programmingcombinatoricsdpimplementationmath
Kvant Math Problem 2871

Let $p>2$ be a prime number and $k$ an integer with $0<k<p-1$.

kvantmathematicsolympiad
CF 1789B - Serval and Inversion Magic

We are given a binary string consisting only of 0s and 1s. The task is to determine whether we can make it a palindrome by flipping exactly one contiguous segment of the string. Flipping a segment means changing every 0 in that segment to 1 and every 1 to 0.

codeforcescompetitive-programmingbrute-forceimplementationstringstwo-pointers
CF 1790G - Tokens on Graph

We are given a connected undirected graph where certain vertices contain tokens and certain vertices contain bonuses. A token can move along edges, but the number of moves is limited: each token can move exactly once initially.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similargraphsshortest-paths
Kvant Math Problem 2870

We are asked to prove that if a snail moves along a closed, non-self-intersecting polygonal line in the plane using only three directions—up, to the right, and down-left at an angle of $45^\circ$ to t…

kvantmathematicsolympiad
CF 1790E - Vlad and a Pair of Numbers

The problem asks us to find two positive integers, a and b, given a number x, such that two conditions hold simultaneously: a XOR b = x and (a + b)/2 = x.

codeforcescompetitive-programmingbitmasksconstructive-algorithms
CF 1790F - Timofey and Black-White Tree

We are given a tree where one vertex starts as black and every other vertex is initially white. Then vertices are gradually turned black one by one according to a fixed order.

codeforcescompetitive-programmingbrute-forcedfs-and-similardivide-and-conquergraphsgreedymathshortest-pathstrees
CF 1790D - Matryoshkas

We are given a collection of matryoshka dolls, all mixed together, and each doll has a positive integer size. Each original set consisted of dolls of consecutive sizes, and each set was used entirely.

codeforcescompetitive-programmingdata-structuresgreedysortings
CF 1790C - Premutation

We are given several test cases. In each test case there exists a hidden permutation of numbers from 1 to n. Instead of seeing the permutation directly, we are given n derived arrays.

codeforcescompetitive-programmingbrute-forceimplementationmath
CF 1790B - Taisia and Dice

We are asked to reconstruct the results of rolling multiple six-sided dice when some summary information is missing. Specifically, Taisia rolls $n$ dice, and the sum of all dice is $s$.

codeforcescompetitive-programminggreedymath
CF 1790A - Polycarp and the Day of Pi

Each test case gives a string of digits that Polycarp wrote down after trying to memorize the digits of π. The task is to determine how many leading digits of π match the prefix of this string. We are not reconstructing π or correcting errors.

codeforcescompetitive-programmingimplementationmathstrings
CF 1791G2 - Teleporters (Hard Version)

We are given a number line with positions labeled from 0 to n+1. Positions 1 through n each have a teleporter with a specified cost.

codeforcescompetitive-programmingbinary-searchgreedysortings
CF 1791F - Range Update Point Query

We are given an array of integers and a series of operations that either transform a subarray by replacing each element with the sum of its digits or query the current value of a single element. The task is to output the results of all the queries in the order they appear.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structures
CF 1791D - Distinct Split

We are asked to split a string into two non-empty parts such that the sum of distinct characters in each part is maximized.

codeforcescompetitive-programmingbrute-forcegreedystrings
CF 1791G1 - Teleporters (Easy Version)

We are placed on a line of integer points from 0 to n. At every position i from 1 to n, there is a teleporter that can be used exactly once, and using it sends us back to position 0. The cost of using the teleporter at i is a[i].

codeforcescompetitive-programminggreedysortings
CF 1791E - Negatives and Positives

We are given an array of integers, which can be positive, negative, or zero, and we are allowed to perform a single operation any number of times: choose two adjacent elements and flip their signs simultaneously.

codeforcescompetitive-programmingdpgreedysortings
CF 1791B - Following Directions

Alperen starts at the origin (0,0) on a 2D grid. He is given a sequence of n moves, where each move shifts him one unit in one of the four cardinal directions: left, right, up, or down.

codeforcescompetitive-programminggeometryimplementation
CF 1791C - Prepend and Append

We are given a binary string that is the final result of repeatedly applying a very specific operation. Each operation takes the current string and expands it by adding one character to the left end and one character to the right end, with the constraint that the two added…

codeforcescompetitive-programmingimplementationtwo-pointers
CF 1791A - Codeforces Checking

We are given a very small decision problem repeated multiple times. Each test case provides a single lowercase English letter, and we must decide whether that letter belongs to a fixed reference string, namely “codeforces”.

codeforcescompetitive-programmingimplementationstrings
Kvant Math Problem 2869

Let $ABCD$ be a convex quadrilateral with diagonals $AC$ and $BD$.

kvantmathematicsolympiad
CF 1792F1 - Graph Coloring (easy version)

We are asked to count the number of ways to color the edges of a complete graph on $n$ vertices using exactly two colors, red and blue, under very specific connectivity constraints. A complete graph means every vertex is connected to every other vertex.

codeforcescompetitive-programmingcombinatoricsdpgraphs
CF 1792F2 - Graph Coloring (hard version)

We are asked to color the edges of a complete graph with two colors, red and blue. Each edge must receive exactly one color. The crucial constraint is connectivity: every subset of vertices of size at least two must be connected in exactly one color, either red or blue.

codeforcescompetitive-programmingbrute-forcecombinatoricsdivide-and-conquerdpfftgraphs
CF 1792C - Min Max Sort

We are given a permutation of size $n$, which is simply a sequence containing each integer from $1$ to $n$ exactly once. The task is to sort this permutation using a special operation any number of times.

codeforcescompetitive-programmingbinary-searchbrute-forcegreedymathtwo-pointers
CF 1792D - Fixed Prefix Permutations

We are given multiple permutations of length $m$. Each permutation contains all integers from 1 to $m$ exactly once. The "beauty" of a permutation is the length of its initial prefix that forms the identity sequence $1, 2, 3, dots, k$.

codeforcescompetitive-programmingbinary-searchbitmasksdata-structureshashingmathsortings
CF 1792E - Divisors and Table

We are working with an $n times n$ multiplication table where each cell $(i, j)$ contains the value $i cdot j$. This table is not constructed explicitly; instead, we reason about which numbers appear in it. For each test case, we are given a number $m = m1 cdot m2$.

codeforcescompetitive-programmingbrute-forcedfs-and-similardpnumber-theory
CF 1792A - GamingForces

We are asked to determine the minimum number of spell casts Monocarp needs to kill a set of monsters, each with a certain health value.

codeforcescompetitive-programminggreedysortings
CF 1792B - Stand-up Comedian

We are given a fixed audience of two people whose reactions to jokes are completely determined by joke type. Each joke changes each person’s mood by either increasing it by one if they like the joke or decreasing it by one if they do not.

codeforcescompetitive-programminggreedymath
CF 1793F - Rebrending

We are given a lineup of candidates for a band, each with a unique height. Over several days, the organizers choose a contiguous segment of candidates and want to select two whose heights are as close as possible.

codeforcescompetitive-programmingbrute-forcedata-structuresdivide-and-conquerimplementation
CF 1793E - Velepin and Marketing

We have a set of regular readers, each with a personal threshold of satisfaction: a reader is happy if at least a certain number of people read the same book as them.

codeforcescompetitive-programmingbinary-searchdata-structuresdpgreedysortingstwo-pointers
CF 1793D - Moscow Gorillas

We are given two permutations of the same set of numbers from 1 to n. Think of them as two different orderings of the same objects placed on a line.

codeforcescompetitive-programmingbinary-searchdpgreedyimplementationmathtwo-pointers
CF 1793A - Yet Another Promotion

You need at least n kilograms of potatoes. The store is open on two different days. On the first day, each kilogram costs a, and there is a promotion: every time you pay for m kilograms, you receive one extra kilogram for free.

codeforcescompetitive-programminggreedymath
CF 1793B - Fedya and Array

We are asked to reconstruct a circular array of integers such that the difference between any two neighboring elements is exactly one. Fedya remembers only the sum of all local maxima and the sum of all local minima in this array.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1793C - Dora and Search

We are given a permutation of integers from 1 to n. Our task is to find a contiguous subsegment where the first and last elements are neither the minimum nor the maximum of that subsegment. If no such subsegment exists, we must output -1.

codeforcescompetitive-programmingconstructive-algorithmsdata-structurestwo-pointers
Kvant Math Problem 2866

The problem asks whether the integers from $1$ through $127$ can be divided into two groups such that the sum of the products of the numbers in each group ends with exactly ten zeros or exactly thirty…

kvantmathematicsolympiad