#math
CF 1725E - Electrical Efficiency
CF 1725E - Electrical Efficiency Rating: 2500 Tags: combinatorics, data structures, dp, math, number theory, trees Solve time: 1m 44s Verified: yes Solution Problem Understanding We are given a tree of $N$ factories. Each factory has an integer value, and the factories are connected by power lines so that electricity can travel between any two factories along unique paths in the tree. For any triple of distinct factories $(x, y,...
CF 1725G - Garage
CF 1725G - Garage Rating: 1500 Tags: binary search, geometry, math Solve time: 1m 43s Verified: yes Solution Problem Understanding We are asked to generate an infinite increasing sequence of positive integers called “suitable” numbers. A number is suitable if it can be realized as the area of a square that appears in a specific geometric construction involving a right triangle attached to it, where the triangle has integer leg...
CF 1267K - Key Storage
CF 1267K - Key Storage Rating: 2100 Tags: combinatorics, math Solve time: 2m 26s Verified: no Solution Problem Understanding A key is transformed into a sequence by repeatedly dividing it by growing divisors starting from 2. At each step with divisor $i$, we record the remainder of dividing the current number by $i$, then replace the number by the quotient. The process continues with $i = 2, 3, 4, \dots$...
CF 1267G - Game Relics
CF 1267G - Game Relics Rating: 3000 Tags: math, probabilities Solve time: 1m 28s Verified: no Solution Problem Understanding We are given a collection of $n$ distinct items called relics. Each relic $i$ can be obtained in two ways: either by directly purchasing it at a fixed cost $c_i$, or by paying a fixed cost $x$ to receive a uniformly random relic among all $n$, where duplicates do not help...
CF 1252K - Addition Robot
CF 1252K - Addition Robot Rating: 2100 Tags: data structures, math, matrices Solve time: 1m 52s Verified: no Solution Problem Understanding The robot stores a binary instruction string over the alphabet {A, B}. When we process this string with an initial pair of values (A, B) , each character acts like a small transformation step. If the current character is A , the second value is added into the first,...
CF 1250B - The Feast and the Bus
CF 1250B - The Feast and the Bus Rating: 1800 Tags: brute force, constructive algorithms, greedy, math Solve time: 1m 44s Verified: no Solution Problem Understanding We are given a collection of employees, where each employee belongs to exactly one team. The only meaningful structure in the input is the frequency of each team, since employees from the same team must always travel together. The transportation rules impose a strict...
CF 958D1 - Hyperspace Jump (easy) Rating: 1400 Tags: expression parsing, math Model: gpt-5-3-mini Solve time: 1m 35s Verified: yes (1/1 samples) Share: https://chatgpt.com/share/6a339d94-f784-83ec-a7e6-3815fd55bbe8 Solution Problem Understanding Each ship independently computes a target coordinate from a short arithmetic expression of the form “(a + b) / c”, where a, b, and c are small positive integers. After evaluating this expression, the result is a rational number. Ships that obtain exactly...
CF 1040B - Shashlik Cooking Rating: 1300 Tags: dp, greedy, math Model: gpt-5-3-mini Solve time: 1m 25s Verified: no (0/1 samples) Share: https://chatgpt.com/share/6a33b8ae-772c-83ec-a3d7-73b862c99c7f Solution Problem Understanding We are given a line of $n$ skewers arranged from left to right. Each skewer has a binary state: either it is still in its initial state or it has been flipped. A single operation is performed by choosing a position $i$. That operation...
CF 983A - Finite or not? Rating: 1700 Tags: implementation, math Model: gpt-5-5 Solve time: 1m 7s Verified: yes (1/1 samples) Share: https://chatgpt.com/share/6a33757e-78f4-83ec-b62c-055c2636f4e3 Solution Problem Understanding We are given a rational number $p/q$ and asked to determine whether its representation is finite when written in base $b$. A finite representation means that after some point, the expansion stops and no further digits are needed, similar to how $1/2 = 0.5$...
CF 963E - Circles of Waiting Rating: 3100 Tags: math Model: gpt-5-3-mini Solve time: 2m 12s Verified: yes (1/1 samples) Share: https://chatgpt.com/share/6a33a384-da9c-83ec-970d-7257bd131e0d Solution Problem Understanding A chip starts at the origin of the integer grid. Every second it performs a single random move in one of the four cardinal directions: left, down, right, or up, with probabilities derived from the input parameters. The motion is memoryless and independent across steps....
CF 931C - Laboratory Work Rating: 1700 Tags: implementation, math Model: gpt-5-3-mini Solve time: 1m 27s Verified: yes (1/1 samples) Share: https://chatgpt.com/share/6a327606-d3c4-83ec-8000-99ae5512713a Solution Problem Understanding We are given a multiset of integers representing Kirill’s measurements. All values are very tightly clustered: every value lies within an interval of length at most two, so after shifting, the data contains only three possible integers at most. Anya must construct another multiset of...
CF 963A - Alternating Sum Rating: 1800 Tags: math, number theory Model: gpt-5-3-mini Solve time: 1m 22s Verified: yes (1/1 samples) Share: https://chatgpt.com/share/6a328192-f20c-83ec-a3a9-4d043e415a76 Solution Problem Understanding We are given a long weighted sum where each position contributes a power of two independent bases. At index $i$, the contribution is either $+1$ or $-1$, multiplied by $a^{n-i} b^i$. The sequence of signs is not arbitrary for all $n+1$ positions, instead only...
CF 932E - Team Work Rating: 2400 Tags: combinatorics, dp, math Model: gpt-5-3-mini Solve time: 1m 26s Verified: yes (1/1 samples) Share: https://chatgpt.com/share/6a3276bd-8288-83ec-a06b-8326cbcd5f3b Solution Problem Understanding We are asked to evaluate a combinatorial sum over all non-empty subsets of a set of size $N$. Every subset contributes a cost that depends only on its size: if a subset contains $x$ elements, its cost is $x^k$. The final answer is the...
CF 930E - Coins Exhibition
CF 930E - Coins Exhibition Rating: 2900 Tags: data structures, dp, math Solve time: 1m 56s Verified: no Solution Problem Understanding We are given a line of $k$ coins, each independently oriented either “obverse” (call it O) or “reverse” (call it R). A full configuration is simply a binary string of length $k$, but $k$ can be extremely large, so we cannot enumerate configurations. Two people remember constraints coming from...
CF 931A - Friends Meeting
CF 931A - Friends Meeting Rating: 800 Tags: brute force, greedy, implementation, math Solve time: 1m 8s Verified: yes Solution Problem Understanding Two people stand on a number line at integer coordinates $a$ and $b$. They want to end up at the same integer position, and each of them can move one step left or right any number of times. The twist is that movement cost is not linear. If...
CF 958E1 - Guard Duty (easy)
CF 958E1 - Guard Duty (easy) Rating: 1600 Tags: brute force, geometry, greedy, math Solve time: 39s Verified: yes Solution Problem Understanding We are given two small point sets in the plane, one representing Rebel ships and the other representing bases. Each ship must be assigned to exactly one base, and each base must also receive exactly one ship, so the assignment is a bijection between the two sets. Once...
CF 960G - Bandit Blues
CF 960G - Bandit Blues Rating: 2900 Tags: combinatorics, dp, fft, math Solve time: 2m 32s Verified: yes Solution Problem Understanding We are given a permutation of the numbers from 1 to N, and we simulate a simple “record-breaking” process on it. We start with a virtual value 0. Scanning from left to right, we maintain the maximum value seen so far; every time we encounter a number larger than...
CF 963C - Cutting Rectangle
CF 963C - Cutting Rectangle Rating: 2600 Tags: brute force, math, number theory Solve time: 1m 39s Verified: yes Solution Problem Understanding We are given a final collection of axis-aligned rectangles that come from cutting an unknown larger rectangle using only straight cuts parallel to its sides. Every cut is either horizontal or vertical, so the original rectangle is partitioned into a grid. If there are $p$ horizontal cuts and...
CF 964A - Splits
CF 964A - Splits Rating: 800 Tags: math Solve time: 1m 29s Verified: yes Solution Problem Understanding We are working with ways of writing an integer $n$ as a nonincreasing sequence of positive integers. In other words, we break $n$ into parts that never increase as we move to the right, and all parts must be positive. This is the same as a standard integer partition written in sorted form....
CF 964B - Messages
CF 964B - Messages Rating: 1300 Tags: math Solve time: 1m 19s Verified: yes Solution Problem Understanding We are given a sequence of messages that arrive over time. Each message arrives at a known minute and starts with a fixed value. After it appears, its value decreases linearly every minute until it is read, and once read it immediately contributes its current value to Vasya’s money. At the same time,...
CF 967B - Watering System
CF 967B - Watering System Rating: 1000 Tags: math, sortings Solve time: 1m 28s Verified: yes Solution Problem Understanding We are given a system of pipe holes, each hole having a fixed size that determines how much water it can drain when water is poured into the system. Arkady pours a fixed amount of water, but only one hole, the first one, is considered useful to him. His goal is...
CF 1017F - The Neutral Zone
CF 1017F - The Neutral Zone Rating: 2500 Tags: brute force, math Solve time: 3m 31s Verified: yes Solution Problem Understanding We are asked to evaluate a number-theoretic sum over all integers from 1 to $n$, where each integer contributes a value defined through its prime factorization. For a number $x$, we factor it as a product of primes $x = \prod p_i^{a_i}$. A function $f$ is defined on integers,...
CF 1017B - The Bits
CF 1017B - The Bits Rating: 1200 Tags: implementation, math Solve time: 1m 47s Verified: yes Solution Problem Understanding We are given two binary strings of equal length. You are allowed to pick any two positions in the first string and swap their bits. The second string stays fixed. After each swap, we recompute the bitwise OR of the two strings position by position, and we want to count how...
CF 1023B - Pair of Toys
CF 1023B - Pair of Toys Rating: 1000 Tags: math Solve time: 1m 52s Verified: yes Solution Problem Understanding We are given a range of toy prices that is completely regular: there are toys priced from 1 up to n, each integer price appearing exactly once. We want to count how many distinct unordered pairs of different toys have a combined price exactly equal to k. Each pair is determined...
CF 1025G - Company Acquisitions
CF 1025G - Company Acquisitions Rating: 3200 Tags: constructive algorithms, math Solve time: 4m 3s Verified: yes Solution Problem Understanding We are given a system of startups arranged into a structure where some startups are already “active” and others are “acquired” and attached to exactly one active startup. Each acquired startup forms a rooted tree of dependents under an active root, and every active startup is the root of its...
CF 1025D - Recovering BST
CF 1025D - Recovering BST Rating: 2100 Tags: brute force, dp, math, number theory, trees Solve time: 3m 32s Verified: yes Solution Problem Understanding We are given a sorted list of distinct integers, and we want to build a binary search tree using exactly these values as node keys. The in-order traversal of any valid BST with these keys is fixed and already matches the given order, so the only...
CF 1039C - Network Safety
CF 1039C - Network Safety Rating: 2200 Tags: dfs and similar, dsu, graphs, math, sortings Solve time: 8m 24s Verified: yes Solution Problem Understanding We are given a network of servers where each server has an integer label (an encryption key) in a fixed bit range. Some pairs of servers are connected, and a connection is considered safe only if the two endpoints currently hold different values. A virus is...
CF 1039A - Timetable
CF 1039A - Timetable Rating: 2300 Tags: constructive algorithms, data structures, greedy, math Solve time: 6m 10s Verified: no Solution Problem Understanding We are given a fixed sequence of departure times from station A, strictly increasing, and for each bus we also know a constraint on how “late” it can possibly appear in the arrival order at station B. The arrival station has an unknown strictly increasing timetable, and we...
CF 1725C - Circular Mirror
CF 1725C - Circular Mirror Rating: 2000 Tags: binary search, combinatorics, geometry, math, two pointers Solve time: 5m 43s Verified: no Solution Problem Understanding We are given a circle with lamps placed on its boundary in a fixed clockwise order. Between consecutive lamps we know the arc lengths, so the geometry of the circle is fully determined up to rotation. Any triple of lamps defines a triangle by taking their...
CF 1561D1 - Up the Strip (simplified version)
CF 1561D1 - Up the Strip (simplified version) Rating: 1700 Tags: brute force, data structures, dp, math, number theory Solve time: 5m 59s Verified: no Solution Problem Understanding We are standing on a vertical strip of numbered cells from 1 at the top down to n at the bottom. A token starts at cell n, and we repeatedly move it upward until it reaches cell 1. Each move is a...
CF 1558A - Charmed by the Game
CF 1558A - Charmed by the Game Rating: 1300 Tags: brute force, math Solve time: 5m 8s Verified: no Solution Problem Understanding We are given only the final match statistics of a tennis game: Alice has won a individual games and Borys has won b individual games. We do not know the order of these games, and we also do not know who served first. What we do know is...
CF 1553G - Common Divisor Graph
CF 1553G - Common Divisor Graph Rating: 2700 Tags: brute force, constructive algorithms, dsu, graphs, hashing, math, number theory Solve time: 3m 40s Verified: yes Solution Problem Understanding We are given a fixed set of nodes, each labeled by a distinct integer. Two nodes are connected if their labels share any prime factor. This means the graph is determined entirely by the prime factorizations of the given numbers. For each...
CF 1553F - Pairwise Modulo
CF 1553F - Pairwise Modulo Rating: 2300 Tags: data structures, math Solve time: 4m 38s Verified: no Solution Problem Understanding We are given a sequence of distinct positive integers. After reading the first k elements, we define a score p_k that aggregates the remainder produced by dividing every ordered pair (a_i, a_j) among the first k elements. In other words, for each prefix, we consider all possible pairs where the...
CF 1553E - Permutation Shift
CF 1553E - Permutation Shift Rating: 2100 Tags: brute force, combinatorics, constructive algorithms, dfs and similar, dsu, graphs, math Solve time: 4m 48s Verified: yes Solution Problem Understanding We start from the identity permutation, which is simply the numbers from 1 to n in order. Someone first rotates this array cyclically to the right by an unknown shift k, and then performs at most m arbitrary swaps of elements. After...
CF 1387A - Graph
CF 1387A - Graph Rating: 2100 Tags: *special, binary search, dfs and similar, dp, math, ternary search Solve time: 6m 59s Verified: no Solution Problem Understanding We are given an undirected graph where every edge enforces a linear constraint between its endpoints. Each vertex must be assigned a real value, and every edge says exactly what the sum of its two endpoint values must be. Black edges force a sum...
CF 1386B - Mixture
CF 1386B - Mixture Rating: 2900 Tags: *special, data structures, geometry, math, sortings Solve time: 7m 15s Verified: no Solution Problem Understanding We are maintaining a dynamic multiset of 3D vectors, each vector representing the amounts of salt, pepper, and garlic powder in a bottle. After each update, either adding or removing a bottle, we must determine the smallest number of available bottles whose positive linear combination can produce a...
CF 1305E - Kuroni and the Score Distribution
CF 1305E - Kuroni and the Score Distribution Rating: 2200 Tags: constructive algorithms, greedy, implementation, math Solve time: 7m 11s Verified: no Solution Problem Understanding We are asked to construct a strictly increasing sequence of integers $a_1 < a_2 < \dots < a_n$, all between 1 and $10^9$, such that a specific combinatorial condition on triples is satisfied. The condition counts how many index triples $i < j < k$...
CF 1276C - Beautiful Rectangle
CF 1276C - Beautiful Rectangle Rating: 2300 Tags: brute force, combinatorics, constructive algorithms, data structures, greedy, math Solve time: 11m 51s Verified: no Solution Problem Understanding We are given a multiset of integers, and we are allowed to select some of them and arrange the selected elements into a rectangular grid. Every chosen element occupies exactly one cell, and the grid is completely filled with chosen values. The grid has...
CF 1267J - Just Arrange the Icons
CF 1267J - Just Arrange the Icons Rating: 1800 Tags: greedy, implementation, math Solve time: 3m 21s Verified: yes Solution Problem Understanding We are given a multiset of applications, each belonging to a category. The only thing that matters about a category is how many apps it contains, so the input can be compressed into frequencies of each distinct category. We must place all apps into “screens”. Each screen has...
CF 1250L - Divide The Students
CF 1250L - Divide The Students Rating: 1500 Tags: binary search, greedy, math Solve time: 7m 8s Verified: yes Solution Problem Understanding We are given three groups of students determined by their preferred programming language. The task is to split all students into exactly three practice groups. The only restriction is that a single group is not allowed to contain both Assembler fans and C++ fans at the same time....
CF 1214E - Petya and Construction Set
CF 1214E - Petya and Construction Set Rating: 2000 Tags: constructive algorithms, graphs, math, sortings, trees Solve time: 2m 50s Verified: no Solution Problem Understanding We are asked to build a graph on $2n$ labeled vertices using exactly $2n-1$ edges. Since a connected graph with $2n$ vertices and $2n-1$ edges is necessarily a tree, the construction is really about designing a tree on these labeled nodes. The vertices come in...
CF 1208G - Polygons
CF 1208G - Polygons Rating: 2800 Tags: greedy, math, number theory Solve time: 6m 55s Verified: yes Solution Problem Understanding We are asked to build several regular polygons that all lie on the same circle, and we want to reuse the circle’s boundary points as much as possible. Each polygon is determined only by how many vertices it has. If a polygon has $l$ sides, then it uses $l$ equally...
CF 914G - Sum the Fibonacci
CF 914G - Sum the Fibonacci Rating: 2600 Tags: bitmasks, divide and conquer, dp, fft, math Solve time: 5m 10s Verified: no Solution Problem Understanding We are given a sequence of integers, each of which can be thought of as a 17-bit mask. From this array we must form ordered selections of five positions. Each selection contributes a value computed from bitwise combinations of the chosen elements, followed by evaluating...
CF 1060D - Social Circles
CF 1060D - Social Circles Rating: 1900 Tags: greedy, math Solve time: 6m 2s Verified: no Solution Problem Understanding We are given several guests, and each guest has a personal requirement about how they sit in a circular arrangement. If a guest is placed in a circle, then looking around the circle there are two directions, and the guest needs enough empty chairs on both sides: at least $l_i$ empty...
CF 1086F - Forest Fires
CF 1086F - Forest Fires Rating: 3500 Tags: math Solve time: 4m 50s Verified: no Solution Problem Understanding We are given a set of initial fire sources placed on an infinite integer grid. Fire spreads every second in all eight directions, so each burning cell ignites every neighboring cell that shares a side or a corner. This means the fire expands in a square shape under the Chebyshev metric. Each...
CF 1261F - Xor-Set
CF 1261F - Xor-Set Rating: 3100 Tags: bitmasks, divide and conquer, math Solve time: 6m 41s Verified: no Solution Problem Understanding We are given two very large sets of integers, but they are not listed explicitly. Instead, each set is described as a union of intervals. Every integer inside an interval belongs to the set, and different intervals may overlap, so the same number can appear multiple times in the...
CF 1600F - Party Organization
CF 1600F - Party Organization Rating: 2300 Tags: brute force, math, probabilities Solve time: 2m 22s Verified: yes Solution Problem Understanding We are given a simple undirected graph where people are vertices and friendships are edges. A valid party is a selection of exactly five distinct vertices such that the induced subgraph on these five vertices is either completely empty of edges or completely full, meaning it is a 5-vertex...
CF 1773J - Jumbled Trees
CF 1773J - Jumbled Trees Rating: 2900 Tags: constructive algorithms, math Solve time: 3m 16s Verified: no Solution Problem Understanding Each edge in a connected undirected graph carries a value that starts at zero. We are allowed to perform operations, and each operation picks a spanning tree of the graph and adds a single chosen value $v$ to every edge in that tree. The goal is to reach a configuration...
CF 1773A - Amazing Trick
CF 1773A - Amazing Trick Rating: 1900 Tags: constructive algorithms, graph matchings, math, probabilities Solve time: 2m 23s Verified: no Solution Problem Understanding We are given a permutation $a$ of size $n$, meaning every number from $1$ to $n$ appears exactly once. We are allowed to apply two permutations $q$ first and then $p$, so that the final position $i$ receives the value originally at position $p[q[i]]$. In other words,...
CF 1726H - Mainak and the Bleeding Polygon
CF 1726H - Mainak and the Bleeding Polygon Rating: 3500 Tags: binary search, geometry, implementation, math Solve time: 7m 13s Verified: no Solution Problem Understanding We are given a convex polygon described by its vertices in counter-clockwise order. The shape is not arbitrary: every corner is either a right angle or slightly wider than a right angle, but never sharp. That geometric restriction has a strong consequence on how “far...
CF 1726E - Almost Perfect
CF 1726E - Almost Perfect Rating: 2400 Tags: combinatorics, fft, math Solve time: 4m 48s Verified: no Solution Problem Understanding We are asked to count how many permutations of size $n$ satisfy a very specific structural constraint involving both the permutation and its inverse. For a permutation $p$, the value $p_i$ is the number placed at position $i$, while $p^{-1}_i$ is the position where value $i$ appears. The condition compares...
CF 1726B - Mainak and Interesting Sequence
CF 1726B - Mainak and Interesting Sequence Rating: 1100 Tags: bitmasks, constructive algorithms, math Solve time: 4m 46s Verified: no Solution Problem Understanding We are asked to construct a sequence of positive integers of length $n$ whose sum is fixed to $m$, but with an additional constraint that comes from a peculiar XOR condition applied to value ordering rather than positions. For every value $x$ appearing in the sequence, if...
CF 1726A - Mainak and Array
CF 1726A - Mainak and Array Rating: 900 Tags: greedy, math Solve time: 4m 32s Verified: yes Solution Problem Understanding We are given an array of positive integers. Exactly once, we are allowed to choose a contiguous segment and rotate it cyclically by any amount, which effectively means we can pick any element inside the segment and move it to either end of that segment, while preserving the relative order...
CF 1725H - Hot Black Hot White
CF 1725H - Hot Black Hot White Rating: 1800 Tags: constructive algorithms, math Solve time: 4m 26s Verified: no Solution Problem Understanding We are given an array of integers, each representing the strength of a magical stone. We must split these stones into two equal groups and assign each stone one of two colors. The only constraint on the coloring is that exactly half of the stones must be black...
CF 1725D - Deducing Sortability
CF 1725D - Deducing Sortability Rating: 2900 Tags: binary search, bitmasks, math Solve time: 4m 6s Verified: no Solution Problem Understanding We are asked to construct a very large hidden array indexed from 1 to N, where N can be up to one billion, without explicitly building it. This array is special because it is chosen so that it can be transformed, through a particular operation applied independently on elements,...
CF 1725A - Accumulation of Dominoes
CF 1725A - Accumulation of Dominoes Rating: 800 Tags: math Solve time: 3m 15s Verified: yes Solution Problem Understanding The grid in this problem is not arbitrary, it is completely determined by its dimensions. Every cell contains a unique integer, and the numbers increase row by row from left to right. The first row is filled with the first M integers, the second row continues immediately after, and so on....
CF 1654D - Potion Brewing Class
CF 1654D - Potion Brewing Class Rating: 2100 Tags: dfs and similar, math, number theory, trees Solve time: 9m 14s Verified: yes Solution Problem Understanding We are given a set of ingredients, each of which must appear in some positive integer quantity in a final mixture. The professor does not provide absolute amounts, but instead gives exactly $n-1$ constraints. Each constraint relates two ingredients and fixes their ratio: if ingredient...
CF 1654H - Three Minimums
CF 1654H - Three Minimums Rating: 3500 Tags: combinatorics, constructive algorithms, divide and conquer, dp, fft, math Solve time: 5m 50s Verified: no Solution Problem Understanding We are asked to count permutations of the numbers from 1 to n that satisfy two independent kinds of restrictions. The first restriction is positional and local. We are given a short comparison string s of length m. It fixes whether each adjacent pair...
CF 1578G - Game of Chance
CF 1578G - Game of Chance Rating: 3500 Tags: math, probabilities Solve time: 5m 52s Verified: no Solution Problem Understanding We are given a line of participants, each assigned a positive “luckiness” value. These participants enter a knockout tournament with a very rigid pairing structure. In any match between two players with luck values $x$ and $y$, the probability that the first player wins is $x/(x+y)$, and the second wins...
CF 1556H - DIY Tree
CF 1556H - DIY Tree Rating: 3300 Tags: graphs, greedy, math, probabilities Solve time: 4m 54s Verified: no Solution Problem Understanding We are given a complete weighted undirected graph on $n$ vertices, so every pair of vertices is connected and every edge has a known cost. The task is to select exactly $n-1$ edges that form a spanning tree of minimum total weight, but with an additional restriction that only...
CF 1556D - Take a Guess
CF 1556D - Take a Guess Rating: 1800 Tags: bitmasks, constructive algorithms, interactive, math Solve time: 9m 7s Verified: no Solution Problem Understanding We are given a hidden array of integers, and we cannot access its elements directly. The only way to learn anything about the array is by asking queries on pairs of indices. Each query returns either the bitwise AND or bitwise OR of two elements. Using only...
CF 1556F - Sports Betting
CF 1556F - Sports Betting Rating: 2500 Tags: bitmasks, combinatorics, dp, graphs, math, probabilities Solve time: 5m 15s Verified: yes Solution Problem Understanding We are given a complete tournament where every pair of teams plays exactly one match. The result of each match is random, but biased: team $i$ beats team $j$ with probability proportional to its strength, specifically $\frac{a_i}{a_i + a_j}$. Each match outcome is independent. From all match...
CF 1556A - A Variety of Operations
CF 1556A - A Variety of Operations Rating: 800 Tags: math Solve time: 3m 43s Verified: yes Solution Problem Understanding We start with two integers, both initialized to zero. We are allowed to repeatedly apply operations that modify them using a freely chosen positive step size each time. Every operation moves the pair $(a, b)$ in one of three linear directions: increasing both equally, shifting one up while the other...
CF 1553I - Stairs
CF 1553I - Stairs Rating: 3400 Tags: combinatorics, divide and conquer, dp, fft, math Solve time: 6m 11s Verified: no Solution Problem Understanding We are given an array a of length n . It is not a permutation itself but a derived “stability profile” of an unknown permutation of 1..n . For each position i in that hidden permutation, we look at all subarrays that contain i . Among those...
CF 1553A - Digits Sum
CF 1553A - Digits Sum Rating: 800 Tags: math, number theory Solve time: 4m 41s Verified: yes Solution Problem Understanding We are given several independent queries. Each query provides a positive integer $n$, and we must count how many integers $x$ in the range from 1 to $n$ have a special property. For a number $x$, we compare the sum of its digits before and after adding one. If the...
CF 1305C - Kuroni and Impossible Calculation Rating: 1600 Tags: brute force, combinatorics, math, number theory Model: gpt-5-3-mini Solve time: 1m 52s Verified: yes (1/1 samples) Share: https://chatgpt.com/share/6a2dd813-0a24-83ec-a40b-0979084984ee Solution Problem Understanding We are given a collection of numbers, and we are asked to compute a global product over all pairs of indices. For every pair of distinct elements, we take the absolute difference between them and multiply all of those...
CF 1305F - Kuroni and the Punishment Rating: 2500 Tags: math, number theory, probabilities Model: gpt-5-3-mini Solve time: 1m 51s Verified: yes (1/1 samples) Share: https://chatgpt.com/share/6a2dd87b-f5dc-83ec-a859-ab36a2e89043 Solution Problem Understanding We are given a list of large positive integers. In one move, we can pick any single element and shift it by exactly one unit up or down, as long as it stays positive. Each such shift costs one operation. The...
CF 1320A - Journey Planning Rating: 1400 Tags: data structures, dp, greedy, math, sortings Model: gpt-5-5 Solve time: 4m 27s Verified: yes (1/1 samples) Share: https://chatgpt.com/share/6a2de6ec-99fc-83ec-9276-106005ae8eca Solution Problem Understanding We are given a line of cities, each with an index from left to right and an associated beauty value. We need to choose a sequence of cities to visit such that indices strictly increase. The key restriction is that consecutive...
CF 1322B - Present Rating: 2100 Tags: binary search, bitmasks, constructive algorithms, data structures, math, sortings Model: gpt-5-3-mini Solve time: 1m 28s Verified: yes (1/1 samples) Share: https://chatgpt.com/share/6a2deae4-fc9c-83ec-aeba-66f8cbbf4563 Solution Problem Understanding We are given an array of integers, and we consider every unordered pair of distinct elements. For each pair, we compute their sum. After collecting all these pairwise sums, instead of summing or minimizing them, we combine them using...
CF 1250H - Happy Birthday
CF 1250H - Happy Birthday Rating: 1500 Tags: math Solve time: 4m 10s Verified: yes Solution Problem Understanding We are given a collection of digit candles, where each digit from 0 to 9 appears a certain number of times. Each candle can be reused infinitely, so the counts do not deplete when we form numbers. The task is to determine the smallest positive integer that cannot be written using the...
CF 1214B - Badges
CF 1214B - Badges Rating: 1100 Tags: brute force, math Solve time: 5m 4s Verified: yes Solution Problem Understanding We are given three integers describing a small combinatorial setup. There are a fixed number of boys and girls in total, and exactly $n$ participants will attend an event, but we do not know how many of them are boys or girls. The actual number of boys in the event can...
CF 1209B - Koala and Lights
CF 1209B - Koala and Lights Rating: 1300 Tags: implementation, math, number theory Solve time: 11m 21s Verified: yes Solution Problem Understanding Each light in this problem behaves like a binary switch that flips its state over time. You are given an initial configuration where each light is either on or off. After that, every light follows its own periodic rule: it starts toggling at a specific time offset and...
CF 1184D2 - Parallel Universes (Hard)
CF 1184D2 - Parallel Universes (Hard) Rating: 3100 Tags: math, matrices Solve time: 2m 28s Verified: yes Solution Problem Understanding We are simulating a probabilistic system that evolves a one-dimensional structure of length l , where a distinguished position called the Doctor’s current universe is fixed inside this structure. At every step, the system randomly either grows by inserting a new universe or shrinks by cutting a connection and discarding...
CF 1184A3 - Heidi Learns Hashing (Hard)
CF 1184A3 - Heidi Learns Hashing (Hard) Rating: 3100 Tags: fft, math, number theory Solve time: 7m 45s Verified: yes Solution Problem Understanding We are given two strings of equal length and we want to force a collision under a polynomial rolling hash. The hash is defined by interpreting each string as coefficients of a polynomial in a base $r$, and then evaluating it modulo a prime $p$. Concretely, each...
CF 1090L - Berland University
CF 1090L - Berland University Rating: 2000 Tags: greedy, math Solve time: 7m 1s Verified: yes Solution Problem Understanding There are t students and n lectures. A student passes if they attend at least k lectures. Lectures alternate between two auditoriums. Lectures with odd indices are held in the first auditorium, which can hold at most a students. Lectures with even indices are held in the second auditorium, which can...
CF 1090K - Right Expansion Of The Mind
CF 1090K - Right Expansion Of The Mind Rating: 2000 Tags: math Solve time: 1m 57s Verified: yes Solution Problem Understanding Each participant is described by two finite strings. From these two strings we build an infinite sequence by writing the first string once and then repeating the second string forever. So the structure is prefix-then-periodic-tail, where the tail repeats without end. The task compares every pair of such infinite...
CF 1089G - Guest Student
CF 1089G - Guest Student Rating: 1500 Tags: math Solve time: 5m 48s Verified: yes Solution Problem Understanding We are given a weekly schedule of classes that repeats every seven days. Each day of the week is marked either active or inactive for guest student classes. Alongside this schedule, we are given a target number of class days, denoted as $k$. We want to choose a continuous block of days...
CF 914A - Perfect Squares
CF 914A - Perfect Squares Rating: 900 Tags: brute force, implementation, math Solve time: 4m 38s Verified: yes Solution Problem Understanding We are given an array of integers and need to find the largest element that is not a perfect square . A perfect square is a number that can be expressed as the square of an integer. The input consists of a number n , the size of the...
CF 906D - Power Tower
CF 906D - Power Tower Rating: 2700 Tags: chinese remainder theorem, math, number theory Solve time: 14m 47s Verified: yes Solution Problem Understanding We are asked to compute a "power tower" modulo a given number. Conceptually, imagine a sequence of rocks, each with a positive integer power. To construct the tower from rocks numbered l through r , we start from the top rock r and work down to l...
CF 906B - Seating of Students
CF 906B - Seating of Students Rating: 2200 Tags: brute force, constructive algorithms, math Solve time: 6m 9s Verified: no Solution Problem Understanding We are asked to rearrange students in a classroom so that no two students who were neighbors in the original seating remain neighbors in the new arrangement. The classroom is an n × m grid, and the students are numbered sequentially from 1 to n · m...
CF 1089F - Fractions
CF 1089F - Fractions Rating: 1900 Tags: math Solve time: 3m 14s Verified: yes Solution Problem Understanding We are given an integer $n$, and we want to represent a fixed rational number, specifically $1 - \frac{1}{n}$, as a sum of several smaller fractions. Each fraction must have a denominator that is a proper divisor of $n$, meaning it divides $n$ but is neither 1 nor $n$. The numerator must be...
CF 1120B - Once in a casino
CF 1120B - Once in a casino Rating: 2700 Tags: constructive algorithms, greedy, implementation, math Solve time: 1m 25s Verified: no Solution Problem Understanding We are given two equal-length decimal strings, representing numbers written digit by digit. The task is to transform the first number into the second one using a very specific operation applied to adjacent digit pairs. Each operation selects an index between two neighboring digits and either...
CF 1184A1 - Heidi Learns Hashing (Easy)
CF 1184A1 - Heidi Learns Hashing (Easy) Rating: 1200 Tags: brute force, math, number theory Solve time: 3m 46s Verified: yes Solution Problem Understanding 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$. If multiple pairs exist, we...
CF 1208A - XORinacci
CF 1208A - XORinacci Rating: 900 Tags: math Solve time: 1m 28s Verified: yes Solution Problem Understanding 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. Formally, the sequence is defined by two initial integers a and b as f(0) = a , f(1) =...
CF 1209H - Moving Walkways
CF 1209H - Moving Walkways Rating: 3300 Tags: data structures, greedy, math Solve time: 1m 32s Verified: yes Solution Problem Understanding 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 $[x_i, y_i]$ and provides a constant speed bonus $s_i$. At any moment, Limak chooses a...
CF 1209A - Paint the Numbers
CF 1209A - Paint the Numbers Rating: 800 Tags: greedy, implementation, math Solve time: 1m 41s Verified: yes Solution Problem Understanding 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...
CF 1210E - Wojtek and Card Tricks
CF 1210E - Wojtek and Card Tricks Rating: 2700 Tags: math Solve time: 1m 49s Verified: yes Solution Problem Understanding 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. Wojtek is curious about all possible decks he can produce if he memorizes a contiguous set of shuffles...
CF 1210C - Kamil and Making a Stream
CF 1210C - Kamil and Making a Stream Rating: 2000 Tags: math, number theory, trees Solve time: 2m 30s Verified: yes Solution Problem Understanding 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. The...
CF 1214A - Optimal Currency Exchange
CF 1214A - Optimal Currency Exchange Rating: 1400 Tags: brute force, math Solve time: 2m 2s Verified: yes Solution Problem Understanding 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...
CF 1277D - Let's Play the Words?
CF 1277D - Let's Play the Words? Rating: 1900 Tags: data structures, hashing, implementation, math Solve time: 2m 3s Verified: no Solution Problem Understanding We are given a collection of binary strings, and we are allowed to optionally reverse some of them. After doing so, we want to arrange all strings in a single sequence such that every adjacent pair is compatible: the last character of a word must match...