brain

tamnd's digital brain — notes, problems, research

41650 notes

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
CF 1794E - Labeling the Tree with Distances

We are given a tree with $n$ vertices and a multiset of $n-1$ integers. One vertex is special: it is not assigned any value from the list, while every other vertex must be assigned exactly one number from the list.

codeforcescompetitive-programmingdata-structuresdpgreedyhashingimplementationtrees
CF 1794D - Counting Factorizations

We are given a multiset of $2n$ integers, which may include both primes and positive integers greater than one. The goal is to count how many positive integers $m$ have a prime factorization that produces exactly this multiset when each prime and its exponent are included as…

codeforcescompetitive-programmingcombinatoricsdivide-and-conquerdpmathnumber-theory
CF 1794B - Not Dividing

We are given an array of positive integers. The goal is to modify the array so that no element divides the next element, using only increments of 1. Each element can be incremented multiple times, but the total number of operations must not exceed twice the array length.

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 1794A - Prefix and Suffix Array

We are given a hidden string $s$ of length $n$. Instead of seeing $s$ directly, we are shown a multiset of strings consisting of every non-empty prefix of $s$ and every non-empty suffix of $s$, except for $s$ itself.

codeforcescompetitive-programmingstrings
CF 1794C - Scoring Subsequences

We are given a non-decreasing array. For every prefix a[1...k], we must determine a special value called the cost. For any subsequence of length d, its score is the product of its elements divided by d!.

codeforcescompetitive-programmingbinary-searchgreedymathtwo-pointers
CF 1795F - Blocking Chips

We are given a tree, which is a connected acyclic graph with n vertices. Some of these vertices initially contain chips, each located on a distinct vertex. Every vertex that contains a chip is colored black, and the rest are white.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsdfs-and-similargreedytrees
CF 1795G - Removal Sequences

We are given a graph with $n$ vertices and $m$ edges. Each vertex $i$ has an associated number $ai$. A vertex can only be removed if its current degree equals $ai$, and when a vertex is removed, its incident edges disappear, reducing the degrees of its neighbors.

codeforcescompetitive-programmingbitmasksdfs-and-similargraphs
Kvant Math Problem 2862

Consider the equation

kvantmathematicsolympiad
CF 1795E - Explosions?

We are given a row of monsters, each with a certain health, and two types of attacks: a basic spell that reduces any monster's health by 1 for 1 MP, and a single-use "Explosion" that can be targeted on one monster with an arbitrary power.

codeforcescompetitive-programmingbinary-searchdata-structuresdpgreedymath
CF 1795D - Triangle Coloring

The graph is not arbitrary. It is composed of independent groups of three vertices, and inside each group all three pairs are connected, forming a triangle.

codeforcescompetitive-programmingcombinatoricsmath
CF 1795A - Two Towers

We are given two vertical stacks of colored blocks. Each stack is described from bottom to top as a string consisting of only two symbols: B for blue and R for red.

codeforcescompetitive-programmingbrute-forceimplementationstrings
CF 1795C - Tea Tasting

Connection interrupted. Waiting for the complete answer

codeforcescompetitive-programmingbinary-searchdata-structuresimplementation
Kvant Math Problem 2860

Consider the problem of determining whether both sums

kvantmathematicsolympiad
CF 1795B - Ideal Point

We are working with a set of closed intervals on a number line, and we are allowed to discard any subset of them. For any integer coordinate $x$, we define its coverage value $f(x)$ as the number of remaining segments that include $x$.

codeforcescompetitive-programmingbrute-forcegeometrygreedy
CF 1796F - Strange Triples

We are asked to count triples of positive integers (a, b, n) that satisfy a specific strange property. Here, a can range from 1 up to A-1, b from 1 up to B-1, and n from 1 up to N-1.

codeforcescompetitive-programmingbrute-forcemathnumber-theory
CF 1796E - Colored Subgraphs

We are given a tree with $n$ vertices, and we are allowed to choose any vertex $r$ as a root. Once the root is fixed, every vertex gets a distance label $dv$, which is simply how far it is from $r$. After this, we assign colors to vertices under two constraints.

codeforcescompetitive-programmingdfs-and-similardpgamesgreedytrees
CF 1796A - Typical Interview Problem

We are asked to reason about an infinite string that is not built directly character by character, but generated from the positive integers in order.

codeforcescompetitive-programmingbrute-forceimplementationstrings
CF 1796D - Maximum Subarray

Producing a complete editorial of the quality and length you requested for Codeforces 1796D would require first deriving and verifying the full intended solution in detail.

codeforcescompetitive-programmingdata-structuresdpgreedytwo-pointers
Kvant Math Problem 2861

The configuration contains two coupled constructions on the base line $BC$ and two circumcenter loci attached to triangles $NEC$ and $MFB$.

kvantmathematicsolympiad
CF 1796B - Asterisk-Minor Template

We are asked to construct a “template” string that can describe two given strings simultaneously. A template consists of lowercase letters and asterisks. Each asterisk can be replaced with any string, including the empty string, to match the original strings.

codeforcescompetitive-programmingimplementationstrings
CF 1796C - Maximum Set

We are asked to work with sets of integers that are “beautiful,” meaning that any two numbers in the set are comparable under divisibility.

codeforcescompetitive-programmingbinary-searchmath
CF 1797E - Li Hua and Array

We are given an array of integers and two types of operations. The first operation transforms elements in a range by applying Euler's totient function, which reduces a number to the count of integers coprime to it.

codeforcescompetitive-programmingbrute-forcedata-structuresdsumathnumber-theorytwo-pointers
CF 1797F - Li Hua and Path

We are working with a rooted but otherwise unrooted tree where every vertex carries a unique label from 1 to n, and these labels matter structurally rather than just as identifiers. For any two vertices u and v, consider the unique simple path connecting them.

codeforcescompetitive-programmingdata-structuresdfs-and-similardivide-and-conquerdsutrees
CF 1797D - Li Hua and Tree

We are given a rooted tree with n vertices, where each vertex has a numerical importance. The root is vertex 1. Two types of operations can be performed on this tree. The first operation asks for the sum of importance values in the subtree rooted at a given node.

codeforcescompetitive-programmingbrute-forcedata-structuresdfs-and-similardpimplementationtrees
CF 1797C - Li Hua and Chess

We are dealing with a hidden position on an extremely large grid, up to one billion in both dimensions. A king is placed on one cell, and our task is to determine its exact coordinates. We cannot directly access the position.

codeforcescompetitive-programmingconstructive-algorithmsgreedyinteractive
CF 1797A - Li Hua and Maze

This is a Type B (prove) problem: the task is to prove that the intersection point of the diagonals of quadrilateral $ABCD$ coincides with the intersection of the common internal tangents of the two circles. The solution correctly addresses a proof,

codeforcescompetitive-programmingconstructive-algorithmsflowsgraphsgreedyimplementation
CF 1797B - Li Hua and Pattern

We are given an $n times n$ grid where each cell is either 0 or 1, representing two colors. We are also given a fixed number $k$ of moves. A single move flips the color of exactly one chosen cell.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1798D - Shocking Arrangement

We are given an array of integers whose sum is zero. The task is to rearrange the elements so that the maximum absolute sum over any contiguous subarray is strictly less than the difference between the largest and smallest elements in the array.

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 1798F - Gifts from Grandfather Ahmed

We are given a collection of gift boxes, each box containing some positive number of gifts. There are $n$ existing boxes, and we must add exactly one additional box with an integer number of gifts between 1 and $10^6$. After that, we will have $n+1$ boxes in total.

codeforcescompetitive-programmingdpmathnumber-theory
CF 1798C - Candy Store

Each candy type has two numbers attached to it. There are $ai$ candies of that type in stock, and each candy costs $bi$ coins. For every type, we must choose a pack size $di$.

codeforcescompetitive-programminggreedymathnumber-theory
CF 1798E - Multitest Generator

We are given an array, and we look at every suffix starting from position i. For each suffix, we are allowed to change some elements arbitrarily to non-negative integers.

codeforcescompetitive-programmingbrute-forcedp
CF 1798B - Three Sevens

We are given a sequence of days. On each day, a group of people participates in a lottery, and exactly one of them is chosen as the winner for that day. The key restriction is that once someone wins on day i, they are forbidden from appearing in any later day i+1 through m.

codeforcescompetitive-programmingbrute-forcedata-structuresgreedyimplementation
CF 1798A - Showstopper

We are given two arrays of equal length, which we can think of as parallel sequences of tiles. Each tile has two numbers: one on the "a" side and one on the "b" side. We are allowed to swap the numbers on a single tile as many times as we want.

codeforcescompetitive-programminggreedyimplementationsortings
CF 1799G - Count Voting

We have a group of $n$ people, each belonging to a specific team, and each person wants to receive a certain number of votes. The rules restrict voting so that no one can vote for themselves and no one can vote for someone on their own team.

codeforcescompetitive-programmingcombinatoricsdpmath
CF 1799F - Halve or Subtract

We are given an array of positive integers and two types of optional operations that can be applied to elements, with global limits and per-element limits.

codeforcescompetitive-programmingbinary-searchbrute-forcedpgreedysortings
CF 1799H - Tree Cutting

I can't reliably write a correct, complete editorial for Codeforces 1799H from the problem statement alone. This is a 3200-rated problem with a highly nontrivial tree DP over subsets, and the solution involves delicate state design and transition conditions.

codeforcescompetitive-programmingbitmasksdfs-and-similardp
CF 1799E - City Union

We are given a rectangular grid of size $n times m$, where each cell is either filled or empty. A "city" is defined as a connected component of filled cells, where connectivity is through sides (no diagonals). Initially, there are exactly two cities on the grid.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similardsugeometrygreedyimplementationmath
CF 1799D1 - Hot Start Up (easy version)

We are given a fixed execution order of programs, and we must execute them sequentially on a machine with two independent CPUs. Each program has two possible execution costs: a normal cost and a reduced cost.

codeforcescompetitive-programmingdp
CF 1799D2 - Hot Start Up (hard version)

We are given a sequence of programs that must be executed in order, using two CPUs. Each program has two run times: a cold time, which applies if the CPU last ran a different program, and a hot time, which applies if the CPU last ran the same program.

codeforcescompetitive-programmingdata-structuresdp
CF 1799C - Double Lexicographically Minimum

We are given a string consisting of lowercase letters, and the task is to reorder its characters into a new string t such that when we consider t and its reverse, the lexicographically larger of the two-denoted tmax-is as small as possible in lexicographic order.

codeforcescompetitive-programminggreedystrings
Kvant Math Problem 2858

Consider a tree with $n$ vertices, each initially containing a single chip.

kvantmathematicsolympiad
CF 1799B - Equalize by Divide

We are given an array of positive integers. We can repeatedly pick two distinct indices $i$ and $j$, and set the element at index $i$ to the ceiling of its division by the element at index $j$.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedymath
CF 1799A - Recent Actions

We are asked to track the "Recent Actions" field of posts on a site like Codeforces. Initially, the field contains the first $n$ posts, numbered $1$ through $n$, from top to bottom. New posts with numbers $n+1$ and higher can appear through actions.

codeforcescompetitive-programmingdata-structuresgreedyimplementationmath
CF 1800G - Symmetree

We are given a rooted tree with vertices numbered from 1 to $n$, where vertex 1 is the root. Each vertex can have zero or more children, and the input specifies the edges connecting vertices. The task is to determine whether the tree is symmetrical.

codeforcescompetitive-programmingdfs-and-similarhashingimplementationtrees
CF 1800E2 - Unforgivable Curse (hard version)

We have two strings of equal length, s and t. Starting from s, we may repeatedly swap characters whose positions differ by exactly k or exactly k + 1. The question is whether these allowed swaps are powerful enough to transform s into t.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdfs-and-similardsugraphsgreedystrings
CF 1800F - Dasha and Nightmares

We are given a list of words and asked to count pairs of words whose concatenation satisfies several strict properties.

codeforcescompetitive-programmingbitmaskshashingmeet-in-the-middlestrings
Kvant Math Problem 2859

Assume that a function $f:\mathbb R\to\mathbb R$ satisfies

kvantmathematicsolympiad
CF 1800D - Remove Two Letters

We are given a string consisting of lowercase Latin letters, and the task is to count how many distinct strings can be formed by removing any two consecutive characters. Each test case consists of a string of length at least three.

codeforcescompetitive-programmingdata-structuresgreedyhashingstrings
CF 1800E1 - Unforgivable Curse (easy version)

We are given two strings of equal length, and we are allowed to transform the first string into the second by swapping characters, but only under a restricted rule: we can swap positions whose indices differ by either 3 or 4.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdsugraphsgreedystrings
CF 1800C1 - Powering the Hero (easy version)

We process a deck of cards from top to bottom. Positive values represent bonus cards, while 0 represents a hero card. Whenever we encounter a bonus card, we may keep it for later or throw it away.

codeforcescompetitive-programmingdata-structuresgreedy
CF 1800C2 - Powering the Hero (hard version)

We are given a sequence of cards arranged in a fixed order, and we process them from top to bottom. Each card is either a hero or a bonus. A hero card has value zero and represents an opportunity to finalize one hero in our army.

codeforcescompetitive-programmingdata-structuresgreedy
CF 1800B - Count the Number of Pairs

Kristina has a string of letters that can be lowercase or uppercase. She earns one burl for every valid pair consisting of a lowercase letter and its corresponding uppercase version. Each letter can only participate in a single pair.

codeforcescompetitive-programminggreedystrings
Kvant Math Problem 2856

For a query polynomial $Q$, the answer is the set of real roots of

kvantmathematicsolympiad
CF 1800A - Is It a Cat?

We are asked to determine if a given string represents the sound of a cat meowing. The sound must strictly follow the pattern “m-e-o-w” in order, where each letter can appear multiple times consecutively, and both uppercase and lowercase letters are allowed.

codeforcescompetitive-programmingimplementationstrings
Kvant Math Problem 2855

Consider an isosceles triangle $ABC$ with $CA=CB$ and axis of symmetry $CM$, where $M$ is the midpoint of $AB$.

kvantmathematicsolympiad
CF 1801G - A task for substrings

We are given a very long text string t and a set of distinct dictionary words s₁, s₂, ..., sₙ. For each query [l, r], we look only at the substring t[l..r]. Inside that interval we must count how many substrings are equal to one of the dictionary words.

codeforcescompetitive-programmingdata-structuresstring-suffix-structuresstrings
CF 1801F - Another n-dimensional chocolate bar

We are given a chocolate bar in n dimensions. Along each dimension, the bar is already divided into discrete units: for dimension i, there are ai units. Vasya wants to cut the chocolate further along these pre-existing divisions to produce at least k pieces.

codeforcescompetitive-programmingdpmathmeet-in-the-middlenumber-theory
CF 1801D - The way home

We are given a directed network of cities where each city has a per-day income, and each flight has a fixed cost. We start in city 1 with some initial amount of money, and the goal is to reach city n.

codeforcescompetitive-programmingbinary-searchdata-structuresdpgraphsgreedyshortest-pathssortings
CF 1801C - Music Festival

The reason your solution produces no output is that it never actually writes to stdout. In the previous drafts, you were appending results to a list ans but never called print or sys.stdout.write. This is why the program runs without error but shows an empty output.

codeforcescompetitive-programmingbinary-searchdata-structuresdpgreedysortings
CF 1801E - Gasoline prices

We are given a country, Berland, structured as a tree of cities rooted at city 1. Each city has a gas station with a price range $[li, ri]$. Every year, the king’s two sons inspect gasoline prices along two paths of equal length.

codeforcescompetitive-programmingdata-structuresdivide-and-conquerdsuhashingtrees
CF 1801A - The Very Beautiful Blanket

We are asked to construct an $n times m$ grid filled with integers such that a specific XOR condition holds for every $4 times 4$ subgrid.

codeforcescompetitive-programmingbitmasksconstructive-algorithms
CF 1801B - Buying gifts

We are given several independent test cases. In each test case, there are $n$ departments, and each department offers two possible prices $ai$ and $bi$.

codeforcescompetitive-programmingdata-structuresgreedysortings
CF 1802B - Settlement of Guinea Pigs

We are simulating a timeline where new guinea pigs arrive over time, and occasionally a “reveal” event happens where all currently owned animals suddenly have their genders revealed.

codeforcescompetitive-programminggreedyimplementationmath
Kvant Math Problem 2849

This is a **C: optimization problem**.

kvantmathematicsolympiad
CF 1802A - Likes

The problem describes a sequence of user interactions on a post, where each interaction is either a like or an unlike. The input sequence is shuffled, so the chronological order is lost.

codeforcescompetitive-programminggreedyimplementation