brain

tamnd's digital brain — notes, problems, research

43815 notes

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
CF 1215C - Swap Letters

We are given two strings, s and t, of equal length composed only of the letters "a" and "b". The task is to make s and t identical using a sequence of allowed swap operations. Each operation lets us pick one character from s and one from t and swap them.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1215A - Yellow Cards

In this problem, we have two football teams playing a match. Each team starts with a certain number of players, denoted by a1 and a2. Throughout the match, the referee shows n yellow cards to players.

codeforcescompetitive-programminggreedyimplementationmath
CF 1216F - Wi-Fi

We have a line of rooms numbered from 1 to n. Every room must end up connected to the Internet. There are two ways to achieve that. A room can be connected directly, paying a cost equal to its index. Connecting room i directly costs i.

codeforcescompetitive-programmingdata-structuresdpgreedy
CF 1216E2 - Numerical Sequence (hard version)

The sequence is built by concatenating “blocks”. The first block is just the string “1”. The second block is “12”.

codeforcescompetitive-programmingbinary-searchmath
CF 1216C - White Sheet

We are given three rectangles on a plane aligned with the axes. The first rectangle is a white sheet, and two subsequent rectangles are black sheets. Each rectangle is defined by its bottom-left and top-right coordinates.

codeforcescompetitive-programminggeometrymath
CF 1216B - Shooting

We are given a line of cans, each with a durability value. Vasya has to shoot all cans exactly once, but the number of shots required to knock down a can depends on how many cans have already been knocked down.

codeforcescompetitive-programminggreedyimplementationsortings
CF 1217C - The Number Of Good Substrings

We are given a binary string and asked to count its "good" substrings. A substring is good if its length equals the decimal value of its binary representation, allowing leading zeros.

codeforcescompetitive-programmingbinary-searchbitmasksbrute-force
CF 1220C - Substring Game in the Lesson

We are given a string s and we need to predict the outcome of a two-player game for each starting position k in the string. The game begins with a substring consisting of a single character at position k.

codeforcescompetitive-programminggamesgreedystrings
CF 1221G - Graph And Numbers

We have an undirected graph. Every vertex must be assigned either 0 or 1. For each edge, we write the sum of the values on its two endpoints.

codeforcescompetitive-programmingbitmasksbrute-forcecombinatoricsdpmeet-in-the-middle
CF 1221A - 2048 Game

We are given several independent game states. Each state consists of tiles whose values are powers of two. In one move, we may pick two tiles with the same value and merge them into a single tile whose value is their sum.

codeforcescompetitive-programmingbrute-forcegreedymath
CF 1223C - Save the Nature

We have a collection of ticket prices, and we are free to choose the order in which tickets are sold. Two donation programs exist. Every a-th sold ticket contributes x% of its price, and every b-th sold ticket contributes y% of its price.

codeforcescompetitive-programmingbinary-searchgreedy
CF 1225G - To Make 1

We have a set of $n$ positive integers on a blackboard and a number $k ge 2$. None of the integers is divisible by $k$. We are allowed to repeatedly pick any two numbers $x$ and $y$, erase them, and write $f(x+y)$ instead.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsdpgreedynumber-theory
CF 1225B2 - TV Subscriptions (Hard Version)

We are given the TV schedule for the next n days. Each day broadcasts an episode from exactly one show, represented by an integer. A subscription is purchased per show, not per episode. If we subscribe to show x, we can watch every occurrence of x in the schedule.

codeforcescompetitive-programmingimplementationtwo-pointers
CF 1228C - Primes and Multiplication

We are asked to compute a product over a sequence of numbers derived from a pair of integers $x$ and $n$. The function $f(x, y)$ looks at all prime factors of $x$ and for each such prime $p$ determines the largest power of $p$ that divides $y$.

codeforcescompetitive-programmingmathnumber-theory
CF 1234E - Special Permutations

We are given a sequence x of length m. For every value i from 1 to n, we construct a special permutation: pi = [i, 1, 2, ..., i-1, i+1, ..., n] This permutation differs from the identity permutation only because the value i has been moved to the front.

codeforcescompetitive-programmingmath
CF 1234B1 - Social Network (easy version)

We are simulating the behavior of a smartphone chat interface. The smartphone screen can show at most $k$ conversations. Each incoming message comes from a friend identified by a unique ID. If a conversation with that friend is already on the screen, the screen does not change.

codeforcescompetitive-programmingimplementation
CF 1238F - The Maximum Subtree

We are given a tree and need to find the largest connected subgraph that can be represented as an intersection graph of line segments on a line.

codeforcescompetitive-programmingdfs-and-similardpgraphstrees
CF 1238A - Prime Subtraction

We are given two integers, x and y, with x y. The task is to determine whether it is possible to choose a single prime number p and repeatedly subtract it from x until we reach y. Importantly, once a prime is chosen, it must be used exclusively; we cannot switch primes mid-way.

codeforcescompetitive-programmingmathnumber-theory
CF 1239A - Ivan the Fool and the Probability Theory

We are asked to count the number of "random pictures" of size $n times m$, where each cell is either black or white. A picture is considered random under Ivan's definition if every cell has at most one adjacent cell of the same color. Here, adjacency is horizontal or vertical.

codeforcescompetitive-programmingcombinatoricsdpmath
CF 1250J - The Parade

We are asked to arrange soldiers of various heights into a parade formation with exactly $k$ rows. Each row must have the same number of soldiers, and within a row, no two soldiers can differ in height by more than one.

codeforcescompetitive-programmingbinary-searchgreedy
CF 1252G - Performance Review

We are tracking whether a single employee, Randall, remains employed after a sequence of yearly “pruning” operations in a company where employees are ranked by a fixed performance value. The company always keeps exactly $N$ employees.

codeforcescompetitive-programmingdata-structures
CF 1252B - Cleaning Robots

We are given a tree with $N$ junctions and $N-1$ roads connecting them. A tree means that every pair of junctions is connected by exactly one path.

codeforcescompetitive-programmingdptrees
CF 1252A - Copying Homework

We are given a permutation of integers from 1 to N, which represents Danang's completed homework. Darto wants to submit his own permutation, different enough from Danang's, but still using numbers 1 through N exactly once.

codeforcescompetitive-programming
CF 1253B - Silly Mistake

There is not enough information to diagnose the bug or provide a corrected solution. The sample with expected output appears to belong to a string construction problem, but you have not provided: - the problem statement, - the original Python solution, - or even the name of…

codeforcescompetitive-programminggreedyimplementation
CF 1253C - Sweets Eating

We are given a list of sweets, each with a positive integer value representing its sweetness level. Yui wants to eat exactly $k$ sweets for each $k$ from 1 to $n$. However, she cannot eat more than $m$ sweets in a single day. Time is divided into days starting from day 1.

codeforcescompetitive-programmingdpgreedymathsortings
CF 1254B1 - Send Boxes to Alice (Easy Version)

We are asked to rearrange chocolates among boxes so that Alice will be happy. Each of the $n$ boxes has either zero or one chocolate, and at least one box contains a chocolate.

codeforcescompetitive-programmingconstructive-algorithmsgreedymathnumber-theoryternary-searchtwo-pointers
CF 1255A - Changing Volume

There is not enough information to diagnose the bug or provide a corrected solution. The sample with expected output appears to belong to a string construction problem, but you have not provided: - the problem statement, - the original Python solution, - or even the name of…

codeforcescompetitive-programmingmath
CF 1256A - Payment Without Change

We are asked to determine whether a target sum S can be constructed using two types of coins. One type has value n and there are a coins of it, the other type has value 1 and there are b coins of it.

codeforcescompetitive-programmingmath
CF 1257G - Divisor Set

The input does not give the number directly. Instead, it gives its prime factorization as a list of prime factors, where equal primes may appear many times. Suppose a prime $q$ appears $c$ times. Then every divisor chooses an exponent between $0$ and $c$ for that prime.

codeforcescompetitive-programmingdivide-and-conquerfftgreedymathnumber-theory
CF 1257E - The Contest

We have three participants and a set of problems numbered from 1 to n. Each participant currently holds some subset of problems, but the subsets may not respect the desired division: the first participant should hold a prefix of the problems, the third participant should hold…

codeforcescompetitive-programmingdata-structuresdpgreedy
CF 1257A - Two Rival Students

We have a line of students numbered from 1 to n. Among them, two students are rivals, located at positions a and b. The gym teacher wants to maximize the distance between these two students, where distance is simply the absolute difference of their positions.

codeforcescompetitive-programminggreedymath
CF 1260F - Colored Tree

We are given a tree where each vertex does not have a fixed color. Instead, every vertex has a range of possible colors, and we imagine choosing one integer color independently for each vertex within its allowed interval.

codeforcescompetitive-programmingdata-structurestrees
CF 1260C - Infinite Fence

There is not enough information to diagnose the bug or provide a corrected solution. The sample with expected output appears to belong to a string construction problem, but you have not provided: - the problem statement, - the original Python solution, - or even the name of…

codeforcescompetitive-programminggreedymathnumber-theory
CF 1260A - Heating

We are given a house with n rooms. For each room, we know two numbers: ci, the maximum number of radiators we can install, and sumi, the total number of radiator sections required to adequately heat that room.

codeforcescompetitive-programmingmath
CF 1263F - Economic Difficulties

We have two independent electrical grids in a palace, each forming a rooted tree with node 1 as the head. The trees supply electricity to devices through their leaves.

codeforcescompetitive-programmingdata-structuresdfs-and-similardpflowsgraphstrees