brain

tamnd's digital brain — notes, problems, research

41650 notes

CF 985B - Switches and Lamps

We are given a collection of switches, each of which controls a subset of lamps. When a switch is pressed, every lamp connected to it turns on permanently. Once a lamp is on, it never turns off again, even if other switches affecting it are pressed later.

codeforcescompetitive-programmingimplementation
CF 985A - Chess Placing

We are given a line of length $n$, where $n$ is even, and each position is either empty or contains exactly one chess piece. The board is colored in an alternating pattern starting with black at position 1, so positions look like B, W, B, W, and so on.

codeforcescompetitive-programmingimplementation
CF 986F - Oppa Funcan Style Remastered

We are asked whether it is possible to design a function on a very large set of positions, up to $10^{18}$, that behaves like a deterministic jump rule applied every second. Each position points to exactly one next position, and every element moves according to this fixed rule.

codeforcescompetitive-programminggraphsmathnumber-theoryshortest-paths
CF 986A - Fair

We are given a connected undirected graph of towns. Each town produces exactly one type of goods, and there are at most 100 distinct types overall. For any pair of towns, moving goods between them costs the shortest-path distance in the graph, where each road has unit length.

codeforcescompetitive-programminggraphsgreedynumber-theoryshortest-paths
CF 986B - Petr and Permutations

We are given a permutation of size $n$, and we are told it was produced by one of two random procedures. Both procedures start from the identity permutation $[1, 2, 3, dots, n]$, then repeatedly pick two distinct positions uniformly at random and swap them.

codeforcescompetitive-programmingcombinatoricsmath
CF 987B - High School: Become Human

We are given two positive integers $x$ and $y$, and we are asked to compare the values of two exponentials: $x^y$ and $y^x$.

codeforcescompetitive-programmingmath
CF 987C - Three displays

We are given a sequence of displays arranged along a line. Each display has a fixed position in this order, a font size, and a rental cost.

codeforcescompetitive-programmingbrute-forcedpimplementation
CF 988F - Rain and Umbrellas

We are given a line from position 0 to position $a$. Polycarp moves only to the right, one unit at a time. Some disjoint intervals on this line are rainy, and if he traverses an edge fully contained inside any rainy interval, he must carry at least one umbrella during that…

codeforcescompetitive-programmingdp
CF 988C - Equal Sums

We are given several independent integer arrays. From each array we are allowed to remove exactly one element, and this creates a “modified sum” for that array, meaning the original sum minus the removed element.

codeforcescompetitive-programmingimplementationsortings
CF 988B - Substrings Sort

We are given a collection of strings, and we are allowed to rearrange them in any order. After rearranging, we want a very specific nesting property: every string must contain all strings that appear before it as substrings.

codeforcescompetitive-programmingsortingsstrings
CF 989D - A Shade of Moonlight

We are given several “clouds” moving along a line. Each cloud is a segment of fixed length $l$, initially placed at position $xi$, and then moving over time with constant velocity $vi + w$, where $vi$ is either $+1$ or $-1$, and $w$ is a global wind parameter we are allowed…

codeforcescompetitive-programmingbinary-searchgeometrymathsortingstwo-pointers
CF 989C - A Mist of Florescence

We are asked to construct a rectangular grid and fill it with four letters, each representing a type of flower. The grid should be designed so that when we look at each letter separately, counting connected components using edge adjacency, the number of components for the four…

codeforcescompetitive-programmingconstructive-algorithmsgraphs
CF 989A - A Blend of Springtime

We are given a short string representing a row of cells. Each cell is either empty or contains exactly one flower of one of three types, encoded as the letters A, B, and C.

codeforcescompetitive-programmingimplementationstrings
CF 990C - Bracket Sequences Concatenation Problem

We are given a collection of strings, each consisting only of opening and closing parentheses. Think of each string as a small “building block” of a larger bracket expression.

codeforcescompetitive-programmingimplementation
CF 990E - Post Lamps

We are placing lamps along a one-dimensional street that runs from position 0 up to position n. Some positions are forbidden, meaning we are not allowed to place a lamp there, but otherwise we may choose any allowed position as a base.

codeforcescompetitive-programmingbrute-forcegreedy
CF 990A - Commentary Boxes

We are given an initial number of commentary boxes and a required number of delegations. Every delegation must receive exactly the same number of boxes, and all existing boxes must be used so that nothing remains idle.

codeforcescompetitive-programmingimplementationmath
CF 991D - Bishwock

We are given a board with two rows and $n$ columns, so each cell is either empty or blocked. A blocked cell cannot be used. Our task is to place as many fixed L-shaped pieces as possible on the board, where each piece occupies exactly three cells in one of four orientations.

codeforcescompetitive-programmingdpgreedy
CF 991F - Concise and clear

We are given a single integer $n$ up to $10^{10}$. The task is not to compute anything from it, but to rewrite it as a mathematical expression using only digits, plus, multiplication, and exponentiation.

codeforcescompetitive-programmingbrute-forcegreedyimplementationmath
CF 991A - If at first you don't succeed...

We are given summary statistics about how students in a group behaved after an exam. Every student belongs to exactly one of four categories: they either visited only BugDonalds, only BeaverKing, both restaurants, or stayed at home because they failed the exam.

codeforcescompetitive-programmingimplementation
CF 991C - Candies

We are given an initial pile of candies and a fixed daily rule that transforms this pile over time. Each morning Vasya chooses a constant number k.

codeforcescompetitive-programmingbinary-searchimplementation
CF 992A - Nastya and an Array

We are given a list of integers, and we are allowed to repeatedly apply an operation that changes the array in a very specific way: in one move, we choose an integer value and add it to every element that is currently non-zero. Zeros stay untouched during that operation.

codeforcescompetitive-programmingimplementationsortings
CF 992B - Nastya Studies Informatics

We are given four integers $l, r, x, y$. The task is to count ordered pairs $(a, b)$ such that both numbers lie inside the interval $[l, r]$, and their greatest common divisor is exactly $x$ while their least common multiple is exactly $y$.

codeforcescompetitive-programmingmathnumber-theory
CF 993F - The Moral Dilemma

We are given a fixed logical circuit built in two layers above a set of binary input features. The first layer contains a small number of gates, each reading exactly two input variables and producing a boolean output using one of four operations: AND, OR, NAND, or NOR.

codeforcescompetitive-programming
CF 993E - Nikita and Order Statistics

We are given an array and a threshold value x. For every possible integer k from 0 to n, we need to count how many subarrays have exactly k elements strictly smaller than x.

codeforcescompetitive-programmingchinese-remainder-theoremfftmath
CF 993B - Open Communication

Two people each receive a secret pair of distinct digits from 1 to 9. The two hidden pairs are linked by a single property: they share exactly one common number. You are not given the hidden pairs directly.

codeforcescompetitive-programmingbitmasksbrute-force
CF 993D - Compute Power

We are given a collection of tasks. Each task has a “power” value and a “processor requirement”. A machine can run at most two tasks, but there is a strict ordering rule if it runs two: the first task assigned to a machine is allowed to be arbitrary, while the second…

codeforcescompetitive-programmingbinary-searchdpgreedy
CF 993C - Careful Maneuvering

We are given two sets of enemy ships, all lying on two vertical lines: one group is fixed at $x=-100$, the other at $x=100$. Each ship has an integer $y$-coordinate, and multiple ships may share the same $y$.

codeforcescompetitive-programmingbitmasksbrute-forcegeometry
CF 994B - Knights of a Polygonal Table

Each knight comes with two attributes, a fighting strength and a stash of coins. A knight is only able to defeat knights with strictly smaller strength, and every victory transfers the defeated knight’s coins to the winner.

codeforcescompetitive-programminggreedyimplementationsortings
CF 994A - Fingerprints

The input describes a fixed sequence of digits, like a recorded keypad history, and a separate set of digits that correspond to keys with fingerprints.

codeforcescompetitive-programmingimplementation
CF 995F - Cowmpany Cowmpensation

We are given a rooted tree of employees where employee 1 is the CEO. Every other employee has exactly one direct superior, forming a hierarchy.

codeforcescompetitive-programmingcombinatoricsdpmathtrees
CF 995A - Tesla

We are given a parking grid with 4 rows and $n le 50$ columns. Each cell either holds a car or is empty. Cars are uniquely labeled from $1$ to $k$, with $k le 2n$. The middle two rows contain the cars in their starting positions.

codeforcescompetitive-programmingconstructive-algorithmsimplementation
CF 995B - Suit and Tie

We are given a lineup of $2n$ people where each integer label from $1$ to $n$ appears exactly twice. Each label represents a couple, so the goal is to rearrange the line so that both occurrences of every number sit next to each other.

codeforcescompetitive-programminggreedyimplementationmath
CF 996A - Hit the Lottery

We are given a single integer representing the total amount of money Allen wants to withdraw. The bank only dispenses cash using fixed denominations: 1, 5, 10, 20, and 100.

codeforcescompetitive-programmingdpgreedy
CF 997E - Good Subsegments

We are given a permutation, meaning every value from 1 to n appears exactly once in an array. For any contiguous segment of this array, we call it good when it has a very strong structural property: if you take the smallest and largest values inside that segment, then every…

codeforcescompetitive-programmingdata-structures
CF 997C - Sky Full of Stars

We are working with an $n times n$ grid where each cell independently takes one of three colors. A coloring is considered “good” if at least one full row or at least one full column ends up monochromatic, meaning every cell in that row or column shares the same color.

codeforcescompetitive-programmingcombinatoricsmath
CF 997A - Convert to Ones

We are given a binary string and we want to transform it into a string of all ones. Two types of operations are available: we can reverse any contiguous segment for a cost, or we can flip all bits in a contiguous segment for a cost.

codeforcescompetitive-programmingbrute-forcegreedyimplementationmath
CF 998A - Balloons

We are given several packets, each packet containing a known number of balloons. The task is to split these packets between two people so that each packet goes entirely to exactly one of them. No packet can be broken, and both people must receive at least one packet.

codeforcescompetitive-programmingconstructive-algorithmsimplementation
CF 999E - Reachability from the Capital

We are given a directed graph where cities are nodes and roads are one-way edges. One city is designated as the capital. The goal is to ensure that every city can be reached by following directed roads starting from the capital.

codeforcescompetitive-programmingdfs-and-similargraphsgreedy
CF 999A - Mishka and Contest

We are given a list of problems arranged in a fixed order from left to right, where each problem has a difficulty value. Mishka has a skill level k, meaning he can only solve problems whose difficulty does not exceed k.

codeforcescompetitive-programmingbrute-forceimplementation
CF 999B - Reversing Encryption

We are given a string that has already been transformed by a deterministic process involving repeated reversals of prefixes.

codeforcescompetitive-programmingimplementation
CF 1000G - Two-Paths

We are working on a weighted tree where every vertex has a positive value and every edge has a positive cost. A path is not required to be simple in the usual sense: edges are allowed to be traversed up to two times, and vertices can be visited multiple times.

codeforcescompetitive-programmingdata-structuresdptrees
CF 1000F - One Occurrence

We are given a static array and many independent queries, each query asking us to inspect a contiguous segment of the array and return any value that appears exactly once inside that segment. If no such value exists in that segment, the answer is zero.

codeforcescompetitive-programmingdata-structuresdivide-and-conquer
CF 1000B - Light It Up

We are given a time interval from 0 to M during which a lamp is initially on. The lamp has a predefined list of switching moments. At each moment in this list, the lamp flips between on and off instantly.

codeforcescompetitive-programminggreedy
CF 1000C - Covered Points Count

We are given a collection of segments on a very large number line. Each segment covers every integer point between its endpoints, including both ends. Different segments may overlap in arbitrary ways: they can be disjoint, nested, identical, or partially intersecting.

codeforcescompetitive-programmingdata-structuresimplementationsortings
CF 1001I - Deutsch-Jozsa algorithm

We are given access to a black-box quantum oracle that encodes a boolean function over all $2^N$ binary inputs of length $N$. For any input bitstring $x$, the oracle evaluates $f(x)$ without revealing the function explicitly.

codeforcescompetitive-programming*special
CF 1001H - Oracle for f(x) = parity of the number of 1s in x

We are given a register of qubits representing an integer in binary form, along with an additional qubit that acts as a target bit.

codeforcescompetitive-programming*special
CF 1001G - Oracle for f(x) = k-th element of x

We are given a very small quantum program interface: an array of qubits x, a single qubit y, and an index k. The task is to implement a reversible transformation that encodes a classical function into a quantum oracle. The function itself is extremely simple.

codeforcescompetitive-programming*special
CF 1001F - Distinguish multi-qubit basis states

We are given an array of qubits, but the important promise is simpler than the quantum framing suggests: the system is guaranteed to be in one of two classical computational basis states.

codeforcescompetitive-programming*special
CF 1001C - Generate GHZ state

We are given a small register of up to eight qubits, all initially prepared in the all-zero computational basis state.

codeforcescompetitive-programming*special
CF 1001D - Distinguish plus state and minus state

We are given a single qubit that has been prepared in one of two possible states. These two states are not computational basis states like The task is to interact with this qubit using allowed quantum operations, perform a measurement, and return an integer that identifies…

codeforcescompetitive-programming*special
CF 1001E - Distinguish Bell states

We are given a pair of qubits that were prepared in one of four specific two-qubit entangled states. These four states form the Bell basis, meaning they are maximally entangled and differ only by relative phase and bit flips, not by local classical information on each qubit.

codeforcescompetitive-programming*special
CF 1001B - Generate Bell state

We are working in a quantum setting with two qubits that initially form the computational basis state corresponding to both being zero. The task is to transform these two qubits in-place into one of four specific entangled states, chosen by an integer index from 0 to 3.

codeforcescompetitive-programming*special
CF 1001A - Generate plus state or minus state

We are working in a quantum programming setting where a single qubit is already in a known initial basis state, and we are asked to transform it into one of two target basis states depending on the value of an integer parameter called sign.

codeforcescompetitive-programming*special
CF 1002E2 - Another array reconstruction algorithm

We are given a black-box quantum operation that acts on N input qubits plus one auxiliary qubit. Internally, this operation encodes a hidden binary array of length N.

codeforcescompetitive-programming*special
CF 1002E1 - Bernstein-Vazirani algorithm

We are interacting with an oracle that hides a binary string of length $N$. Each position in this hidden string is either 0 or 1. The oracle does not reveal the string directly.

codeforcescompetitive-programming*special
CF 1002D3 - Oracle for majority function

We are working in a quantum setting where three input qubits represent a binary vector of length three, and an additional qubit acts as an output register.

codeforcescompetitive-programming*special
CF 1002D2 - Oracle for f(x) = b * x + (1 - b) * (1 - x) mod 2

We are given a small quantum circuit setting where the input consists of an $N$-qubit register $x$, a single target qubit $y$, and a classical binary vector $b$ of length $N$.

codeforcescompetitive-programming*special
CF 1002C2 - Distinguish zero state and plus state without errors

We are given a single qubit guaranteed to be in one of two possible pure states. One state is the classical basis state $ The output of the operation must be one of three integers.

codeforcescompetitive-programming*special
CF 1002D1 - Oracle for f(x) = b * x mod 2

We are given a very small quantum system consisting of two parts: an input register of N qubits and a single output qubit. Alongside this, we are given a classical binary vector b of length N.

codeforcescompetitive-programming*special
CF 1002C1 - Distinguish zero state and plus state with minimum error

We are given a single qubit that is prepared in one of two possible pure states with equal probability. One of them is the computational basis state $ The task is not to deterministically identify the state, but to implement a quantum procedure that produces a classical bit…

codeforcescompetitive-programming*special
CF 1002B3 - Distinguish four 2-qubit states

We are given a system of two qubits that is guaranteed to be in one of four mutually orthogonal entangled states. These states form a complete basis for two-qubit space, so exactly one of them is present, and the task is to identify which one.

codeforcescompetitive-programming*special
CF 1002B4 - Distinguish four 2-qubit states - 2

We are given a 2-qubit system that is guaranteed to be in exactly one of four mutually orthogonal quantum states. Each of these states is a different encoding of a two-bit piece of information, but not in the standard computational basis.

codeforcescompetitive-programming*special
CF 1002A4 - Generate W state

We are working with a register of $N = 2^k$ qubits, where $k le 4$, so $N le 16$. The system starts in the all-zero computational basis state, meaning every qubit is in $ A W state over $N$ qubits is a uniform superposition of all basis states that contain exactly one qubit in…

codeforcescompetitive-programming*special
CF 1002B2 - Distinguish GHZ state and W state

We are given a small system of qubits, at most eight of them, prepared in one of two highly structured quantum states. One of them is the GHZ state, which behaves like a perfect global correlation between all qubits being simultaneously zero or simultaneously one when measured.

codeforcescompetitive-programming*special
CF 1002B1 - Distinguish zero state and W state

We are given a very small system of qubits, at most eight of them, and the system is guaranteed to be prepared in exactly one of two highly structured quantum states.

codeforcescompetitive-programming*special
CF 1002A3 - Generate superposition of two basis states

We are working in a quantum setting where an initial register of $N le 8$ qubits starts in the all-zero computational basis state. Alongside this register, we are given two classical bitstrings of equal length, each describing a valid basis state on these qubits.

codeforcescompetitive-programming*special
CF 1002A2 - Generate superposition of zero state and a basis state

We start with a register of up to eight qubits, all initialized in the all-zero computational basis state. Alongside this, we are given a classical description of another basis state as a boolean array, where each entry indicates whether the corresponding qubit should be in…

codeforcescompetitive-programming*special
CF 1002A1 - Generate superposition of all basis states

We start with a system of N independent two-level quantum bits, all initially in the state corresponding to zero. In computational terms, this is the single basis state where every qubit is 0.

codeforcescompetitive-programming*special
CF 1003E - Tree Constructing

We are asked to build a tree with a fixed number of nodes such that two structural constraints hold simultaneously: the longest simple path in the tree has length exactly d, and every vertex is incident to at most k edges. If no such tree can exist, we must report impossibility.

codeforcescompetitive-programmingconstructive-algorithmsgraphs
CF 1003D - Coins and Queries

We are given a multiset of coin values, where every coin is a power of two. Each query asks whether we can form a target sum using a subset of these coins, and if so, what the minimum number of coins needed is.

codeforcescompetitive-programminggreedy
CF 1003F - Abbreviation

We are given a document as a sequence of words. The structure is fixed: words are separated by single spaces, so the underlying object is really just an array of strings.

codeforcescompetitive-programmingdphashingstrings
CF 1003B - Binary String Constructing

We are asked to construct a binary string made of zeros and ones with two constraints that interact with each other in a nontrivial way. First, the string must contain exactly a zeros and exactly b ones, so the total length is fixed as n = a + b.

codeforcescompetitive-programmingconstructive-algorithms
CF 1003C - Intense Heat

We are given a sequence of daily temperatures and asked to evaluate all contiguous time intervals whose length is at least a given threshold. For each such interval, we compute its average temperature, meaning the sum of its values divided by its length.

codeforcescompetitive-programmingbrute-forceimplementationmath
CF 1003A - Polycarp's Pockets

We are given a multiset of coin values, and we need to place every coin into a collection of “pockets” under a simple restriction: inside any single pocket, no value is allowed to repeat.

codeforcescompetitive-programmingimplementation
CF 1004F - Sonya and Bitwise OR

We are given an array that changes over time and we must repeatedly answer queries about subarrays inside a given segment. For any segment $[l, r]$, we consider every contiguous subarray $[L, R]$ fully contained inside it.

codeforcescompetitive-programmingbitmasksdata-structuresdivide-and-conquer
CF 1004E - Sonya and Ice Cream

We are given a weighted tree with up to $10^5$ vertices. Each edge has a positive length, so distances are standard shortest-path distances on the tree. We must choose a set of vertices that forms a single simple path in the tree, containing at most $k$ vertices.

codeforcescompetitive-programmingbinary-searchdata-structuresdpgreedyshortest-pathstrees
CF 1004D - Sonya and Matrix

We are given a multiset of integers that is known to come from a very specific geometric construction. Somewhere on an unknown grid of size $n times m$, there is exactly one cell containing a zero. Every other cell is filled with its Manhattan distance to that zero cell.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsimplementation
CF 1004B - Sonya and Exhibition

We are given a row of positions, each of which must be filled with one of two possible types. You can think of this as constructing a binary string of length $n$, where each position is either type A or type B.

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementationmath
CF 1004A - Sonya and Hotels

We are given a set of existing hotels placed on integer points along an infinite number line. We want to open one additional hotel at some integer coordinate. The requirement is that the closest existing hotel to this new one must be at distance exactly $d$.

codeforcescompetitive-programmingimplementation
CF 1004C - Sonya and Robots

We are given an array of integers laid out on a line. Two robots start just outside the array, one at the far left moving rightward and one at the far right moving leftward.

codeforcescompetitive-programmingconstructive-algorithmsimplementation
CF 1005F - Berland and the Shortest Paths

We are given a connected undirected graph of cities where city 1 is the capital. From this graph we must select exactly $n-1$ roads so that the selected edges still connect all cities, meaning they form a spanning tree.

codeforcescompetitive-programmingbrute-forcedfs-and-similargraphsshortest-paths
CF 1005E2 - Median on Segments (General Case Edition)

We are given a sequence of integers and a fixed value $m$. The task is to count how many contiguous subarrays have the property that when you sort the subarray, its median equals exactly $m$, where for even-length subarrays the median is defined as the left middle element.

codeforcescompetitive-programmingsortings
CF 1005E1 - Median on Segments (Permutations Edition)

We are given a permutation of the integers from 1 to n, and a distinguished value m that appears exactly once somewhere in the array. The task is to count how many contiguous subarrays have the property that, if we sort that subarray, the median element equals m.

codeforcescompetitive-programmingsortings
CF 1005A - Tanya and Stairways

We are given a single sequence of integers that represents what Tanya says while climbing stairs in a building. Each time she starts a new stairway, she always begins counting from 1 and increases by 1 for each step until she reaches the last step of that stairway.

codeforcescompetitive-programmingimplementation
CF 1005D - Polycarp and Div 3

We are given a very long decimal string and we are allowed to insert cuts between adjacent digits, splitting it into contiguous chunks.

codeforcescompetitive-programmingdpgreedynumber-theory
CF 1005C - Summarize to the Power of Two

We are given a multiset of integers, and we are allowed to delete any subset of them. After deletions, we want the remaining elements to satisfy a pairing condition: every remaining value must be able to find at least one other remaining value such that their sum equals a…

codeforcescompetitive-programmingbrute-forcegreedyimplementation
CF 1005B - Delete from the Left

We are given two strings, and we are allowed to repeatedly delete only the leftmost character from either string. Each deletion shortens one of the strings by exactly one character.

codeforcescompetitive-programmingbrute-forceimplementationstrings
CF 1006F - Xor-Paths

We are given a rectangular grid where each cell contains a non-negative integer. A path starts at the top-left cell and moves only right or down until it reaches the bottom-right cell.

codeforcescompetitive-programmingbitmasksbrute-forcedpmeet-in-the-middle
CF 1006E - Military Problem

We are given a rooted tree of officers where each officer has a unique direct superior except the root officer 1. This creates a hierarchy where every node represents an officer and edges point from superior to subordinate.

codeforcescompetitive-programmingdfs-and-similargraphstrees
CF 1006D - Two Strings Swaps

We are given two strings of equal length, and we are allowed to manipulate them using a small set of swap operations. Each position forms a vertical pair of characters, one from the first string and one from the second.

codeforcescompetitive-programmingimplementation
CF 1006B - Polycarp's Practice

We are given a sequence of problem difficulties in a fixed order, and we must split this sequence into exactly k consecutive segments. Each segment corresponds to one day of practice, and every problem must belong to exactly one segment.

codeforcescompetitive-programminggreedyimplementationsortings
CF 1006A - Adjacent Replacements

We are given a sequence of integers, each lying in a very large range up to $10^9$. Mishka repeatedly applies a global transformation rule that acts independently on each value: every pair of consecutive integers $(1,2)$, $(3,4)$, $(5,6)$, and so on, gets swapped in place, but…

codeforcescompetitive-programmingimplementation
CF 1006C - Three Parts of the Array

We are given a sequence of numbers arranged in a line, and we want to cut this line into three consecutive segments. The first segment starts at the beginning, the second sits in the middle, and the third ends at the last element.

codeforcescompetitive-programmingbinary-searchdata-structurestwo-pointers
CF 1007E - Mini Metro

We are dealing with a linear sequence of subway stations, where each station continuously accumulates passengers over time. Initially, each station already has some number of waiting people.

codeforcescompetitive-programmingdp
CF 1007D - Ants

We are given a tree and a collection of “ants”. Each ant comes with two alternative vertex pairs. For each ant, we must decide which of its two pairs it will use.

codeforcescompetitive-programming2-satdata-structurestrees
CF 1007A - Reorder the Array

We are given an array of numbers and allowed to freely reorder them. After rearranging, we compare the new array against the original array position by position.

codeforcescompetitive-programmingcombinatoricsdata-structuresmathsortingstwo-pointers
CF 1007C - Guess two numbers

We are dealing with a hidden pair of integers, both lying in a very large range up to $10^{18}$. The only way to learn about this pair is by repeatedly asking queries of the form $(x, y)$.

codeforcescompetitive-programmingbinary-searchinteractive
CF 1007B - Pave the Parallelepiped

We are given a fixed rectangular box with side lengths $A, B, C$. We want to count how many different triples $(a,b,c)$, ordered so that $a le b le c$, can serve as a building block such that copies of this smaller box can exactly tile the larger one, provided every copy is…

codeforcescompetitive-programmingbitmasksbrute-forcecombinatoricsmathnumber-theory
CF 1008A - Romaji

We are given a single lowercase word and asked to verify whether it follows a specific phonetic rule. The rule constrains how consonants and vowels can appear in sequence.

codeforcescompetitive-programmingimplementationstrings
CF 1008B - Turn the Rectangles

We are given a sequence of rectangular tiles placed in a fixed left-to-right order. Each tile has two possible orientations: we can either keep it as width-by-height or rotate it by 90 degrees, which swaps the two values.

codeforcescompetitive-programminggreedysortings