#combinatorics
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 1558D - Top-Notch Insertions
CF 1558D - Top-Notch Insertions Rating: 2600 Tags: combinatorics, data structures Solve time: 1m 48s Verified: no Solution Problem Understanding We are looking at a process that behaves like insertion sort, but instead of only caring about the final sorted array, we care about the exact sequence of “real insertions” it performs while sorting. The key idea is that whenever the algorithm sees an element that is smaller than something...
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 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 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 960E - Alternating Tree
CF 960E - Alternating Tree Rating: 2300 Tags: combinatorics, dfs and similar, divide and conquer, dp, probabilities, trees Solve time: 2m 1s Verified: no Solution Problem Understanding We are given a tree with a value attached to every node. Between any two nodes $u$ and $v$, there is exactly one simple path, and we assign a score to that directed path by taking the node values along the path and...
CF 1725I - Imitating the Key Tree
CF 1725I - Imitating the Key Tree Rating: 2800 Tags: combinatorics, dsu, trees Solve time: 2m 4s Verified: no Solution Working
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 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 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 1060F - Shrinking Tree
CF 1060F - Shrinking Tree Rating: 2900 Tags: combinatorics, dp Solve time: 4m 9s Verified: no Solution Problem Understanding We are given a tree with up to 50 vertices, and we repeatedly compress it until only one vertex remains. Each operation picks an edge uniformly at random. The two endpoints of that edge disappear, and they are replaced by a single merged vertex. This new vertex inherits all edges that...
CF 1726G - A Certain Magical Party
CF 1726G - A Certain Magical Party Rating: 3300 Tags: combinatorics, data structures, greedy, sortings Solve time: 5m 44s Verified: no Solution Problem Understanding We are given a group of $n$ people, each starting with a happiness value $a_i$ and a binary personality flag $b_i$. We choose a permutation, which represents the order in which they speak. When a person speaks, they look at everyone else’s current happiness values and...
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 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 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 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 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 1089I - Interval-Free Permutations
CF 1089I - Interval-Free Permutations Rating: 2600 Tags: combinatorics Solve time: 3m 32s Verified: no Solution Sure-please paste the full Codeforces problem statement (or at least the link / input-output / constraints). Once I have it, I’ll write a proper competitive programming editorial with: Key idea / intuition Step-by-step reasoning Formal solution Complexity analysis Common pitfalls Reference implementation (C++/Python if you want) Send the problem whenever you’re ready.
CF 914H - Ember and Storm's Tree Game
CF 914H - Ember and Storm's Tree Game Rating: 3400 Tags: combinatorics, dp, games, trees Solve time: 10m 4s Verified: yes Solution Problem Understanding The game begins with Ember choosing a tree on $n$ labeled vertices, with the restriction that no vertex has degree exceeding $d$. After that, Storm selects an ordered pair of vertices $(u, v)$, which determines a simple path in the tree. Writing the vertex labels along...
CF 914C - Travelling Salesman and Special Numbers
CF 914C - Travelling Salesman and Special Numbers Rating: 1800 Tags: brute force, combinatorics, dp Solve time: 4m Verified: yes Solution Problem Understanding We are given an upper bound n , but n is not provided as a decimal integer. Instead, it is given directly as a binary string whose length can be as large as 1000 bits. We consider the following operation on a positive integer: Take the number...
CF 1276B - Two Fairs
CF 1276B - Two Fairs Rating: 1900 Tags: combinatorics, dfs and similar, dsu, graphs Solve time: 1m 34s Verified: yes Solution Problem Understanding We are given a connected undirected graph of cities. Among all cities, two special nodes are distinguished, call them a and b , representing two fairs. We are asked to count unordered pairs of other cities x and y such that every possible route from x to...
CF 1402C - Star Trek
CF 1402C - Star Trek Rating: 2600 Tags: *special, combinatorics, dfs and similar, dp, games, graphs, matrices, trees Solve time: 1m 26s Verified: yes Solution Problem Understanding We are given a tree of $N$ planets. Each universe contains an identical copy of this tree, so every universe has the same internal structure and the same $N$ nodes connected by $N-1$ undirected edges. There are $D+1$ universes indexed from $0$ to...
CF 1403C - Chess Rush
CF 1403C - Chess Rush Rating: 3200 Tags: *special, combinatorics, dp, implementation, math Solve time: 4m 8s Verified: yes Solution What is actually going wrong Let’s trace what the wrong behavior implies. Input: 3 4 #.## #### ##.. Grid: #.## #### ##.. There are only 4 # cells total. But the output is 9 , which is suspiciously close to “counting something per cell plus neighbors” or “counting all 2x2...
CF 1425D - Danger of Mad Snakes
CF 1425D - Danger of Mad Snakes Rating: 2300 Tags: combinatorics, dp, math Solve time: 1m 12s Verified: yes Solution Problem Understanding The problem gives a set of points on a 2D grid, each point representing a snake with a weight called its danger level. We choose exactly M distinct snakes as attack targets. Each chosen target defines a square influence region centered at that snake, where all other snakes...
CF 1442B - Identify the Operations
CF 1442B - Identify the Operations Rating: 1800 Tags: combinatorics, data structures, dsu, greedy, implementation Solve time: 1m 55s Verified: no Solution Problem Understanding We start with a permutation stored in a line. At each step, we remove one element from the current line and, depending on where we removed it, we are forced to append one of its immediate neighbors (left or right, whichever exists at that moment) into...
CF 1523E - Crypto Lights
CF 1523E - Crypto Lights Rating: 2600 Tags: combinatorics, dp, math, probabilities Solve time: 2m 17s Verified: no Solution Problem Understanding We are asked to compute the expected number of lights that turn on in a line of $n$ lights, given a stopping condition based on consecutive segments of length $k$. Each light starts off, and in each step, one random light that is still off is turned on. The...
CF 1530F - Bingo
CF 1530F - Bingo Rating: 2600 Tags: bitmasks, combinatorics, dp, math, probabilities Solve time: 2m 2s Verified: no Solution Problem Understanding We are asked to compute the probability that a square table of events is "winning." Each cell of an $n \times n$ table contains an event that may happen with a given probability. Rows, columns, the main diagonal, and the antidiagonal are considered lines. A table is winning if...
CF 1586I - Omkar and Mosaic
CF 1586I - Omkar and Mosaic Rating: 3500 Tags: combinatorics, constructive algorithms, math Solve time: 2m 14s Verified: no Solution Problem Understanding We are given an $n \times n$ grid representing a partially filled mosaic. Each cell either contains a sinoper tile S , a glaucous tile G , or is empty . . The final goal is to fill all empty cells so that the resulting mosaic is a...
CF 1599C - Bubble Strike
CF 1599C - Bubble Strike Rating: 2000 Tags: combinatorics, math, probabilities, ternary search Solve time: 1m 44s Verified: no Solution Problem Understanding We are asked to determine how many maps Johnny must study to ensure that the probability he ends up playing on a studied map is at least $P$. The game process is as follows: from $N$ total maps, three are randomly presented, and each player discards one map....
CF 1648A - Weird Sum
CF 1648A - Weird Sum Rating: 1400 Tags: combinatorics, data structures, geometry, math, matrices, sortings Solve time: 1m 12s Verified: yes Solution Problem Understanding We are given a 2D grid of size $n \times m$ where each cell contains a color represented by an integer. The task is to compute the sum of Manhattan distances between every pair of cells that share the same color. The Manhattan distance between two...
CF 1648C - Tyler and Strings
CF 1648C - Tyler and Strings Rating: 1900 Tags: combinatorics, data structures, implementation Solve time: 57s Verified: yes Solution Problem Understanding We are given two sequences of integers, s and t , representing letters of two strings. Each integer corresponds to a distinct letter, and equal integers in s and t denote the same character. Tyler wants to count how many distinct rearrangements of s result in a string that...
CF 1662N - Drone Photo
CF 1662N - Drone Photo Rating: - Tags: combinatorics, math, sortings Solve time: 1m 27s Verified: yes Solution Problem Understanding We are asked to count the number of ways to select four contestants standing on the vertices of a rectangle in an $n \times n$ grid, such that when forming a banner using the two youngest contestants as one pole and the two oldest as another, the poles do not...
CF 1666F - Fancy Stack
CF 1666F - Fancy Stack Rating: 2200 Tags: combinatorics, dp, implementation Solve time: 1m 3s Verified: yes Solution Problem Understanding The problem gives us a sequence of integers representing operations on a stack. Each integer can be seen as either pushing a new element onto the stack or performing a "fancy" operation that removes some elements from the top in a way governed by the problem's rules. The goal is...
CF 1765C - Card Guessing
CF 1765C - Card Guessing Rating: 2600 Tags: combinatorics, dp, probabilities Solve time: 4m 5s Verified: yes Solution Problem Understanding We are dealing with a long sequence of independent random experiments: a deck contains exactly four suits, and each suit appears exactly (n) times, so the total length is (4n). The deck is shuffled uniformly at random, so every permutation is equally likely. A player scans the deck from top...
CF 1773G - Game of Questions
CF 1773G - Game of Questions Rating: 2800 Tags: bitmasks, combinatorics, dp, fft, math, probabilities Solve time: 4m 17s Verified: yes Solution Problem Understanding Each test case gives a binary matrix with up to 17 columns and up to 2⋅10^5 rows. Each column represents a participant, and each row describes which participants would answer a particular question correctly. The questions are randomly permuted before being asked. As the sequence runs,...
CF 1773D - Dominoes
CF 1773D - Dominoes Rating: 2600 Tags: combinatorics, flows, graph matchings, greedy Solve time: 1m 49s Verified: yes Solution Bug Diagnosis Now we finally see a real logical failure rather than a wrapper issue. The produced output: 2 3 2 2 2 2 is structurally consistent but numerically wrong, which tells us the implementation is computing something uniform per position instead of position-dependent reachability. The core mistake is in how...
CF 1776G - Another Wine Tasting Event
CF 1776G - Another Wine Tasting Event Rating: 2100 Tags: combinatorics, constructive algorithms, math, strings Solve time: 1m 4s Verified: yes Solution Problem Understanding We are given a binary string of length $2n-1$, where each position represents a bottle of wine, either white or red. From this fixed sequence, we need to assign $n$ critics to $n$ distinct segments of the array. Each critic chooses a contiguous interval, and every...
CF 1906H - Twin Friends
CF 1906H - Twin Friends Rating: 2200 Tags: combinatorics, dp Solve time: 1m 11s Verified: yes Solution Problem Understanding We are given two strings, $A$ of length $N$ and $B$ of length $M$ with $N \le M$, representing the names of two twins. We want to create nicknames $A'$ and $B'$ for them. $A'$ can be any permutation of $A$, while $B'$ is obtained by taking any permutation of $B$...
CF 1877F - Lexichromatography
CF 1877F - Lexichromatography Rating: 2500 Tags: combinatorics, dsu Solve time: 3m 17s Verified: no Solution Problem Understanding We are asked to count the number of ways to colour an array of integers either blue or red, subject to two constraints. The first is a lexicographical constraint: if we extract the blue elements as a subsequence and the red elements as another subsequence, the blue sequence must be strictly smaller...
CF 1877D - Effects of Anti Pimples
CF 1877D - Effects of Anti Pimples Rating: 1500 Tags: combinatorics, number theory, sortings Solve time: 1m 57s Verified: no Solution Problem Understanding We are given an array indexed from 1 to n. We repeatedly choose a non-empty subset of indices and mark them as special. Those chosen indices are colored black. After that, any still-unselected index becomes green if it is a multiple of at least one black index....
CF 1866M - Mighty Rock Tower
CF 1866M - Mighty Rock Tower Rating: 2400 Tags: brute force, combinatorics, dp, math, probabilities Solve time: 2m 18s Verified: no Solution Problem Understanding We are asked to compute the expected number of moves to build a tower of height N using identical small rocks, where each placement may trigger a cascading fall of the top rocks. Every time a rock is placed at height x , the topmost rock...
CF 1866H - Happy Sets
CF 1866H - Happy Sets Rating: 2100 Tags: combinatorics Solve time: 1m 52s Verified: no Solution Problem Understanding We are given a collection of $N$ sets, each set is formed from integers in the range $1$ to $K$. The sets are unordered internally, but the array of sets is ordered. After we construct these $N$ sets, we are allowed to permute them in any order. The key condition is that...
CF 1866B - Battling with Numbers
CF 1866B - Battling with Numbers Rating: 1400 Tags: combinatorics, math, number theory Solve time: 1m 23s Verified: yes Solution Problem Understanding We are given two integers, but instead of being written in decimal form, they are described by their prime factorizations. One number, call it $X$, is fully determined by a list of primes and their exponents. The other number $Y$ is described the same way. The task is...
CF 1876D - Lexichromatography
CF 1876D - Lexichromatography Rating: 2500 Tags: combinatorics, dfs and similar, dsu, graphs, two pointers Solve time: 2m 10s Verified: no Solution Problem Understanding We are given an array of integers, and our task is to assign each element one of two colors, blue or red. The goal is to count all colorings that satisfy two conditions. First, if we take the subsequence of all blue elements and the subsequence...
CF 1876B - Effects of Anti Pimples
CF 1876B - Effects of Anti Pimples Rating: 1500 Tags: combinatorics, number theory, sortings Solve time: 1m 44s Verified: yes Solution Problem Understanding We are given an array of integers representing values at different positions. Chaneka can select one or more indices to color black. After that, every element at a position that is a multiple of a black index turns green. The score of a particular selection is the...
CF 1906J - Count BFS Graph
CF 1906J - Count BFS Graph Rating: 2100 Tags: combinatorics, dp Solve time: 1m 18s Verified: yes Solution Problem Understanding We are given a fixed ordering of all vertices, starting from node 1, and this ordering is claimed to be the order in which a BFS discovers nodes in some undirected simple graph. The BFS rule is standard: starting from node 1, we scan neighbors in increasing numeric order, and...
CF 1912K - Kim's Quest
CF 1912K - Kim's Quest Rating: 1800 Tags: bitmasks, combinatorics, dp Solve time: 1m 31s Verified: yes Solution Problem Understanding We are given a sequence of integers, and we need to count how many of its subsequences satisfy a very specific structural constraint. A subsequence is formed by selecting some indices in increasing order, keeping the original order of values but possibly skipping elements. The constraint is applied locally: if...
CF 1912B - Blueprint for Seating
CF 1912B - Blueprint for Seating Rating: 2100 Tags: combinatorics, divide and conquer, math Solve time: 2m 42s Verified: no Solution Problem Understanding We are given a row of seats split into contiguous blocks by aisles. Each block is a positive-length segment of seats, and between any two consecutive blocks there is exactly one aisle. If there are $k$ aisles, then there are $k+1$ blocks, and their sizes form a...
CF 2034F1 - Khayyam's Royal Decree (Easy Version)
CF 2034F1 - Khayyam's Royal Decree (Easy Version) Rating: 2500 Tags: combinatorics, dp, math, sortings Solve time: 3m 48s Verified: no Solution Problem Understanding We are simulating a random process where a bag is filled by repeatedly drawing items from a multiset containing two types of objects: red items worth 2 units and blue items worth 1 unit. The draw order is uniformly random over all permutations of the multiset,...
CF 2034F2 - Khayyam's Royal Decree (Hard Version)
CF 2034F2 - Khayyam's Royal Decree (Hard Version) Rating: 2800 Tags: combinatorics, dp, math, sortings Solve time: 2m 20s Verified: no Solution Problem Understanding We are asked to compute the expected total value of a collection of gems after a stochastic process with multiplicative bonuses. Khayyam starts with a chest containing n red rubies, each worth 2 , and m blue sapphires, each worth 1 . On each turn, he...
CF 2034E - Permutations Harmony
CF 2034E - Permutations Harmony Rating: 2200 Tags: combinatorics, constructive algorithms, greedy, hashing, math Solve time: 2m 25s Verified: yes Solution Problem Understanding We need to construct $k$ distinct permutations of length $n$ such that if we look at any position $i$, the sum of the values appearing at that position across all $k$ permutations is the same for every position. If we denote the permutations by $p_1,p_2,\dots,p_k$, then for...
CF 2038F - Alternative Platforms
CF 2038F - Alternative Platforms Rating: 2500 Tags: combinatorics, data structures, fft, math, sortings Solve time: 1m 50s Verified: no Solution Problem Understanding We are given a collection of bloggers, where each blogger has two independent activity counts: how many videos they uploaded to platform A and how many to platform B. A user does not necessarily watch all bloggers equally. Instead, we consider choosing a subset of exactly $k$...
CF 2041H - Sheet Music
CF 2041H - Sheet Music Rating: 2300 Tags: combinatorics, dp, math Solve time: 1m 43s Verified: no Solution Problem Understanding Alice wants to count all sequences of notes of length n using pitches from 1 to k , but sequences that "move" the same way are considered identical. Two sequences are considered musically equivalent if each consecutive pair of notes has the same relative relationship: increasing, decreasing, or equal. For...
CF 2045E - Narrower Passageway
CF 2045E - Narrower Passageway Rating: 2700 Tags: combinatorics, data structures Solve time: 3m 33s Verified: no Solution Problem Understanding We are given a grid with two rows and $N$ columns. Each cell contains a value representing the strength of a soldier stationed there. On any given day, each column independently either disappears in fog or remains visible, with probability $1/2$. If a column is fogged, both cells in that...
CF 2061C - Kevin and Puzzle
CF 2061C - Kevin and Puzzle Rating: 1600 Tags: 2-sat, combinatorics, dp Solve time: 1m 49s Verified: yes Solution Problem Understanding We have a line of classmates, each of whom claims a certain number of liars standing to their left. Each person is either honest, in which case their claim is exactly true, or a liar, in which case their claim may be arbitrary. Additionally, liars cannot stand next to...
CF 2068J - The Ultimate Wine Tasting Event
CF 2068J - The Ultimate Wine Tasting Event Rating: 2000 Tags: combinatorics, greedy Solve time: 2m 3s Verified: no Solution Problem Understanding We are given a row of $2n$ wine bottles, exactly half white and half red. Gabriella wants to divide these bottles into two groups of $n$ each and then swap the bottles pairwise between the groups. After this single swap, all white bottles should occupy the first $n$...
CF 2124F2 - Appending Permutations (Hard Version)
CF 2124F2 - Appending Permutations (Hard Version) Rating: 2800 Tags: combinatorics, dp Solve time: 1m 41s Verified: no Solution Problem Understanding We are building an array of length $n$, but we are not constructing it element by element. Instead, the array is formed by repeatedly appending whole blocks. Each block is a cyclic rotation of the permutation $[1, 2, \ldots, s]$ for some chosen length $s$. Every operation contributes a...
CF 2124F1 - Appending Permutations (Easy Version)
CF 2124F1 - Appending Permutations (Easy Version) Rating: 2300 Tags: combinatorics, dp Solve time: 1m 32s Verified: no Solution Problem Understanding We are asked to count arrays of length $n$ that can be built by repeatedly appending cyclic shifts of the arrays $[1, 2, \dots, s]$ for any $s \ge 1$, while respecting a set of restrictions of the form $a_i \ne x$. Each operation appends a contiguous sequence of...
CF 2172D - Divisor Card Game
CF 2172D - Divisor Card Game Rating: 3100 Tags: combinatorics, dp Solve time: 2m 14s Verified: no Solution Problem Understanding We are asked to model a probabilistic card game where each student starts with a subset of numbered cards and additional cards are revealed one by one. The game mechanics are based on divisibility: for each revealed card, each student selects a card from their hand, and the smallest card...
CF 2206I - Growth Factor
CF 2206I - Growth Factor Rating: 2900 Tags: combinatorics, dp, math, number theory Solve time: 1m 10s Verified: yes Solution Problem Understanding We are counting how many ways we can build a sequence of integers when each position has an upper limit, and each element must divide the next one. More concretely, at position i we choose a value b_i that cannot exceed a_i . After choosing it, the next...
CF 2222H - Counting Sort?
CF 2222H - Counting Sort? Rating: - Tags: brute force, combinatorics, dp Solve time: 1m 54s Verified: no Solution Problem Understanding We are asked to count arrays with a property defined recursively. Given an array of integers, each bounded individually by a corresponding r_i , we define a transformation f(b) that counts how many times each integer appears in b . Then, g(b) is defined as the number of distinct...