brain

tamnd's digital brain — notes, problems, research

41650 notes

CF 1163B1 - Cat Party (Easy Edition)

Shiro receives a cat every day, each cat wearing a ribbon of a certain color. The colors are integers from 1 to 10.

codeforcescompetitive-programmingdata-structuresimplementation
CF 1165C - Good String

We are asked to transform a given string into a "good string" with the minimum number of deletions. A string is good if its length is even, and every pair of consecutive characters at positions (1,2), (3,4), etc., are different.

codeforcescompetitive-programminggreedy
CF 1165E - Two Arrays and Sum of Functions

We are given two arrays of equal length, where one array is fixed and the other can be permuted arbitrarily. After choosing an ordering of the second array, we assign its values position by position against the first array.

codeforcescompetitive-programminggreedymathsortings
CF 1165A - Remainder

We are given a binary string of length $n$, where each position behaves like a digit in a decimal number but is restricted to either 0 or 1. We are allowed to flip any digit as many times as we want, and each flip costs one operation.

codeforcescompetitive-programmingimplementationmath
CF 1166E - The LCMs Must be Large

We are given a set of stores, each selling an unknown positive integer, and a record of Dora's purchases over several days. On each day, she bought integers from some stores, while her rival, Swiper, bought from the remaining stores.

codeforcescompetitive-programmingbitmasksbrute-forceconstructive-algorithmsmathnumber-theory
CF 1166B - All the Vowels Please

We are trying to construct a string of length $k$ that can be rearranged into a rectangular grid with $n$ rows and $m$ columns such that every row and every column contains all five vowels: a, e, i, o, u at least once.

codeforcescompetitive-programmingconstructive-algorithmsmathnumber-theory
CF 1166C - A Tale of Two Lands

We are given a set of integers representing potential values for two historical markers, $x$ and $y$. For each candidate pair of distinct integers $(x, y)$, we compute two intervals on the number line.

codeforcescompetitive-programmingbinary-searchsortingstwo-pointers
CF 1167C - News Distribution

We are given a social network with n users and m groups of friends. Each group contains a list of users who are mutually friends with each other.

codeforcescompetitive-programmingdfs-and-similardsugraphs
CF 1169B - Pairs

We are given a collection of integer pairs, each element ranging from 1 to some upper bound $n$. Our task is to find whether there exist two integers $x$ and $y$ such that every pair contains at least one of these two integers. In other words, $x$ or $y$ must "cover" every pair.

codeforcescompetitive-programminggraphsimplementation
CF 1170I - Good Subsets

We are given a set of segments on the real line, each defined by its left and right endpoints. The task is to count subsets of these segments whose union exactly equals the union of all segments.

codeforcescompetitive-programming*specialdp
CF 1170B - Bad Days

We are given a sequence of daily website visit counts. Each position represents one day, and the value at that position represents how many visits occurred on that day. We need to examine every day and decide whether it is “bad”.

codeforcescompetitive-programming*specialimplementation
CF 1172B - Nauuo and Circle

We are asked to count how many ways we can place the nodes of a given tree around a circle such that the edges, drawn as straight lines between nodes, do not cross. The tree has n nodes labeled from 1 to n, and n-1 edges connecting them.

codeforcescompetitive-programmingcombinatoricsdfs-and-similardptrees
CF 1173A - Nauuo and Votes

The problem asks us to determine the outcome of a simple voting scenario. There are three categories of voters: some are guaranteed to upvote, some are guaranteed to downvote, and some are undecided. The input gives the counts of each group.

codeforcescompetitive-programminggreedy
CF 1174E - Ehab and the Expected GCD Problem

We are asked to consider all permutations of the numbers from 1 to $n$. For each permutation, we define a sequence of prefix greatest common divisors (GCDs). Specifically, for the permutation $p = [p1, p2, ..., pn]$, we calculate $gi = gcd(p1, p2, ..., pi)$ for $i$ from 1 to $n$.

codeforcescompetitive-programmingcombinatoricsdpmathnumber-theory
CF 1174B - Ehab Is an Odd Person

We are given a sequence of numbers, and we are allowed to reorder it, but with a restriction on how swaps work. A swap is only legal if we pick two positions whose values have opposite parity, meaning one is odd and the other is even.

codeforcescompetitive-programmingsortings
CF 1175G - Yet Another Partiton Problem

We are asked to partition an array of integers into exactly $k$ contiguous subsegments such that the total weight is minimized. The weight of a segment is defined as its length multiplied by its maximum element. The total weight is the sum of weights over all segments.

codeforcescompetitive-programmingdata-structuresdivide-and-conquerdpgeometrytwo-pointers
CF 1175E - Minimal Segment Cover

We are given a collection of line segments on a number line and multiple queries asking about subranges. For each query segment $[x, y]$, we want to know the smallest number of given segments whose union fully covers every real point from $x$ to $y$.

codeforcescompetitive-programmingdata-structuresdfs-and-similardivide-and-conquerdpgreedyimplementationtrees
CF 1175C - Electrification

We are asked to select an integer point $x$ on a line such that the $(k+1)$-th smallest distance from $x$ to a given set of points is minimized. Each query gives us $n$ sorted integers $a1, a2, dots, an$ representing points on the $OX$ axis, and an integer $k$.

codeforcescompetitive-programmingbinary-searchbrute-forcegreedy
CF 1175B - Catch Overflow!

We have a simple program written in a tiny language with three commands: add, which increments a variable x by 1; for n, which starts a loop that repeats the commands inside it n times; and end, which closes a loop.

codeforcescompetitive-programmingdata-structuresexpression-parsingimplementation
CF 1176F - Destroy it!

We are given a sequence of turns in a card game. On each turn, the player receives a set of cards, each with a cost and a damage value. The player can play any subset of cards in that turn as long as the total cost does not exceed 3. After the turn, unused cards are discarded.

codeforcescompetitive-programmingdpimplementationsortings
CF 1176A - Divide it!

We are given a starting integer and we are allowed to repeatedly shrink it using a small fixed set of divisibility operations. Each operation replaces the current value with a smaller value, but only if the current value is divisible by a specific number: 2, 3, or 5.

codeforcescompetitive-programmingbrute-forcegreedyimplementation
CF 1177B - Digits Sequence (Hard Edition)

We are asked to consider the infinite string formed by writing all positive integers consecutively without any separators: "1234567891011121314…". Given a position $k$, we must determine which digit occupies that place.

codeforcescompetitive-programmingbinary-searchdivide-and-conquerimplementation
CF 1178F1 - Short Colorful Strip

The final strip consists of n unit segments, and because n = m in this subtask, every colour from 1 to n appears exactly once. The input array is simply a permutation describing the visible colour on each unit segment after all repainting operations have finished.

codeforcescompetitive-programmingcombinatoricsdfs-and-similardp
CF 1178B - WOW Factor

We are given a string made only of two characters, v and o. We need to count how many subsequences of this string form the pattern "wow". A subsequence means we pick indices in increasing order, not necessarily contiguous, and read the characters at those positions.

codeforcescompetitive-programmingdpstrings
CF 1178A - Prime Minister

There are several political parties, and the first party belongs to Alice. She wants to form a coalition that always contains her own party and may contain some additional parties. The coalition must control more than half of all seats in parliament.

codeforcescompetitive-programminggreedy
CF 1179A - Valeriy and Deque

We are given a deque containing n integers. Valeriy repeatedly performs an operation where he removes the first two elements, compares them, and then reinserts them: the larger of the two goes to the front, and the smaller goes to the back.

codeforcescompetitive-programmingdata-structuresimplementation
CF 1179C - Serge and Dining Room

We are tasked with simulating a school dining room where each dish has a single copy and each pupil buys the most expensive dish they can afford. Serge, our protagonist, wants to know which dish he will get if he waits until all pupils have made their purchases.

codeforcescompetitive-programmingbinary-searchdata-structuresgraph-matchingsgreedyimplementationmathtrees
CF 1180A - Alex and a Rhombus

We are given a shape that grows on a grid starting from a single cell. At the first stage there is exactly one cell. At every next stage, the shape expands by attaching every grid cell that shares an edge with any cell already in the shape.

codeforcescompetitive-programmingdpimplementationmath
CF 1181E1 - A Story of One Country (Easy)

We are given n castles on a 2D plane, each represented by an axis-aligned rectangle with integer coordinates. Each castle originally belonged to a country whose territory was also a rectangle.

codeforcescompetitive-programmingbrute-forcedivide-and-conquersortings
CF 1181B - Split a Number

We are given a long positive integer as a string of digits, and we need to split it into two non-empty integers such that neither starts with a zero. The goal is to minimize the sum of these two integers after splitting.

codeforcescompetitive-programminggreedyimplementationstrings
CF 1182D - Complete Mirror

We are given a tree with $n$ vertices, described by $n-1$ edges. A tree is a connected graph without cycles. The task is to choose a vertex as a root such that all vertices at the same distance from the root have the same degree, where degree counts the number of edges…

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similardphashingimplementationtrees
CF 1182A - Filling Shapes

We have a board with 3 rows and $n$ columns. The only pieces available are dominoes of size $2 times 1$, which may be placed either vertically or horizontally.

codeforcescompetitive-programmingdpmath
CF 1183E - Subsequences (easy version)

We start with a string and want to build a set containing exactly k distinct subsequences. Adding a subsequence of length L costs the number of removed characters, which is n - L. The same subsequence cannot be added twice.

codeforcescompetitive-programmingdpgraphsimplementationshortest-paths
CF 1183A - Nearest Interesting Number

We are given a positive integer and we want to find the smallest integer that is not smaller than it such that the sum of its digits is divisible by 4.

codeforcescompetitive-programmingimplementation
CF 1184D1 - Parallel Universes (Easy)

We have a line of universes arranged sequentially, each numbered from 1 to $n$, with the Doctor starting at position $k$. The multiverse can change over time according to a series of operations.

codeforcescompetitive-programmingimplementation
CF 1184C3 - Heidi and the Turing Test (Hard)

We are given a set of noisy points in the plane that lie close to a small number of circles, or rings. Each ring has a center and a radius, and each sampled point deviates slightly from the exact circumference.

codeforcescompetitive-programming
CF 1184A1 - Heidi Learns Hashing (Easy)

The problem gives us a function $H(x, y) = x^2 + 2xy + x + 1$, and a positive integer $r$. We need to determine whether there exists a pair of positive integers $(x, y)$ such that $H(x, y) = r$.

codeforcescompetitive-programmingbrute-forcemathnumber-theory
CF 1184B2 - The Doctor Meets Vader (Medium)

The galaxy is a small graph of planets connected by wormholes, where distance between planets is measured as the minimum number of edges in this graph. On top of this infrastructure, there are two kinds of actors: empire ships and rebel bases.

codeforcescompetitive-programmingflowsgraph-matchingsgraphsshortest-pathssortings
CF 1184A2 - Heidi Learns Hashing (Medium)

We are given a binary string y of length n. We want to count how many cyclic shift amounts k produce a situation where we can reconstruct some binary string x such that if we take x and XOR it with a circular right shift of itself by k, we obtain exactly y.

codeforcescompetitive-programmingbrute-forcenumber-theory
CF 1185D - Extra Element

We are given a sequence of integers that may not be ordered, and we are asked to identify a single element whose removal allows the remaining numbers to form an arithmetic progression.

codeforcescompetitive-programmingimplementationmath
CF 1185F - Two Pizzas

We are asked to help a group of friends pick exactly two pizzas so that the maximum number of friends are satisfied with the choice.

codeforcescompetitive-programmingbitmasksbrute-force
CF 1185C1 - Exam in BerSU (easy version)

We are given a sequence of students, each associated with a fixed amount of time they would spend if they successfully pass their exam.

codeforcescompetitive-programminggreedysortings
CF 1185B - Email from Polycarp

The task is to verify whether a typed word t could plausibly result from pressing the keys of a word s on a keyboard that occasionally repeats letters. Each letter in s must appear in order in t, but it may appear one or more times consecutively.

codeforcescompetitive-programmingimplementationstrings
CF 1186C - Vus the Cossack and Strings

We are given a long binary string a and a shorter or equal-length binary string b. We slide b across every possible window of a of the same length, and for each position we compare the two strings character by character.

codeforcescompetitive-programmingimplementationmath
CF 1187B - Letters Shop

We are given a string s representing a sequence of letters available in a shop, arranged from left to right. Each customer (friend) wants to buy letters to form their name, but they can only purchase a prefix of the shop letters.

codeforcescompetitive-programmingbinary-searchimplementationstrings
CF 1188B - Count Pairs

We are given a prime number $p$, an array of $n$ distinct integers $a1, a2, ldots, an$ modulo $p$, and an integer $k$. Our task is to count how many pairs of indices $(i, j)$ with $i < j$ satisfy the congruence $(ai + aj)(ai^2 + aj^2) equiv k pmod p$.

codeforcescompetitive-programmingmathmatricesnumber-theorytwo-pointers
CF 1188E - Problem from Red Panda

We start with a collection of balloons split across $k$ colors. Each color has some initial count, and the total number of balloons is at most one million.

codeforcescompetitive-programmingcombinatorics
CF 1188A1 - Add on a Tree

We are given a tree of $n$ nodes where initially every edge has a value of 0. We can perform operations that select any two distinct leaf nodes and add a real number $x$ to every edge along the unique path connecting those two leaves.

codeforcescompetitive-programmingtrees
CF 1189A - Keanu Reeves

We are given a binary string, which is a sequence of characters containing only 0 and 1. A string is defined as good if the count of zeros differs from the count of ones.

codeforcescompetitive-programmingstrings
CF 1189B - Number Circle

We are given a multiset of numbers and asked whether we can place all of them around a circle so that every element is strictly smaller than the sum of its two adjacent elements. The adjacency is circular, so the first and last elements are also neighbors.

codeforcescompetitive-programminggreedymathsortings
CF 1190F - Tokitsukaze and Powers

We are asked to generate a set of possible passwords under very specific rules. The lock accepts integers between 0 and m-1.

codeforcescompetitive-programmingnumber-theoryprobabilities
CF 1190B - Tokitsukaze, CSL and Stone Game

We are given a collection of piles of stones, each pile containing a non-negative integer number of stones. Two players take turns removing exactly one stone from a pile. Tokitsukaze goes first.

codeforcescompetitive-programminggames
CF 1191B - Tokitsukaze and Mahjong

We are given exactly three mahjong tiles. Each tile consists of a number from 1 to 9 and a suit, where the suit is one of m, p, or s. A winning hand in this simplified game only requires the existence of a single mentsu.

codeforcescompetitive-programmingbrute-forceimplementation
CF 1192A - Building Skyscrapers

We are given a set of points on an infinite grid. Each point represents a building site that must eventually be occupied by a skyscraper. We must decide an order to construct these skyscrapers one by one. Two constraints govern whether a building step is valid.

codeforcescompetitive-programming*special
CF 1194F - Crossword Expert

We are asked to calculate the expected number of crosswords Adilbek can fully solve in a fixed amount of time, given that each crossword takes either ti or ti + 1 seconds independently with equal probability.

codeforcescompetitive-programmingcombinatoricsdpnumber-theoryprobabilitiestwo-pointers
CF 1194C - From S To T

We are given three strings s, t, and p. We can repeatedly take any character from p and insert it anywhere in s. The goal is to determine if, after some sequence of such insertions, s can become exactly equal to t.

codeforcescompetitive-programmingimplementationstrings
CF 1195D2 - Submarine in the Rybinsk Sea (hard edition)

We are given a list of integers, and we repeatedly apply a digit interleaving operation on every ordered pair of numbers in the list, including pairs where both elements are the same.

codeforcescompetitive-programmingcombinatoricsmathnumber-theory
CF 1195C - Basketball Exercise

We are given two horizontal lines of students, each line containing the same number of people. Each student has a height, and we want to build a team by selecting students from these two rows under a strict ordering rule: once we start selecting from left to right, we can…

codeforcescompetitive-programmingdp
CF 1196A - Three Piles of Candies

Each query gives three piles of candies. Alice must take one whole pile, Bob must take one of the remaining piles, and the last pile can be split arbitrarily between them.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsmath
CF 1197C - Array Splitting

We are given a non-decreasing array and asked to split it into exactly $k$ contiguous parts. Each part contributes a cost equal to the difference between its largest and smallest element, and since the array is sorted, this is simply the difference between its last and first…

codeforcescompetitive-programminggreedysortings
CF 1198F - GCD Groups 2

We are given a list of integers and must split it into two non-empty groups. The requirement is not about sums or sizes, but about multiplicative structure: in each group, if you take the greatest common divisor of all its elements, the result must be exactly one.

codeforcescompetitive-programminggreedynumber-theoryprobabilities
CF 1199A - City Day

We are given a sequence of daily rainfall amounts over the summer, and we need to find the earliest day that is “not-so-rainy.

codeforcescompetitive-programmingimplementation
CF 1200E - Compress Words

We are given a sequence of words forming a sentence, and the task is to compress them into a single string by merging them left to right.

codeforcescompetitive-programmingbrute-forcehashingimplementationstring-suffix-structuresstrings
CF 1200B - Block Adventure

In Block Adventure, we have a row of columns with different heights. The player starts on the first column and must reach the last one.

codeforcescompetitive-programmingdpgreedy
CF 1200C - Round Corridor

The corridor is essentially two separate circular rings placed one inside the other. The inner ring is split into n equal rooms arranged in a cycle, and the outer ring is split into m equal rooms arranged in another cycle.

codeforcescompetitive-programmingmathnumber-theory
CF 1201E1 - Knightmare (easy)

We are given a small chessboard and two knights placed on it. One knight is white and moves first, the other is black. On each turn, a player moves their own knight using standard knight moves. The interaction continues until one side wins or 350 moves are reached.

codeforcescompetitive-programminggraphsinteractiveshortest-paths
CF 1201A - Important Exam

Each student answers a multiple-choice test with $m$ questions, where each question has five possible options. We are given the full answer sheet of every student, but the correct answers are unknown.

codeforcescompetitive-programmingimplementationstrings
CF 1202F - You Are Given Some Letters...

We are asked to construct strings made only of two characters, say A and B, where the total number of A’s is fixed to a and the total number of B’s is fixed to b.

codeforcescompetitive-programmingbinary-searchimplementationmath
CF 1203F1 - Complete the Projects (easy version)

Polycarp is a freelancer with an initial rating r. He has a list of projects, each project defined by two numbers: the minimum rating required to start it, and the rating change after completion, which could be positive or negative.

codeforcescompetitive-programminggreedy
CF 1203E - Boxers

We are given a set of boxers, each with a positive integer weight. Each boxer can adjust their weight by at most 1, either up or down, but the weight must remain strictly positive.

codeforcescompetitive-programminggreedysortings
CF 1203B - Equal Rectangles

We are given 4n sticks. Every rectangle requires four sticks: two sticks for one side length and two sticks for the other side length. Every stick must be used exactly once. The goal is to split all sticks into exactly n rectangles such that every rectangle has the same area.

codeforcescompetitive-programminggreedymath
CF 1203C - Common Divisors

We are asked to find the number of positive integers that evenly divide every number in a given array. The array can contain up to 400,000 elements, each of which can be as large as $10^{12}$. Conceptually, we are looking for the set of common divisors of all array elements.

codeforcescompetitive-programmingimplementationmath
CF 1204A - BowWow and the Timetable

The trains leave at times $$1, 4, 16, 64, dots$$ which are exactly the powers of 4. Given a time $s$, we need to count how many of these departure times are strictly smaller than $s$. The unusual part is that $s$ is not given in decimal.

codeforcescompetitive-programmingmath
CF 1204C - Anna, Svyatoslav and Maps

We are given a directed graph represented as an adjacency matrix, where each vertex has edges to other vertices, but no vertex has a loop to itself. Along with the graph, we are also given a path p as a sequence of vertex indices.

codeforcescompetitive-programmingdpgraphsgreedyshortest-paths
CF 1205E - Expected Value Again

We are looking at strings of length $n$ built from an alphabet of size $k$, chosen uniformly at random. For any fixed string, we examine how many of its prefixes also appear as suffixes of the same length.

codeforcescompetitive-programmingcombinatoricsstrings
CF 1205B - Shortest Cycle

We are given a collection of integers, and we interpret each integer as a node in a graph. Two nodes are connected when their bitwise AND is non-zero, meaning they share at least one common bit set to 1.

codeforcescompetitive-programmingbitmasksbrute-forcegraphsshortest-paths
CF 1206B - Make Product Equal One

We are given an array of integers. In one operation, we may choose any element and either increase it by 1 or decrease it by 1. Each such change costs one coin.

codeforcescompetitive-programmingdpimplementation
CF 1207F - Remainder Problem

We are maintaining a very large array indexed from 1 to 500000, initially all zeros, and we support two operations. The first operation adds a value to a single position.

codeforcescompetitive-programmingbrute-forcedata-structuresimplementation
CF 1207B - Square Filling

We are working with a binary grid transformation problem. There is a target grid A filled with zeros and ones, and a second grid B which starts completely empty.

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementation
CF 1208H - Red Blue Tree

The tree defines a bottom-up majority-like rule where only leaves carry fixed information and every internal node derives its state from its children.

codeforcescompetitive-programmingdata-structuresimplementationtrees
CF 1208E - Let Them Slide

We are given a table with n rows and w columns. Each row contains an array that can be slid left or right within its row, but it must remain fully inside the table and occupy consecutive columns. The arrays can have different lengths, and some elements can be negative.

codeforcescompetitive-programmingdata-structuresimplementation
CF 1208A - XORinacci

We are asked to compute a sequence similar to Fibonacci numbers, but instead of summing the previous two terms, each term is obtained by applying the bitwise XOR operation to the two previous terms.

codeforcescompetitive-programmingmath
CF 1209H - Moving Walkways

We are asked to move along a straight line from position 0 to position L. The segment is split into ordinary parts and several disjoint special intervals called walkways. Each walkway covers a subsegment $[xi, yi]$ and provides a constant speed bonus $si$.

codeforcescompetitive-programmingdata-structuresgreedymath
CF 1209G1 - Into Blocks (easy version)

We are asked to transform a given sequence of integers into a "nice" sequence. A sequence is nice if all occurrences of the same number appear in contiguous blocks. For example, [3, 3, 1, 1, 2] is nice, but [3, 1, 3] is not because the 3s are split by 1.

codeforcescompetitive-programmingdata-structuresdsugreedyimplementationtwo-pointers
CF 1209E1 - Rotate Columns (easy version)

We are given a matrix with n rows and m columns, where each entry is a positive integer. We can pick any column and rotate it cyclically any number of times. After performing such rotations, we consider each row and take the maximum value in that row.

codeforcescompetitive-programmingbitmasksbrute-forcedpgreedysortings
CF 1209A - Paint the Numbers

We are given a list of integers, and we want to partition them into as few groups as possible. Each group has a structural constraint: if you look at the smallest number inside that group, every other number assigned to the same group must be divisible by that smallest number.

codeforcescompetitive-programminggreedyimplementationmath
CF 1210E - Wojtek and Card Tricks

We have a small deck of $k$ cards, numbered 1 through $k$, and Wojtek knows $n$ different deterministic shuffles (permutations) of the deck. Each shuffle specifies exactly where each card ends up.

codeforcescompetitive-programmingmath
CF 1210C - Kamil and Making a Stream

We have a rooted tree with root at vertex 1. Every vertex stores a value x[v]. For any ancestor-descendant pair (u, v), we look at the path from u down to v and compute the gcd of all values on that path.

codeforcescompetitive-programmingmathnumber-theorytrees
CF 1210A - Anadi and Domino

We are given a very small graph with at most 7 vertices, and a fixed “palette” of 21 dominoes. Each domino corresponds to an unordered pair of values from 1 to 6, so a domino is really a pair like (1,1), (1,2), …, (6,6), with exactly one copy of each pair available.

codeforcescompetitive-programmingbrute-forcegraphs
CF 1211F - kotlinkotlinkotlinkotlin...

We are given a collection of string fragments. Originally, all of them came from cutting a long string that consisted of the word "kotlin" repeated several times. After the cuts, the fragments were shuffled.

codeforcescompetitive-programming*specialgraphsimplementationstrings
CF 1211B - Traveling Around the Golden Ring of Berland

We are asked to plan the minimum number of visits for a tourist traveling along a fixed cyclic route of cities. The cities are numbered from 1 to n, arranged in a cycle, and the traveler always moves forward: from city i to i+1, and from city n back to city 1.

codeforcescompetitive-programming*specialimplementation
CF 1213D2 - Equalizing by Division (hard version)

We are given an array of integers, and we can repeatedly pick any number and divide it by two, rounding down. The goal is to find the minimum number of such operations required to make at least $k$ numbers in the array equal.

codeforcescompetitive-programmingbrute-forcemathsortings
CF 1213C - Book Reading

We are asked to compute a sum of last digits of page numbers divisible by a given integer. Polycarp reads a book with pages numbered from 1 to n. Every page number divisible by m gets recorded, but only its last digit is written.

codeforcescompetitive-programmingmath
CF 1213B - Bad Prices

We are given several independent experiments, and each experiment consists of a sequence of daily prices of a product.

codeforcescompetitive-programmingdata-structuresimplementation
CF 1214F - Employment

We have two multisets of points on a circle of length m. The first set contains the office locations. Office i is located in city a[i]. The second set contains the candidates. Candidate j lives in city b[j].

codeforcescompetitive-programminggreedysortings
CF 1214G - Feeling Good

We are given a two-dimensional grid representing a chameleon's body. Initially, all cells are green. Each cell can be either green or blue, and the color may be flipped multiple times. Each flip affects a contiguous horizontal segment of a single row.

codeforcescompetitive-programmingbitmasksdata-structures
CF 1214A - Optimal Currency Exchange

We start with a fixed amount of money in rubles and want to convert it into foreign currency using an exchange office that sells only fixed denominations of dollar bills and euro bills. Each dollar costs a fixed amount in rubles, and each euro also has its own fixed ruble price.

codeforcescompetitive-programmingbrute-forcemath
CF 1214C - Bad Sequence

We are given a string of parentheses, like "(()))(" or ")(", and we need to determine whether moving at most one bracket to a different position can make it a correct bracket sequence.

codeforcescompetitive-programmingdata-structuresgreedy
CF 1215E - Marbles

We are given a long row of marbles, each painted with one of at most 20 colors. The only allowed move is swapping two adjacent marbles, and we want to use as few swaps as possible. The goal is not to sort the marbles in the usual sense.

codeforcescompetitive-programmingbitmasksdp
CF 1215F - Radio Stations

We are asked to assign a signal power to a set of radio stations and choose a subset of these stations such that all citizen complaints are satisfied, no two stations interfere, and each chosen station's signal power falls within its allowed range.

codeforcescompetitive-programming2-sat