brain

tamnd's digital brain — notes, problems, research

43815 notes

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
CF 1009G - Allowed Letters

We are given a string made only from the first six lowercase letters. We are allowed to rearrange its characters arbitrarily by swapping any positions any number of times, so effectively we can treat it as a multiset of letters with full permutation freedom.

codeforcescompetitive-programmingbitmasksflowsgraph-matchingsgraphsgreedy
CF 1009E - Intercity Travelling

We are given a road split into $n$ unit segments, and each segment has a “base fatigue cost” $ai$ that applies when Leha starts a fresh driving session.

codeforcescompetitive-programmingcombinatoricsmathprobabilities
CF 1009F - Dominant Indices

We are working with a rooted tree where vertex 1 is considered the root. For every vertex $x$, we conceptually look at all nodes in its subtree and group them by their distance from $x$ in terms of edges downward in the tree.

codeforcescompetitive-programmingdata-structuresdsutrees
CF 1009C - Annoying Present

We start with an array of length $n$ that initially contains only zeros. Bob performs $m$ operations. Each operation is defined by a pair $(x, d)$, and Bob is allowed to pick a center position $i$ in the array.

codeforcescompetitive-programminggreedymath
CF 1009D - Relatively Prime Graph

We are asked to build a simple undirected graph on vertices numbered from 1 to n. The graph must have exactly m edges, must be connected, and must avoid both self-loops and repeated edges.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgraphsgreedymath
CF 1009B - Minimum Ternary String

We are given a string made only of digits 0, 1, and 2. We are allowed to repeatedly swap adjacent pairs if they are 0 and 1 in either direction, or 1 and 2 in either direction.

codeforcescompetitive-programminggreedyimplementation
CF 1009A - Game Shopping

The shop presents a line of games, each with a fixed price, and Maxim walks through them strictly from left to right.

codeforcescompetitive-programmingimplementation
CF 1010E - Store

We are given a 3D calendar system where every moment is uniquely identified by a triple consisting of a month, a day inside that month, and a second inside that day.

codeforcescompetitive-programmingdata-structures
CF 1010F - Tree

We are given a rooted tree where the root is fixed at vertex 1 and every vertex has at most two children. After a process of “pruning”, we keep a connected set of vertices that must still contain the root.

codeforcescompetitive-programmingfftgraphstrees
CF 1010C - Border

We are given a set of banknotes, each with a fixed positive value. Natasha can use any number of each type of banknote, including zero, so in effect she can form any total sum that is a non-negative integer linear combination of the given values.

codeforcescompetitive-programmingnumber-theory
CF 1010D - Mars rover

The structure we are given is a rooted tree where every node behaves like a logic component. Leaves are fixed boolean inputs, while internal nodes compute boolean values from their children using standard gates such as AND, OR, XOR, and NOT.

codeforcescompetitive-programmingdfs-and-similargraphsimplementationtrees
CF 1010B - Rocket

We are trying to determine an unknown integer $x$ in the range from 1 to $m$, but we are not allowed to see it directly. Instead, we can probe it by asking queries with a chosen number $y$.

codeforcescompetitive-programmingbinary-searchinteractive
CF 1010A - Fly

We are given a fixed route of space travel that starts at Earth, visits several intermediate planets in order, reaches Mars, and then returns back to Earth.

codeforcescompetitive-programmingbinary-searchmath
CF 1011A - Stages

We are given a multiset of characters, each character representing a rocket stage with an intrinsic cost equal to its position in the alphabet.

codeforcescompetitive-programminggreedyimplementationsortings
CF 1011B - Planning The Expedition

We are given a collection of food packages, each labeled by a type. There are also $n$ participants in an expedition, and time is measured in days. Each day, every participant consumes exactly one package.

codeforcescompetitive-programmingbinary-searchbrute-forceimplementation
CF 1012F - Passports

We are given a small collection of trips, each with a fixed start day and duration, and for each trip a visa process time that determines how long a passport is tied up after an application. Gleb has at most two passports, and each visa must be assigned to one of them.

codeforcescompetitive-programmingdpimplementation
CF 1012E - Cycle sort

We are given an array of integers and allowed to rearrange it using a very specific primitive: we can take any set of indices and rotate the values sitting at those positions cyclically.

codeforcescompetitive-programmingdsumath
CF 1012D - AB-Strings

We are given two binary strings, each consisting only of the characters a and b. The only allowed operation is to choose a prefix of the first string and a prefix of the second string, then swap those prefixes in a single move.

codeforcescompetitive-programmingconstructive-algorithmsstrings
CF 1012C - Hills

We are given a line of hills, each with a fixed initial height. We are allowed to repeatedly pick any single hill and decrease its height by one unit per operation.

codeforcescompetitive-programmingdp
CF 1012B - Chemical table

We are given an $n times m$ grid where each cell is a distinct chemical element. Some of these cells are already available in the laboratory. From any three elements forming three corners of an axis-aligned rectangle, the scientists can always synthesize the fourth corner.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similardsugraphsmatrices
CF 1012A - Photo of The Sky

We are given a multiset of numbers of size 2n, and we are told that these numbers originally came from n points in the plane, where each point contributes exactly two integers: its x-coordinate and its y-coordinate.

codeforcescompetitive-programmingbrute-forceimplementationmathsortings
CF 1013B - And

We are given a list of integers and a special integer x. The only allowed transformation is choosing an index and replacing that element with its bitwise AND with x. This operation can only decrease bits, since AND can only turn 1 bits into 0 depending on x.

codeforcescompetitive-programminggreedy
CF 1013A - Piles With Stones

We are given two snapshots of the same system of stone piles. In the first snapshot, each pile has some number of stones, and in the second snapshot the piles have different counts.

codeforcescompetitive-programmingmath
CF 1015E2 - Stars Drawing (Hard Edition)

The grid contains two kinds of cells, filled and empty. We are allowed to place geometric objects called stars, where each star consists of one central filled cell and four straight arms extending in the four cardinal directions.

codeforcescompetitive-programmingbinary-searchdpgreedy
CF 1015F - Bracket Substring

We are asked to build full valid bracket sequences of length 2n, and we want to count how many of those sequences contain a given string s as a contiguous block somewhere inside them. So conceptually, imagine all balanced parentheses strings of fixed size 2n.

codeforcescompetitive-programmingdpstrings
CF 1015D - Walking Between Houses

We are standing at the leftmost house in a long line of houses numbered from 1 to $n$. We must perform exactly $k$ moves, and each move consists of jumping from our current house to any different house.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1015E1 - Stars Drawing (Easy Edition)

We are given a rectangular grid filled with two types of cells, occupied cells marked as and empty cells marked as .. The task is to explain the grid as a superposition of geometric objects called stars.

codeforcescompetitive-programmingbrute-forcedpgreedy
CF 1015C - Songs Compression

We are given a collection of songs, each with an original size and a smaller size if we choose to compress it. All songs must be copied onto a flash drive whose total capacity is fixed. The only decision available is which songs to compress.

codeforcescompetitive-programmingsortings
CF 1015B - Obtaining the String

We are given two strings of equal length, where one string represents a starting arrangement of characters and the other represents a target arrangement. The only allowed operation is swapping two adjacent characters in the starting string.

codeforcescompetitive-programmingimplementation
CF 1015A - Points in Segments

We are given a one-dimensional number line from 1 to m, and several closed intervals placed on it. Each interval covers every integer point between its endpoints, including both ends.

codeforcescompetitive-programmingimplementation
CF 1016G - Appropriate Team

We are given a list of candidate values, and we want to count how many ordered pairs of candidates can simultaneously support a hidden integer value $v$ under two arithmetic constraints involving gcd and lcm with fixed constants $X$ and $Y$.

codeforcescompetitive-programmingbitmasksmathnumber-theory
CF 1016D - Vasya And The Matrix

We are asked to construct a grid of size n by m where each cell contains a non-negative integer. What we know in advance is not the grid itself, but two sets of constraints derived from it: the XOR of every row is fixed, and the XOR of every column is fixed.

codeforcescompetitive-programmingconstructive-algorithmsflowsmath
CF 1016F - Road Projects

We are given a weighted tree whose nodes are cities and whose edges are existing roads with travel times. The structure guarantees a unique simple path between any two cities, so distances are well-defined tree distances.

codeforcescompetitive-programmingdfs-and-similardptrees
CF 1016E - Rest In The Shades

The task revolves around a point light source moving horizontally at a fixed negative height, and a set of disjoint segments lying on the x-axis that act as obstacles.

codeforcescompetitive-programmingbinary-searchgeometry
CF 1016C - Vasya And The Mushrooms

We are given a grid with two rows and $n$ columns. Each cell contains a value that represents how many mushrooms grow per minute in that cell. Vasya starts at the top-left cell and must move every minute to a neighboring cell sharing an edge.

codeforcescompetitive-programmingdpimplementation