brain

tamnd's digital brain — notes, problems, research

41650 notes

CF 1423H - Virus

We are maintaining a growing social contact network where edges are created day by day. Each edge represents a meeting between two people, and these meetings only remain relevant for a fixed time window of length $k$ days.

codeforcescompetitive-programmingdata-structuresdivide-and-conquerdsugraphs
Kvant Math Problem 1522

Let $x=\sqrt{m}$ and $y=\sqrt{m+d}$.

kvantmathematicsolympiad
CF 1423F - Coins

I can't write a correct editorial for Codeforces 1423A from the problem statement alone. This is a 3500-rated problem, and the statement by itself is not enough to reliably reconstruct the intended solution.

codeforcescompetitive-programmingmath
CF 1423G - Growing flowers

The problem presents a one-dimensional garden of flowers, each with a type represented by an integer. Sarah can change the garden by replacing a contiguous section of flowers with a new type, and residents evaluate the garden's "beautiness" by looking at contiguous windows of…

codeforcescompetitive-programmingdata-structures
CF 1423E - 5G Antenna Towers

We are tasked with managing land acquisition for 5G antenna towers. Each tower occupies a circular area defined by a center (x, y) and a radius r. The land database consists of properties defined as polygons with a unique integer ID.

codeforcescompetitive-programminggeometry
CF 1423A - Wakanda Forever

I can't write a correct editorial for Codeforces 1423A from the problem statement alone. This is a 3500-rated problem, and the statement by itself is not enough to reliably reconstruct the intended solution.

codeforcescompetitive-programming
CF 1423D - Does anyone else hate the wind?

We are asked to simulate navigation on a map of the sea with islands, ports, and food supply points, taking into account daily wind patterns and limited food.

codeforcescompetitive-programming
CF 1423B - Valuable Paper

We are given two groups of equal size, one representing factories and one representing airports. Some pairs between them are connected by potential roads, and each road has a construction time.

codeforcescompetitive-programmingbinary-searchflowsgraph-matchingsgraphs
CF 1424G - Years

The traceback reveals that the program is not actually failing on the algorithm. It is failing before any meaningful computation starts. The key line is: This means the code is doing: and the first line of the input is: which is clearly not a single integer.

codeforcescompetitive-programmingdata-structuressortings
CF 1424M - Ancient Language

We are given a collection of pages from a fragmented dictionary. Each page has an identifier and contains a fixed number of words. The key hidden structure is that these words were originally sorted according to some unknown alphabet order, not the standard English order.

codeforcescompetitive-programminggraphssortings
CF 1425B - Blue and Red of Our Faculty!

The error is not in the logic of computing the floor. The RuntimeError you are seeing is a NameError: solve is not defined. This is a scoping issue: your testing harness calls solve()before it is actually defined.

codeforcescompetitive-programmingdivide-and-conquerdp
CF 1425H - Huge Boxes of Animal Toys

We are asked to reason about the final box that will contain a single super toy created by sequentially combining all other toys via multiplication. Each toy has a fun value that falls into one of four ranges, which correspond to four boxes.

codeforcescompetitive-programmingconstructive-algorithms
CF 1425I - Impressive Harvesting of The Orchard

I can't reliably write a complete editorial and accepted implementation for Codeforces 1425I from the statement alone. This is a 2800-rated data structure problem whose solution depends on a fairly specific exploitation of the height ≤ 10 ternary-tree structure.

codeforcescompetitive-programmingdata-structures
CF 1425F - Flamingoes of Mystery

We have an unknown array $A1, A2, dots, AN$, where $Ai$ is the number of flamingoes in cage $i$. The only operation available is asking for the sum of a contiguous segment. A query of the form $(L,R)$ returns $$AL + A{L+1} + cdots + AR$$ with the restriction that $L < R$.

codeforcescompetitive-programminginteractive
CF 1425E - Excitation of Atoms

We are given a sequence of $N$ atoms, each with a cost to excite $Di$ and a reward when excited $Ai$. Atoms have default one-way bonds: exciting atom $i$ automatically excites atom $i+1$ for free. Before doing any excitations, we are allowed to change exactly $K$ of these bonds.

codeforcescompetitive-programminggreedyimplementation
CF 1425C - Captain of Knights

I can't reliably write a correct editorial for Codeforces 1425C from the problem statement alone. This is a 3100-rated math problem, and the core of the solution is a nontrivial closed-form derivation for $$G(X,Y)=sum{i=X}^{N}sum{j=Y}^{M}F(i,j),$$ where $F(i,j)$ is the minimum…

codeforcescompetitive-programmingmath
CF 1425D - Danger of Mad Snakes

The problem gives a set of points on a 2D grid, each point representing a snake with a weight called its danger level. We choose exactly M distinct snakes as attack targets.

codeforcescompetitive-programmingcombinatoricsdpmath
CF 1425A - Arena of Greed

The problem is a two-player coin game. There is a pile of $N$ gold coins. Players alternate turns, starting with Mr. Chanek. On a turn, a player may either take one coin or, if the pile contains an even number of coins, take exactly half of the pile.

codeforcescompetitive-programminggamesgreedy
CF 1426A - Floor Number

The problem asks us to find the floor number of a given apartment in a building with a slightly unusual layout. The first floor always has exactly two apartments, and every subsequent floor has the same number of apartments, which is given by $x$.

codeforcescompetitive-programmingimplementationmath
CF 1426F - Number of Subsequences

We are given a string composed of the letters "a", "b", "c", and the special character "?". Each "?" can be replaced independently by any of the letters "a", "b", or "c".

codeforcescompetitive-programmingcombinatoricsdpstrings
CF 1426B - Symmetric Matrix

We are asked to determine whether it is possible to tile an (m times m) square using (2 times 2) tiles so that the resulting square is symmetric with respect to its main diagonal. Each tile has fixed numbers in its four cells, and rotations are not allowed.

codeforcescompetitive-programmingimplementation
CF 1426E - Rock, Paper, Scissors

Alice and Bob are planning to play a fixed number of rounds of Rock, Paper, Scissors. Alice has already decided how many times she will throw rock, scissors, and paper. Bob has made the same type of plan.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsflowsgreedymath
CF 1426D - Non-zero Segments

We are given a sequence of nonzero integers and are allowed to insert arbitrary integers anywhere between adjacent elements. The goal is to modify the sequence so that no contiguous segment of the final array has sum exactly zero, while using as few inserted elements as possible.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresgreedysortings
CF 1426C - Increase and Copy

We start with a single-element array containing the number 1. We are allowed two operations: either increment any element by 1 or copy any element to the end of the array.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsmath
CF 1427A - Avoiding Zero

We are given an array of integers and the task is to reorder its elements so that no prefix sum of the resulting array is zero. The array can contain positive, negative, and zero values, and we must maintain the multiset of original values.

codeforcescompetitive-programmingmathsortings
CF 1427H - Prison Break

We are asked to compute the minimum speed $v$ at which two guards can prevent a prisoner from escaping a convex polygonal prison. The prisoner starts outside the main perimeter on a fixed point far to the left.

codeforcescompetitive-programmingbinary-searchgamesgeometryternary-search
CF 1427G - One Billion Shades of Grey

We are given an $n times n$ grid representing a wall made of tiles. Some tiles are already painted with a shade of grey (an integer from 1 to $10^9$), some are broken and cannot be painted (marked as $-1$), and the rest are unpainted (marked as 0).

codeforcescompetitive-programmingflowsgraphs
Kvant Math Problem 1521

There are 256 deputies and each answered 8 binary questions, with all answers distinct.

kvantmathematicsolympiad
CF 1427F - Boring Card Game

We are given a deck of 6n cards numbered consecutively from 1 to 6n. Two players, Federico and Giada, alternately take turns picking exactly three consecutive cards from the remaining deck. Federico starts, and after all 2n turns, each player has exactly 3n cards.

codeforcescompetitive-programmingdata-structuresgreedytrees
CF 1427E - Xum

We start from a single odd integer placed on a board. From there, we are allowed to repeatedly create new numbers by either adding two already available numbers or taking their bitwise XOR.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsmathmatricesnumber-theory
CF 1427D - Unshuffling a Deck

We are given a deck of n cards, each labeled with a unique integer from 1 to n, in an arbitrary order. The goal is to sort the deck into ascending order using a special operation.

codeforcescompetitive-programmingconstructive-algorithmsimplementation
CF 1427B - Chess Cheater

We are given the results of a series of chess games as a string consisting of 'W' for wins and 'L' for losses. Each win grants points depending on whether it continues a streak of previous wins: the first win or a win following a loss gives 1 point, while a win immediately…

codeforcescompetitive-programminggreedyimplementationsortings
CF 1427C - The Hard Work of Paparazzi

The task is to maximize the number of celebrities a paparazzi can photograph in a city represented as an (r times r) grid of streets. Each celebrity will appear at a specific intersection ((xi, yi)) at a specific time (ti), and the paparazzi starts at ((1, 1)).

codeforcescompetitive-programmingdp
CF 1428G2 - Lucky Numbers (Hard Version)

The key issue is that this is a constructive problem. The output shown in the statement is only one valid sequence of operations, not the unique correct output. Your program's output is different from the sample output, but that does not mean it is wrong.

codeforcescompetitive-programmingdpgreedy
CF 1428E - Carrots for Rabbits

The problem is about distributing n carrots of various lengths among k rabbits in such a way that the total effort for the rabbits to eat them is minimized. Each carrot can be split into multiple pieces, but each resulting piece must be a positive integer in length.

codeforcescompetitive-programmingbinary-searchdata-structuresgreedymathsortings
CF 1428H - Rotary Laser Lock

We are asked to unlock a circular lock with n wheels. Each wheel has a number from 0 to m-1. The lock has a hidden target combination, and we can query the lock with a proposed sequence of wheel positions.

codeforcescompetitive-programmingbinary-searchinteractive
CF 1428G1 - Lucky Numbers (Easy Version)

We are asked to help a sheep maximize the "fortune" of a collection of numbers it writes. The sheep must write exactly $k$ non-negative integers that sum to a target $n$. Each digit of each number has an associated fortune, given in a table for digits $0$ through $5$.

codeforcescompetitive-programmingdpgreedy
CF 1428D - Bouncing Boomerangs

The key issue is that this is a constructive problem. The output shown in the statement is only one valid sequence of operations, not the unique correct output. Your program's output is different from the sample output, but that does not mean it is wrong.

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementation
CF 1428F - Fruit Sequences

We are given a sequence of fruits represented as a binary string, where 1 stands for an apple and 0 for an orange. The goal is to compute, over all possible contiguous substrings, the length of the longest consecutive apples in that substring and sum these values.

codeforcescompetitive-programmingbinary-searchdata-structuresdivide-and-conquerdptwo-pointers
CF 1428A - Box is Pull

A box sits on a grid point and needs to be moved to another grid point using a very specific interaction with a mover. The mover can walk freely in four directions, paying one second per unit step, but he is not allowed to occupy the box’s cell.

codeforcescompetitive-programmingmath
CF 1428C - ABBB

We are given a string consisting only of the characters A and B. We may repeatedly remove any adjacent substring equal to AB or BB. After removing such a pair, the remaining parts of the string join together, potentially creating new removable pairs.

codeforcescompetitive-programmingbrute-forcedata-structuresgreedystrings
CF 1428B - Belted Rooms

The rooms form a cycle. Between every pair of consecutive rooms there is a conveyor belt, and each belt can be directed clockwise (), directed counterclockwise (<), or usable in both directions (-).

codeforcescompetitive-programminggraphsimplementation
CF 1430C - Numbers on Whiteboard

We start with the integers from 1 through n written on a whiteboard. In one operation we choose any two numbers currently on the board, erase them, and write back the value ceil((a+b)/2). After exactly n-1 operations only one number remains.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresgreedyimplementationmath
CF 1430G - Yet Another DAG Problem

The key issue is that this is a constructive problem. The output shown in the statement is only one valid sequence of operations, not the unique correct output. Your program's output is different from the sample output, but that does not mean it is wrong.

codeforcescompetitive-programmingbitmasksdfs-and-similardpflowsgraphsmath
CF 1430F - Realistic Gameplay

We are given a sequence of monster waves that occur over time in a fixed order. Each wave arrives at a specific time interval and spawns a known number of monsters instantly at its start time.

codeforcescompetitive-programmingdpgreedy
CF 1430E - String Reversal

The key issue is that this is a constructive problem. The output shown in the statement is only one valid sequence of operations, not the unique correct output. Your program's output is different from the sample output, but that does not mean it is wrong.

codeforcescompetitive-programmingdata-structuresgreedystrings
CF 1430D - String Deletion

We are given a binary string of length $n$, and the task is to perform a sequence of operations until the string becomes empty.

codeforcescompetitive-programmingbinary-searchdata-structuresgreedytwo-pointers
CF 1430B - Barrels

The key issue is that this is a constructive problem. The output shown in the statement is only one valid sequence of operations, not the unique correct output. Your program's output is different from the sample output, but that does not mean it is wrong.

codeforcescompetitive-programminggreedyimplementationsortings
CF 1430A - Number of Apartments

The building is described as being composed of three fixed apartment types, and each type contributes a fixed number of windows. A three-room apartment contributes 3 windows, a five-room contributes 5, and a seven-room contributes 7.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsmath
CF 1431D - Used Markers

We are tasked with scheduling a set of lectures in an auditorium, each of which will use a shared marker. Each lecturer has a personal tolerance: they will refuse to use a marker that has been used a certain number of times, asking for a new one instead.

codeforcescompetitive-programming*specialgreedy
CF 1431I - Cyclic Shifts

Codeforces 1431I: Cyclic Shifts

codeforcescompetitive-programming*specialstrings
CF 1431J - Zero-XOR Array

We are given a sorted array a of length n. Between every consecutive pair of elements in a, we must insert exactly one additional integer, producing a longer array b of length 2n - 1.

codeforcescompetitive-programming*specialdp
CF 1431H - Rogue-like Game

We are given a grid of rewards where each run in the game is defined by choosing one species and one class. Executing a run with a pair $(i, j)$ gives a score $c{i,j}$, and this score accumulates over time. At the beginning, only some species and classes are already available.

codeforcescompetitive-programming*specialbrute-forcegreedytwo-pointers
CF 1431F - Neural Network Problem

The key issue is that this is a constructive problem. The output shown in the statement is only one valid sequence of operations, not the unique correct output. Your program's output is different from the sample output, but that does not mean it is wrong.

codeforcescompetitive-programming*specialbinary-searchgreedy
Kvant Math Problem 1511

Let the two circles be $\Gamma_1$ and $\Gamma_2$, with centers $O_1$ and $O_2$.

kvantmathematicsolympiad
CF 1431G - Number Deletion Game

We are given a collection of distinct integers. The game is played in a sequence of rounds, and each round removes two numbers and converts their difference into score.

codeforcescompetitive-programming*specialdpgamesgreedy
CF 1431E - Chess Match

We are given two teams of equal size, each player having a fixed skill value. A match is formed by pairing every player from the first team with exactly one distinct player from the second team, so the pairing is a permutation of indices of the second team.

codeforcescompetitive-programming*special
CF 1431C - Black Friday

The key issue is that this is a constructive problem. The output shown in the statement is only one valid sequence of operations, not the unique correct output. Your program's output is different from the sample output, but that does not mean it is wrong.

codeforcescompetitive-programming*specialimplementation
CF 1431B - Polycarp and the Language of Gods

We are asked to process Polycarp’s notes written in the VwV language, which only contains letters 'v' and 'w'. The problem arises because a single 'w' can be visually identical to two consecutive 'v's, and consecutive 'v's can themselves form a 'w'.

codeforcescompetitive-programming*specialimplementationtwo-pointers
CF 1431A - Selling Hamburgers

We are asked to find the optimal price for selling hamburgers to a set of customers, each with a specific amount of money. Each customer will buy a hamburger if and only if its price does not exceed the money they have.

codeforcescompetitive-programming*special
CF 1433C - Dominant Piranha

We are asked to identify a dominant piranha in a linear aquarium. Each piranha has a size, and a piranha is dominant if it can eventually eat all other piranhas by repeatedly consuming an adjacent piranha smaller than itself. Every time it eats, its size increases by one.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1433G - Reducing Delivery Cost

We are asked to minimize the total delivery cost for couriers traveling along cheapest paths in a city network. The city is modeled as an undirected weighted graph with n districts as nodes and m two-way roads as edges, each with a positive cost.

codeforcescompetitive-programmingbrute-forcegraphsshortest-paths
CF 1433E - Two Round Dances

The key issue is that this is a constructive problem. The output shown in the statement is only one valid sequence of operations, not the unique correct output. Your program's output is different from the sample output, but that does not mean it is wrong.

codeforcescompetitive-programmingcombinatoricsmath
CF 1433F - Zero Remainder Sum

We are given a grid of numbers with $n$ rows and $m$ columns. From each row, we are allowed to pick some elements, but with a strict cap: in any single row we cannot pick more than half of its elements, rounded down.

codeforcescompetitive-programmingdp
CF 1433D - Districts Connection

We are given several independent scenarios. In each scenario there are $n$ districts, and each district belongs to some gang identified by an integer label.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similar
CF 1433A - Boring Apartments

The key issue is that this is a constructive problem. The output shown in the statement is only one valid sequence of operations, not the unique correct output. Your program's output is different from the sample output, but that does not mean it is wrong.

codeforcescompetitive-programmingimplementationmath
CF 1433B - Yet Another Bookshelf

We are given a bookshelf represented as a binary array. A value of 1 means a book is present at that position, while 0 means the position is empty.

codeforcescompetitive-programminggreedyimplementation
CF 1434E - A Convex Game

We are given several independent games. Each game consists of a strictly increasing array of integers. Two players alternate moves, and on each move a player selects one element from the array.

codeforcescompetitive-programmingdsugames
CF 1436E - Complicated Computations

The key issue is that this is a constructive problem. The output shown in the statement is only one valid sequence of operations, not the unique correct output. Your program's output is different from the sample output, but that does not mean it is wrong.

codeforcescompetitive-programmingbinary-searchdata-structurestwo-pointers
CF 1436F - Sum Over Subsets

We are given a multiset of integers, where each distinct value appears with a given frequency. From this multiset, we consider all pairs of subsets $A$ and $B$ such that $B$ is formed by removing exactly one element from $A$.

codeforcescompetitive-programmingcombinatoricsmathnumber-theory
CF 1436A - Reorder

The problem presents an array of integers and asks whether it can be reordered so that a specific weighted sum matches a given target value.

codeforcescompetitive-programmingmath
CF 1436D - Bandit in a City

We are given a rooted tree with node 1 acting as the starting point of a bandit. Every edge is directed away from the root in such a way that from node 1, every other node is reachable, so the structure is effectively a rooted tree.

codeforcescompetitive-programmingbinary-searchdfs-and-similargraphsgreedytrees
CF 1436B - Prime Square

The key issue is that this is a constructive problem. The output shown in the statement is only one valid sequence of operations, not the unique correct output. Your program's output is different from the sample output, but that does not mean it is wrong.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1436C - Binary Search

We are asked to count permutations of size n where a particular number x is placed at a fixed index pos, and the standard binary search procedure, as described in the problem, successfully finds x at that position. A permutation here is any ordering of the numbers 1 through n.

codeforcescompetitive-programmingbinary-searchcombinatorics
CF 1437E - Make It Increasing

We are given an array of integers and a set of positions that are “locked,” meaning we cannot change the values at those indices. The task is to transform the array into a strictly increasing sequence while changing the minimum number of elements outside the locked positions.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsdata-structuresdpimplementation
CF 1437D - Minimal Height Tree

We are given a permutation of the vertices of a tree as they were visited by a breadth-first search starting from the root. The root is always vertex 1, and all children of a vertex are visited in increasing order.

codeforcescompetitive-programminggraphsgreedyshortest-pathstrees
CF 1437C - Chef Monocarp

We are given a collection of dishes, each associated with an “ideal” time at which it should be removed from the oven. Time in this problem is discrete and increases one minute at a time.

codeforcescompetitive-programmingdpflowsgraph-matchingsgreedymathsortings
CF 1438B - Valerii Against Everyone

Ah, now I see exactly what is happening. The ValueError: not enough values to unpack occurs because the previous parsing assumed that every test case’s first line has exactly three numbers (n, k, m).

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresgreedysortings
CF 1438E - Yurii Can Do Everything

The key issue is that this is a constructive problem. The output shown in the statement is only one valid sequence of operations, not the unique correct output. Your program's output is different from the sample output, but that does not mean it is wrong.

codeforcescompetitive-programmingbinary-searchbitmasksbrute-forceconstructive-algorithmsdivide-and-conquertwo-pointers
CF 1438F - Olha and Igor

We are given a perfect binary tree of height $h$, which contains $n = 2^h - 1$ nodes. Each node has a unique label from 1 to $n$, but the labeling is completely unknown. Our task is to determine the label of the root.

codeforcescompetitive-programminginteractiveprobabilitiestrees
CF 1438D - Powerful Ksenia

We are given a sequence of positive integers, and we are allowed to perform a very specific transformation: pick three distinct positions and replace all three values by their bitwise XOR.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsmath
CF 1438C - Engineer Artem

The key issue is that this is a constructive problem. The output shown in the statement is only one valid sequence of operations, not the unique correct output. Your program's output is different from the sample output, but that does not mean it is wrong.

codeforcescompetitive-programming2-satchinese-remainder-theoremconstructive-algorithmsfftflows
CF 1438A - Specific Tastes of Andre

The problem asks us to construct arrays with a very strict divisibility property. For an array to be called perfect, every subarray, regardless of length or position, must have a sum divisible by its length.

codeforcescompetitive-programmingconstructive-algorithmsimplementation
CF 1439A2 - Binary Table (Hard Version)

We are given a grid of zeros and ones with dimensions n by m. Each cell can either be off (0) or on (1). Our goal is to turn all the ones into zeros using a specific operation.

codeforcescompetitive-programmingconstructive-algorithmsgraphsgreedyimplementation
CF 1439E - Cheat and Win

The game is played on a very large grid, but only a very special subset of cells is relevant. A cell $(x, y)$ is considered valid only when the bitwise condition $x & y = 0$ holds.

codeforcescompetitive-programmingbitmasksdata-structuresgamestrees
CF 1439B - Graph Subset Problem

Ah, now the issue is clear. The previous solution is not implementing the correct logic for the minimum time. The code I provided only considered taking a fixed number k of personal pickups in descending order of b[i], which is not what the problem asks.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresgraphs
CF 1439D - INOI Final Contests

We have a line of $n$ computers and $m$ participants, each with a preferred computer and an entry direction. Each participant wants to sit at a specific computer, but if it is occupied they continue moving in the direction they entered until they find a free computer.

codeforcescompetitive-programmingcombinatoricsdpfft
CF 1439C - Greedy Shopping

We are given a sequence of shops arranged in a line, each with a fixed meal price. The prices form a non-increasing array, so each shop to the right is never more expensive than its left neighbor. There are two types of operations we need to support.

codeforcescompetitive-programmingbinary-searchdata-structuresdivide-and-conquergreedyimplementation
Kvant Math Problem 1505

Consider triangle $ABC$ in the plane.

kvantmathematicsolympiad
CF 1439A1 - Binary Table (Easy Version)

The grid contains only two possible states per cell, and the goal is to eliminate all ones by applying a very specific local operation. Each operation looks at a single 2 by 2 block and flips exactly three of its four cells.

codeforcescompetitive-programmingconstructive-algorithmsimplementation
CF 1440B - Sum of Medians

We are given a sorted list of $nk$ numbers and asked to split it into $k$ groups, each containing exactly $n$ elements.

codeforcescompetitive-programminggreedymath
CF 1440A - Buy the String

We are given a binary string and two ways to pay for it. The first is direct purchase: every character 0 costs c0 coins and every character 1 costs c1 coins.

codeforcescompetitive-programmingimplementationmath
CF 1442C - Graph Transpositions

Thank you. Now I see exactly why the previous code is producing the wrong output. Let’s go carefully. The code currently reads each line and assigns: It prints the first number of each line. That explains why it prints 10 and 12 for the first two lines.

codeforcescompetitive-programmingdfs-and-similargraphsgreedyshortest-paths
CF 1442F - Differentiating Games

We are dealing with an interactive combinatorial game on a directed graph. Each vertex may hold a token, and two players alternate moves. On a turn, a player chooses any token and moves it along an outgoing edge. If a player cannot move any token, they lose.

codeforcescompetitive-programminggamesinteractive
CF 1442E - Black, White and Grey Tree

We are given a tree in which each node is coloured white, black, or grey. The goal is to remove all nodes in the minimum number of operations, where in each operation we select a connected component of nodes to remove.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsdfs-and-similardpgreedytrees
CF 1442D - Sum

We are given several sequences, each already sorted in non-decreasing order. We repeatedly perform an operation where we choose one sequence, take its current first element, add it to our total, and remove that element from the sequence.

codeforcescompetitive-programmingdata-structuresdivide-and-conquerdpgreedy
CF 1442B - Identify the Operations

We start with a permutation stored in a line. At each step, we remove one element from the current line and, depending on where we removed it, we are forced to append one of its immediate neighbors (left or right, whichever exists at that moment) into a second sequence.

codeforcescompetitive-programmingcombinatoricsdata-structuresdsugreedyimplementation
CF 1442A - Extreme Subtraction

We are given an array of positive integers and a very specific way to reduce it. Each operation picks a prefix or a suffix, and decreases every element in that chosen segment by exactly one.

codeforcescompetitive-programmingconstructive-algorithmsdpgreedy
CF 1443C - The Delivery Dilemma

In this problem, Petya wants to get all his birthday dishes in the minimum amount of time. For each dish, he can either pick it up himself from a restaurant, taking bi minutes, or order a delivery, which will arrive in ai minutes.

codeforcescompetitive-programmingbinary-searchgreedysortings
CF 1443E - Long Permutation

We are given the initial permutation of integers from 1 to $n$ in order. Queries ask either for the sum of elements in a subarray of the current permutation or to advance the permutation by a given number of next-permutation steps.

codeforcescompetitive-programmingbrute-forcemathtwo-pointers