brain

tamnd's digital brain — notes, problems, research

43815 notes

CF 1334A - Level Statistics

We observe the statistics of a game level several times. At each observation we know two values: how many times the level has been played and how many times it has been cleared. A successful attempt increases both numbers by one at the same moment.

codeforcescompetitive-programmingimplementationmath
CF 1335B - Construct the String

For each test case we have to build a lowercase string of length n. The condition is that every contiguous segment of length a must contain exactly b different letters. Any valid string is acceptable. The numbers describe a sliding window condition. If we look at positions 1...

codeforcescompetitive-programmingconstructive-algorithms
CF 1336F - Journey

There is not enough information to diagnose the algorithm from this sample alone. The failing input is: Expected output: Actual output: From this, we can infer only that: - The input format is a line containing 1 7 followed by a binary string 0000000.

codeforcescompetitive-programmingdata-structuresdivide-and-conquergraphstrees
CF 1336B - Xenia and Colorful Gems

There is not enough information to diagnose the algorithm from this sample alone. The failing input is: Expected output: Actual output: From this, we can infer only that: - The input format is a line containing 1 7 followed by a binary string 0000000.

codeforcescompetitive-programmingbinary-searchgreedymathsortingstwo-pointers
CF 1338A - Powered Addition

We are given an integer array and we are allowed to repeatedly perform timed operations. In the $x$-th second, we may choose any subset of indices and add the same value $2^{x-1}$ to all chosen positions.

codeforcescompetitive-programminggreedymath
CF 1339A - Filling Diamonds

The task describes a fixed triangular strip that grows with a parameter $n$. For each $n$, the shape consists of $4n-2$ unit triangles arranged in a long belt-like region.

codeforcescompetitive-programmingbrute-forcedpimplementationmath
CF 1340B - Nastya and Scoreboard

The previous solution is based on a misunderstanding of the problem. The goal is not to match the sample output exactly. The sample output shows one valid answer among many. The real requirement is: 1. t must be a subsequence of s. 2. 3. s must have the smallest possible period.

codeforcescompetitive-programmingbitmasksdpgraphsgreedy
CF 1342F - Make It Ascending

We are given an array of integers, and we are allowed to repeatedly perform an operation where we pick two distinct indices, add the value from the first index to the second, and remove the first element from the array.

codeforcescompetitive-programmingbitmasksbrute-forcedp
CF 1342A - Road To Zero

We start with two independent counters, x and y, and want to bring both to zero. We are allowed to modify them in two different ways, each with a cost.

codeforcescompetitive-programminggreedymath
CF 1343B - Balanced Array

We are asked to construct an array of length $n$ where the first half consists of distinct even positive integers, the second half consists of distinct odd positive integers, and the sums of the two halves are equal.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1343C - Alternating Subsequence

We are given a sequence of integers, both positive and negative, and need to construct a subsequence whose elements strictly alternate in sign. Among all subsequences that achieve the maximum possible length, we are asked to find the one with the largest sum.

codeforcescompetitive-programmingdpgreedytwo-pointers
CF 1344A - Hilbert's Hotel

We are dealing with an infinite hotel where each room, labeled by an integer, has exactly one guest. A shuffling rule is applied where each guest moves from their current room $k$ to a new room $k + a{k bmod n}$, where $a$ is an array of length $n$.

codeforcescompetitive-programmingmathnumber-theorysortings
CF 1344B - Monopole Magnets

We are asked to place north and south monopole magnets on an $n times m$ grid in a way that respects three rules. Each cell is either black or white. A north magnet can move towards a south magnet in the same row or column, but south magnets are fixed.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similardsugraphs
CF 1345A - Puzzle Pieces

We are asked to determine whether a grid of jigsaw pieces can be assembled given a special piece design. Each piece has exactly three tabs and one blank. The pieces can be rotated in any orientation.

codeforcescompetitive-programmingmath
CF 1346A - Color Revolution

We are given a total number of participants and a fixed multiplier. The participants must be split into four consecutive groups where each next group is exactly $k$ times larger than the previous one.

codeforcescompetitive-programming*specialmath
CF 1346G - Two IP Cameras

We are given two identical IP cameras, each capable of taking photos at a fixed period. The period of each camera must be chosen from a predefined set of integers, but the starting moment of each camera is flexible.

codeforcescompetitive-programming*specialmathnumber-theory
CF 1346B - Boot Camp

The problem asks us to schedule the maximum number of lectures during a programming boot camp that lasts n days. Each day is either a normal day, where we can hold lectures, or an excursion day, where no lectures are allowed.

codeforcescompetitive-programming*specialgreedy
CF 1348D - Phoenix and Science

Let $u(x)$ be a polynomial with integer coefficients that is squarefree over $mathbb{Z}$. This means that $u(x)$ has no repeated roots in $mathbb{C}$, equivalently, $gcd(u(x), u'(x)) = 1$ in $mathbb{Z}[x]$, where $u'(x)$ is the derivative of $u(x)$.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsgreedyimplementationmath
CF 1349C - Orac and Game of Life

The grid evolves in discrete time. Each cell has one of two colors and updates simultaneously each step based only on its four neighbors. A cell looks at the current state. If none of its neighbors share its color, it stays unchanged.

codeforcescompetitive-programmingdfs-and-similargraphsimplementationshortest-paths
CF 1349F1 - Slime and Sequences (Easy Version)

We are asked to count appearances of numbers in a special class of integer sequences called good sequences. A sequence of length n is considered good if, for every number k 1 that appears, there is at least one occurrence of k-1 somewhere earlier in the sequence.

codeforcescompetitive-programmingdpfftmath
CF 1349B - Orac and Medians

We are given several independent queries. Each query provides a sequence of integers and a target value $k$. We are allowed to repeatedly choose any contiguous segment of the sequence and replace every element in that segment with the median of that segment.

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 1350B - Orac and Models

We are given several independent test cases. In each one, we have a sequence of model sizes indexed from 1 to n. We are allowed to pick a subset of indices, but the chosen indices must be kept in increasing order, which is equivalent to choosing a subsequence of indices.

codeforcescompetitive-programmingdpmathnumber-theory
CF 1351A - A+B (Trial Problem)

The task asks us to add pairs of integers. Each test case consists of two integers, and for each pair, we need to compute their sum. The input first tells us how many pairs there are, then each subsequent line contains a pair.

codeforcescompetitive-programmingimplementation
CF 1351C - Skier

We are given a sequence of moves on an infinite grid. Each move shifts a skier one unit in one of four directions: north, south, east, or west. As the skier follows the path, they traverse unit segments between grid points.

codeforcescompetitive-programmingdata-structuresimplementation
CF 1352F - Binary String Reconstruction

We are asked to reconstruct a binary string given the counts of its consecutive pairs grouped by how many ones they contain.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similarmath
CF 1353B - Two Arrays And Swaps

The problem gives two arrays of equal length, which we can think of as two sets of numbers on separate shelves. We are allowed to swap numbers between the shelves, but only up to a maximum of k swaps.

codeforcescompetitive-programminggreedysortings
CF 1353E - K-periodic Garland

We are given a linear garland of lamps, represented as a string of 0s and 1s, where 1 indicates a lamp is on and 0 indicates it is off. A garland is called k-periodic if the distance between any two consecutive 1s is exactly k.

codeforcescompetitive-programmingbrute-forcedpgreedy
CF 1353A - Most Unstable Array

We are given an array length n and a required total sum m. The task is to assign non-negative integers to an array of length n so that the sum of all elements equals m.

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 1354A - Alarm Clock

We are simulating a very simple system that evolves over time in discrete “sleep cycles.” A person needs to accumulate at least a target amount of effective sleep before they are allowed to get out of bed.

codeforcescompetitive-programmingmath
CF 1354D - Multiset

We are maintaining a collection of integers where duplicates are allowed, and the collection changes over time. Initially we are given a sorted list of values that already form the starting multiset. After that, we receive a long sequence of operations.

codeforcescompetitive-programmingbinary-searchdata-structures
CF 1354B - Ternary String

We are given multiple test cases, and each test case is a string made only of the characters 1, 2, and 3. For each string, we need to find the shortest continuous segment (substring) that contains at least one occurrence of each of the three characters.

codeforcescompetitive-programmingbinary-searchdpimplementationtwo-pointers
CF 1355B - Young Explorers

We are given a list of explorers, each associated with a number $ei$ that represents how many people must be in any group they join. If an explorer has value $e$, then they are only willing to participate in a group whose size is at least $e$.

codeforcescompetitive-programmingdpgreedysortings
CF 1355A - Sequence with Digits

We are asked to generate a sequence of numbers defined recursively. The sequence starts with a given number $a1$, and each subsequent number is obtained by adding the product of the minimum and maximum digits of the previous number.

codeforcescompetitive-programmingbrute-forceimplementationmath
CF 1356B2 - Decrement

We work modulo an odd prime $p$ and factor $$x^8 + 1.$$ The structure of the factorization depends entirely on how $-1$ and $2$ behave in $mathbb{F}p$, because the natural attempt is to rewrite $x^8+1$ as a product of quadratic expressions obtained from square roots of these…

codeforcescompetitive-programming*special
CF 1356D1 - Quantum Classification - 1

The task is not a typical input-output problem. Instead, you are given a fixed dataset of 200 two-dimensional points, each labeled as either class 0 or class 1.

codeforcescompetitive-programming*special
CF 1356A5 - Distinguish Z from -Z

We are given a quantum operation acting on a single qubit. The operation is either a Z gate, which leaves the The input is not classical data but a quantum operation with known interface: we can call it on a qubit and measure the qubit afterwards.

codeforcescompetitive-programming*special
CF 1356A2 - Distinguish I from Z

We are given a quantum black-box operation that acts on a single qubit. The operation is guaranteed to be either doing nothing at all or applying a phase flip. We need to identify which of these two behaviors is implemented and output a binary label.

codeforcescompetitive-programming*special
CF 1356A3 - Distinguish Z from S

We are given a quantum black-box operation that acts on a single qubit. This operation is guaranteed to be either the Z gate or the S gate.

codeforcescompetitive-programming*special
CF 1357E2 - Root of quantum Fourier transform

The task is to implement a quantum operation that, when applied $P$ times, reproduces the effect of a full quantum Fourier transform (QFT) on a small register of qubits.

codeforcescompetitive-programming*special
CF 1357E1 - Power of quantum Fourier transform

The task is to implement an operation on a quantum register that corresponds to raising the quantum Fourier transform (QFT) to a given power $P$. The input is an integer $P$ and a quantum register encoded in little-endian format, meaning the least significant qubit comes first.

codeforcescompetitive-programming*special
CF 1357D3 - Quantum Classification - Dataset 5

In this problem, we are given an array of integers representing a dataset of measurements. Each query requires us to compute the minimum number of operations needed to make a segment of this array “homogeneous” according to a specific rule: all identical numbers in a…

codeforcescompetitive-programming*special
CF 1357A6 - Distinguish four Pauli gates

We are given a black-box quantum operation that acts on a single qubit. This operation is guaranteed to be exactly one of four possibilities: the identity operation or one of the three Pauli gates.

codeforcescompetitive-programming*special
CF 1357C2 - Prepare superposition of basis states with the same parity

The problem asks us to prepare a quantum state over $N$ qubits where only the basis states with a specific parity of ones are included in an equal superposition.

codeforcescompetitive-programming*special
CF 1357B1 - "Is the bit string balanced?" oracle

We are asked to implement a quantum oracle that marks a bit string as “balanced” if it contains exactly half zeros and half ones. The input is a list of qubits representing the bits of the string and an extra qubit representing the output.

codeforcescompetitive-programming*special
CF 1357A5 - Distinguish Rz(θ) from Ry(θ)

We are given a quantum gate that acts on a single qubit, and we know it is either a rotation around the Z-axis by an angle θ, denoted Rz(θ), or a rotation around the Y-axis by the same angle, Ry(θ). Our task is to determine which gate we have, returning 0 for Rz and 1 for Ry.

codeforcescompetitive-programming*special
CF 1357A1 - Figure out direction of CNOT

We are asked to identify which of two possible two-qubit CNOT gates we have: one where the first qubit is the control and the second is the target, and one where the second qubit is the control and the first is the target.

codeforcescompetitive-programming*special
CF 1357A2 - Distinguish I, CNOTs and SWAP

This is not a traditional input/output Codeforces problem. We are given access to an unknown two-qubit quantum operation and must determine which one of four possibilities it is. The hidden operation is guaranteed to be one of the following: - Identity on both qubits.

codeforcescompetitive-programming*special
CF 1358C - Celex Update

The problem gives us an infinite two-dimensional table filled with integers in a specific pattern. Each cell at position $(x, y)$ contains a number that can be derived from its coordinates using the “GAZ-GIZ” filling rule.

codeforcescompetitive-programmingmath
CF 1359B - New Theatre Square

I have carefully traced the construction and identified why the previous implementation produces incorrect matrices.

codeforcescompetitive-programmingbrute-forcedpgreedyimplementationtwo-pointers
CF 1359A - Berland Poker

We have a deck containing n cards, of which m are jokers. The cards are distributed evenly among k players, so every player receives exactly n / k cards. The score depends only on how the jokers are distributed. Suppose one player ends up with the largest number of jokers.

codeforcescompetitive-programmingbrute-forcegreedymath
CF 1360E - Polygon

We are given an $n times n$ square matrix that starts entirely filled with zeros. Along the top edge, there are $n$ cannons, one above each column, and along the left edge, there are $n$ cannons, one to the left of each row.

codeforcescompetitive-programmingdpgraphsimplementationshortest-paths
CF 1360A - Minimal Square

We are asked to find the minimal square that can contain two identical rectangles of size $a times b$. The rectangles can be rotated, moved, and must remain entirely within the square, with sides parallel to the square.

codeforcescompetitive-programminggreedymath
CF 1361E - James and the Chase

The exercise asks for a direct algebraic simplification of two displayed identities involving content and primitive part of polynomials over a unique factorization domain $S$.

codeforcescompetitive-programmingdfs-and-similargraphsprobabilitiestrees
CF 1361A - Johnny and Contribution

We are given an undirected graph. Each vertex represents a blog, and every blog has a desired topic number t[i]. Johnny writes blogs one by one. When he writes a blog, he looks only at neighbors that have already been written.

codeforcescompetitive-programmingconstructive-algorithmsgraphsgreedysortings
CF 1361B - Johnny and Grandmaster

The exercise asks for a direct algebraic simplification of two displayed identities involving content and primitive part of polynomials over a unique factorization domain $S$.

codeforcescompetitive-programminggreedyimplementationmathsortings
CF 1362B - Johnny and His Hobbies

We are given a set of distinct integers. Johnny chooses a positive integer k and replaces every value s in the set with s XOR k. The transformation is applied to every element simultaneously.

codeforcescompetitive-programmingbitmasksbrute-force
CF 1363C - Game On Leaves

The game is played on a tree, which is an undirected, connected, acyclic graph. Each node is numbered from $1$ to $n$, and one node $x$ is special. Two players take turns removing leaf nodes, where a leaf is a node with only one neighbor, along with its connecting edge.

codeforcescompetitive-programminggamestrees
CF 1363A - Odd Selection

We are given an array of integers and must choose exactly x elements from it. The chosen elements can come from any positions in the array. The question is whether there exists a selection of exactly x elements whose sum is odd.

codeforcescompetitive-programmingbrute-forceimplementationmath
CF 1364C - Ehab and Prefix MEXs

The exercise asks us to investigate approximate polynomial greatest common divisors (gcds) and the behavior of Euclid's algorithm when the polynomial coefficients are floating-point numbers.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedy
CF 1364A - XXXXX

We are given an array of integers and a number $x$ that Ehab dislikes. The goal is to find the length of the longest contiguous subarray whose sum is not divisible by $x$. Each test case gives a new array and a new $x$.

codeforcescompetitive-programmingbrute-forcedata-structuresnumber-theorytwo-pointers
CF 1365A - Matrix Game

We are given a grid where some cells are already occupied. Two players alternate turns, and on each move a player must pick a previously unused cell under a strong restriction: no two chosen cells are allowed to share a row or a column.

codeforcescompetitive-programminggamesgreedyimplementation
CF 1365E - Maximum Subsequence Value

We are given an array of up to 500 positive integers. We may choose any non-empty subsequence and compute its value according to a bitwise rule.

codeforcescompetitive-programmingbrute-forceconstructive-algorithms
CF 1365B - Trouble Sort

We are given a sequence of numbers ai each tagged with a type bi that is either 0 or 1. The task is to determine if it is possible to sort the sequence in non-decreasing order by only swapping elements of different types.

codeforcescompetitive-programmingconstructive-algorithmsimplementation
CF 1366E - Two Arrays

We are given two arrays, a and b. Array b is strictly increasing, and our task is to partition array a into exactly m consecutive subarrays, where each subarray's minimum matches the corresponding element in b.

codeforcescompetitive-programmingbinary-searchbrute-forcecombinatoricsconstructive-algorithmsdptwo-pointers
CF 1366G - Construct the String

We are given a string s consisting of lowercase letters and dots. If we process this string from left to right, every letter is pushed onto a stack and every dot removes the current top character. The function f(s) returns the final stack contents as a string.

codeforcescompetitive-programmingdata-structuresdpstrings
CF 1366C - Palindromic Paths

We have a binary matrix. A path starts at the top-left cell and ends at the bottom-right cell, moving only right or down. Every path visits exactly one cell from each "distance layer" measured from the start.

codeforcescompetitive-programminggreedymath
CF 1366B - Shuffle

We are given an array of size $n$ initialized with all zeros except for a single one at position $x$. The array is 1-indexed. We then have $m$ operations, each defined by a range $[li, ri]$. In each operation, we can swap any two elements within that range.

codeforcescompetitive-programmingmathtwo-pointers
CF 1367F1 - Flying Sort (Easy Version)

We are given an array of distinct integers, and our task is to sort it in non-decreasing order using two kinds of operations: moving any element to the front of the array or moving any element to the back.

codeforcescompetitive-programmingdpgreedytwo-pointers
CF 1367C - Social Distance

The solution does not correctly address the statement being proved, and it does not provide a valid argument that the pseudo-remainder must be divisible by the leading coefficient $l(v)$.

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 1367A - Short Substrings

The problem gives you a string b that is formed by taking every consecutive pair of characters from some secret string a and concatenating them. Your goal is to reconstruct the original string a.

codeforcescompetitive-programmingimplementationstrings
CF 1368E - Ski Accidents

We are working with a directed acyclic structure where each vertex represents a station on a mountain ski resort and every edge represents a one-way ski track that always goes downhill.

codeforcescompetitive-programmingconstructive-algorithmsgraphsgreedy
CF 1368H1 - Breadboard Capacity (easy version)

We have a rectangular breadboard with n rows and m columns of internal nodes. Along the four sides of the board there are ports. The left and right sides contribute n ports each, while the top and bottom sides contribute m ports each. Every port is colored either red or blue.

codeforcescompetitive-programmingdpflowsgreedy
CF 1368A - C+=

We start with two positive integers, a and b. In one operation we may add one variable into the other: a += b or b += a. Only one value changes per operation. Our goal is to make at least one of the two numbers become strictly larger than a given limit n.

codeforcescompetitive-programmingbrute-forcegreedyimplementationmath
CF 1368B - Codeforces Subsequences

The task is to construct a string using only lowercase English letters such that the string contains at least k subsequences that spell out the word "codeforces". A subsequence is formed by selecting characters from the string in order without rearranging them.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedymathstrings
CF 1369A - FashionabLee

The task asks us to determine whether a given regular polygon can be oriented such that one of its edges is parallel to the horizontal axis and another edge is parallel to the vertical axis simultaneously.

codeforcescompetitive-programminggeometrymath
CF 1369B - AccurateLee

We are given a binary string and allowed to repeatedly remove characters under a very specific local rule: whenever a 1 appears immediately followed by a 0, we may delete exactly one of those two characters, shrinking the string each time.

codeforcescompetitive-programminggreedyimplementationstrings
CF 1370E - Binary Subsequence Rotation

We are given two binary strings of equal length, and we want to transform the first string into the second using a very unusual operation.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsdata-structuresgreedy
CF 1370A - Maximum GCD

We are asked to find the largest possible greatest common divisor among all pairs of distinct integers from 1 to n. For a given n, we need the maximum gcd of any two numbers a and b where 1 ≤ a < b ≤ n.

codeforcescompetitive-programminggreedyimplementationmathnumber-theory
CF 1371E2 - Asterism (Hard Version)

We are given a fixed list of enemy strengths, and we imagine choosing a starting number of candies $x$. For any such $x$, Yuzu faces all enemies in some order.

codeforcescompetitive-programmingbinary-searchcombinatoricsdpmathnumber-theorysortings
CF 1371E1 - Asterism (Easy Version)

We are asked to find all positive integers $x$ such that, if Yuzu starts with $x$ candies, there exists a number of ways to defeat all enemies in sequence (a permutation of enemies) so that she always has at least as many candies as her current opponent.

codeforcescompetitive-programmingbinary-searchbrute-forcecombinatoricsmathnumber-theorysortings
CF 1371A - Magical Sticks

We have a set of sticks with lengths from 1 to $n$, one stick of each length. Rocher can connect any two sticks to form a new stick whose length is the sum of the two, removing the original sticks in the process.

codeforcescompetitive-programmingmath
CF 1371B - Magical Calendar

We have a magical calendar where the length of a week is flexible: Alice can choose any integer $k$ from $1$ to $r$ to be the number of days in a week. Alice wants to paint $n$ consecutive days on this calendar.

codeforcescompetitive-programmingmath
CF 1372E - Omkar and Last Floor

We are asked to design the last floor of Omkar's house, represented as an $n times m$ grid initially filled with zeros. Each row is subdivided into contiguous intervals. In each interval, we are allowed to change exactly one zero into a one.

codeforcescompetitive-programmingdpgreedytwo-pointers
CF 1372B - Omkar and Last Class of Math

The proposed solution does not answer the exercise that was asked. The exercise is: Compute the pseudo-quotient $q(x)$ and pseudo-remainder $r(x)$ for the given polynomials $u(x)$ and $v(x)$ over the integers.

codeforcescompetitive-programminggreedymathnumber-theory
CF 1373F - Network Coverage

We have a set of cities arranged in a circle around a central capital, and each city has a number of households that need network coverage.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsdata-structuresgreedy
CF 1374E2 - Reading Books (hard version)

We are given a collection of books, where each book has a reading time and two independent preference flags, one for Alice and one for Bob. We must select exactly $m$ books. The chosen set is shared, so both of them read the same books together.

codeforcescompetitive-programmingdata-structuresgreedyimplementationsortingsternary-searchtwo-pointers
CF 1374A - Required Remainder

Let $Nge 1$ be fixed. An $m$-survivor is a positive integer all of whose prime factors exceed $m$. Let $$f(x,m)={nle x:text{$n$ is an $m$-survivor}},$$ and let $$fk(x,m)={nle x:text{$n$ is an $m$-survivor having exactly $k$ prime factors}},$$ where prime factors are counted…

codeforcescompetitive-programmingmath
CF 1374C - Move Brackets

We are given a string of brackets consisting of exactly half opening brackets '(' and half closing brackets ')', and our goal is to make it a valid, balanced bracket sequence.

codeforcescompetitive-programminggreedystrings
CF 1375G - Tree Modification

Let $Nge 1$ be fixed. An $m$-survivor is a positive integer all of whose prime factors exceed $m$. Let $$f(x,m)={nle x:text{$n$ is an $m$-survivor}},$$ and let $$fk(x,m)={nle x:text{$n$ is an $m$-survivor having exactly $k$ prime factors}},$$ where prime factors are counted…

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdfs-and-similargraph-matchingsgraphstrees
CF 1375C - Element Extermination

Let $Nge 1$ be fixed. An $m$-survivor is a positive integer all of whose prime factors exceed $m$. Let $$f(x,m)={nle x:text{$n$ is an $m$-survivor}},$$ and let $$fk(x,m)={nle x:text{$n$ is an $m$-survivor having exactly $k$ prime factors}},$$ where prime factors are counted…

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresgreedy
CF 1379E - Inverse Genealogy

Let $Nge 1$ be fixed. An $m$-survivor is a positive integer all of whose prime factors exceed $m$. Let $$f(x,m)={nle x:text{$n$ is an $m$-survivor}},$$ and let $$fk(x,m)={nle x:text{$n$ is an $m$-survivor having exactly $k$ prime factors}},$$ where prime factors are counted…

codeforcescompetitive-programmingconstructive-algorithmsdivide-and-conquerdpmathtrees
CF 1379B - Dubious Cyrpto

The problem asks us to reverse-engineer a simple integer encoding scheme. Pasha encrypts a strictly positive integer $n$ using three numbers $a$, $b$, and $c$, all constrained to lie between two given bounds $l$ and $r$. The encryption formula is $m = n cdot a + b - c$.

codeforcescompetitive-programmingbinary-searchbrute-forcemathnumber-theory
CF 1380F - Strange Addition

The revised submission correctly identifies the structure of the problem: it must first maximize the number of leading digits equal to $d$, then select the largest 50-digit prime with that prefix.

codeforcescompetitive-programmingdata-structuresdpmatrices
CF 1380C - Create The Teams

We have a group of programmers, each with a skill value. We want to form as many teams as possible. A team is valid if: $$(text{team size}) times (text{minimum skill in the team}) ge x$$ Every programmer can belong to at most one team, and some programmers may remain unused.

codeforcescompetitive-programmingbrute-forcedpgreedyimplementationsortings
CF 1381E - Origami

I can't write a correct editorial for Codeforces 1381E from the information provided here because the actual problem statement, input format, and constraints are missing. Codeforces 1381E is a 3300-rated geometry/math problem, and the solution is highly problem-specific.

codeforcescompetitive-programminggeometrymathsortings
CF 1381A2 - Prefix Flip (Hard Version)

We are given two binary strings, a and b, of equal length n. The task is to transform a into b using a sequence of prefix flip operations. A prefix flip of length k reverses the first k characters of a and simultaneously inverts all bits within that prefix.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresimplementationstringstwo-pointers
CF 1383F - Special Edges

We have a directed flow network with source 1 and sink n. The first k edges are special. Their capacities are not fixed. Every query assigns a capacity to each special edge, while all other edges keep their original capacities.

codeforcescompetitive-programmingflowsgraphs
CF 1383A - String Transformation 1

We are given two strings A and B of the same length, using only the first 20 lowercase letters from a to t. We are allowed to repeatedly select a group of positions in A that all contain the same letter x and replace them with a strictly larger letter y.

codeforcescompetitive-programmingdsugraphsgreedysortingsstringstreestwo-pointers
CF 1383B - GameGame

The problem describes a two-player game played on an array of non-negative integers. The players take turns removing an element from the array and XOR-ing it with their current score.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsdpgamesgreedymath
CF 1385B - Restore the Permutation by Merger

We are given an array of length $2n$. This array was created by taking a permutation $p$ of the numbers $1$ through $n$, making a second copy of the same permutation, and interleaving the two copies while preserving the relative order inside each copy.

codeforcescompetitive-programminggreedy