brain

tamnd's digital brain — notes, problems, research

41650 notes

CF 1305A - Kuroni and the Gifts

Yes, the inequality $nu(n) le 2^{l(n) - lambda(n)}$ holds for all positive integers $n$. Consider an addition chain of minimal length $l(n)$ and let $lambda(n)$ be the length of a shortest chain consisting only of doubling steps.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedysortings
CF 1307C - Cow and Message

We are given a string of lowercase English letters. A message is any subsequence whose chosen indices form an arithmetic progression. The progression can have any positive difference, including the special case of length one. The task is not to find the message itself.

codeforcescompetitive-programmingbrute-forcedpmathstrings
CF 1307E - Cow and Treats

Yes, the inequality $nu(n) le 2^{l(n) - lambda(n)}$ holds for all positive integers $n$. Consider an addition chain of minimal length $l(n)$ and let $lambda(n)$ be the length of a shortest chain consisting only of doubling steps.

codeforcescompetitive-programmingbinary-searchcombinatoricsdpgreedyimplementationmath
CF 1310A - Recommendations

Codeforces 1310A: Recommendations

codeforcescompetitive-programmingdata-structuresgreedysortings
CF 1310F - Bad Cryptography

Yes, the inequality $nu(n) le 2^{l(n) - lambda(n)}$ holds for all positive integers $n$. Consider an addition chain of minimal length $l(n)$ and let $lambda(n)$ be the length of a shortest chain consisting only of doubling steps.

codeforcescompetitive-programmingmathnumber-theory
CF 1310C - Au Pont Rouge

Yes, the inequality $nu(n) le 2^{l(n) - lambda(n)}$ holds for all positive integers $n$. Consider an addition chain of minimal length $l(n)$ and let $lambda(n)$ be the length of a shortest chain consisting only of doubling steps.

codeforcescompetitive-programmingbinary-searchdpstrings
CF 1311C - Perform the Combo

We are given a fixed string s that represents a sequence of button presses in a fighting game combo. The player repeatedly attempts to type this entire string from left to right. However, the process is interrupted.

codeforcescompetitive-programmingbrute-force
CF 1311A - Add Odd or Subtract Even

Yes, the inequality $nu(n) le 2^{l(n) - lambda(n)}$ holds for all positive integers $n$. Consider an addition chain of minimal length $l(n)$ and let $lambda(n)$ be the length of a shortest chain consisting only of doubling steps.

codeforcescompetitive-programminggreedyimplementationmath
CF 1312D - Count the Arrays

Yes, the inequality $nu(n) le 2^{l(n) - lambda(n)}$ holds for all positive integers $n$. Consider an addition chain of minimal length $l(n)$ and let $lambda(n)$ be the length of a shortest chain consisting only of doubling steps.

codeforcescompetitive-programmingcombinatoricsmath
CF 1312G - Autocompletion

We are given a rooted construction of many strings where every node represents a string and every edge corresponds to appending one character. The root is the empty string, and each node i is created by taking its parent string pi and appending a lowercase letter ci.

codeforcescompetitive-programmingdata-structuresdfs-and-similardp
CF 1312C - Adding Powers

We are given an array of non-negative integers, and a base $k ge 2$. Starting from an array of zeroes of the same length, we can repeatedly pick a step $i$ and add $k^i$ to any single element of the array, or skip the step.

codeforcescompetitive-programmingbitmasksgreedyimplementationmathnumber-theoryternary-search
CF 1313D - Happy New Year

We are given a large line of positions from 1 to $m$, and a collection of $n$ intervals. Each interval represents a “spell” that, when used, adds one candy to every position inside its range. Each spell can be used at most once.

codeforcescompetitive-programmingbitmasksdpimplementation
CF 1313C1 - Skyscrapers (easy version)

Yes, the inequality $nu(n) le 2^{l(n) - lambda(n)}$ holds for all positive integers $n$. Consider an addition chain of minimal length $l(n)$ and let $lambda(n)$ be the length of a shortest chain consisting only of doubling steps.

codeforcescompetitive-programmingbrute-forcedata-structuresdpgreedy
CF 1313B - Different Rules

Each participant in the contest has two independent rankings: one from the first round and one from the second round. No ties exist in either round, so each round is a permutation of ranks from 1 to n. A participant’s final value is the sum of their two ranks.

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementationmath
CF 1316B - String Modification

We are given a string of length $n$, and Vasya wants to perform a sequence of substring reversals to produce the lexicographically smallest string possible. The operation is controlled by an integer $k$, which specifies the length of each consecutive substring to reverse.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsimplementationsortingsstrings
CF 1316C - Primitive Primes

We are given two polynomials, each represented by an array of positive integers, which are their coefficients. The first polynomial has $n$ terms and coefficients $a0, a1, dots, a{n-1}$, the second has $m$ terms with coefficients $b0, b1, dots, b{m-1}$.

codeforcescompetitive-programmingconstructive-algorithmsmathternary-search
CF 1320C - World of Darkraft: Battle for Azathoth

Yes, the inequality $nu(n) le 2^{l(n) - lambda(n)}$ holds for all positive integers $n$. Consider an addition chain of minimal length $l(n)$ and let $lambda(n)$ be the length of a shortest chain consisting only of doubling steps.

codeforcescompetitive-programmingbrute-forcedata-structuressortings
CF 1322C - Instant Noodles

Yes, the inequality $nu(n) le 2^{l(n) - lambda(n)}$ holds for all positive integers $n$. Consider an addition chain of minimal length $l(n)$ and let $lambda(n)$ be the length of a shortest chain consisting only of doubling steps.

codeforcescompetitive-programminggraphshashingmathnumber-theory
CF 1325C - Ehab and Path-etic MEXs

We are given a tree with $n$ nodes, represented by $n-1$ edges connecting pairs of nodes. Each edge must be assigned a distinct integer label between $0$ and $n-2$.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similargreedytrees
CF 1326F2 - Wise Men (Hard Version)

We are asked to analyze permutations of a group of $n$ wise men, where some pairs of them know each other. For each permutation of these wise men, we can create a binary string of length $n-1$ indicating adjacency of acquaintances: a '1' if two consecutive wise men in the…

codeforcescompetitive-programmingbitmasksdpmath
CF 1326A - Bad Ugly Numbers

We need to construct a positive decimal number with exactly n digits. Every digit must be nonzero, and the whole number must fail divisibility by each digit that appears in it. For each test case, the input gives only the required length n.

codeforcescompetitive-programmingconstructive-algorithmsnumber-theory
CF 1326D1 - Prefix-Suffix Palindrome (Easy version)

We are given a string consisting of lowercase English letters, and the task is to construct the longest palindrome by combining a prefix and a suffix of this string.

codeforcescompetitive-programminghashingstring-suffix-structuresstrings
CF 1327A - Sum of Odd Integers

The problem asks whether a given integer n can be expressed as the sum of exactly k distinct positive odd integers. Each test case provides n and k, and the answer is either "YES" or "NO". Odd integers are numbers not divisible by 2, so valid candidates are 1, 3, 5, 7,....

codeforcescompetitive-programmingmath
CF 1328A - Divisibility Problem

Each test case contains two positive integers. We may only perform one kind of operation: increase the first number by one.

codeforcescompetitive-programmingmath
CF 1328E - Tree Queries

The solution does not successfully establish what Exercise 4.6.3.13 asks. The positive part is that the displayed constructions are now genuine star chains.

codeforcescompetitive-programmingdfs-and-similargraphstrees
CF 1330B - Dreamoon Likes Permutations

The solution does not successfully establish what Exercise 4.6.3.13 asks. The positive part is that the displayed constructions are now genuine star chains.

codeforcescompetitive-programmingimplementationmath
CF 1331H - It's showtime

The problem presents a single integer input that encodes two pieces of information. The integer can be decomposed as input = 1000 n + mod, where n is the number for which we want the double factorial and mod is the modulus to compute it under.

codeforcescompetitive-programming*special
CF 1331B - Limericks

The problem asks us to compute a specific numeric property related to an integer input, denoted as a. While the problem statement is written in a poetic form, the underlying task is to find the number of integers less than a that are coprime to a.

codeforcescompetitive-programming*specialmathnumber-theory
CF 1331A - Is it rated?

The solution does not successfully establish what Exercise 4.6.3.13 asks. The positive part is that the displayed constructions are now genuine star chains.

codeforcescompetitive-programming*special
CF 1332F - Independent Set

We are given a tree with $n$ vertices. For every nonempty subset of edges $E'$, we build the edge-induced subgraph consisting of those edges and every endpoint that appears in at least one selected edge. For that subgraph we count its independent sets.

codeforcescompetitive-programmingdfs-and-similardptrees
CF 1332C - K-Complete Word

We are given a string s of length n and an integer k such that n is divisible by k. A string is considered k-complete if it is both a palindrome and periodic with period k. Being a palindrome means the string reads the same forwards and backwards.

codeforcescompetitive-programmingdfs-and-similardsugreedyimplementationstrings
CF 1332B - Composite Coloring

The reviewer is correct. The displayed sequences are not addition chains, because the quantities $2^g,2^h,2^k,2^m$ were used as summands without first appearing as chain elements. The argument must be rebuilt from the definition of a star chain.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedymathnumber-theory
CF 1333D - Challenges in school №41

The reviewer is correct. The displayed sequences are not addition chains, because the quantities $2^g,2^h,2^k,2^m$ were used as summands without first appearing as chain elements. The argument must be rebuilt from the definition of a star chain.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgamesgraphsgreedyimplementationsortings
CF 1334G - Substring Search

We are asked to find all substrings of a string t that "match" another string s according to a flexible definition of equality.

codeforcescompetitive-programmingbitmasksbrute-forcefft
CF 1334E - Divisor Paths

We are given a number $D$ and need to reason about all of its divisors. The problem defines a graph whose vertices are all divisors of $D$. An edge exists from a divisor $y$ to a larger divisor $x$ if $x$ is divisible by $y$ and the quotient $x / y$ is prime.

codeforcescompetitive-programmingcombinatoricsgraphsgreedymathnumber-theory
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 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 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 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