brain

tamnd's digital brain — notes, problems, research

43815 notes

CF 935A - Fafa and his Company

Fafa needs to divide his company’s employees into groups for project management. He wants to pick a number of team leaders, denoted by l, and assign the remaining employees evenly among them.

codeforcescompetitive-programmingbrute-forceimplementation
CF 935E - Fafa and Ancient Mathematics

We are given a fully parenthesized arithmetic expression shaped like a binary tree. Every internal node is an operator, and every leaf is a single digit. However, all operators have been erased and replaced by placeholders.

codeforcescompetitive-programmingdfs-and-similardptrees
CF 935D - Fafa and Ancient Alphabet

We are given two words of equal length over an alphabet consisting of symbols 1...m. Some positions are known, while others were erased and are represented by 0. Every erased position is filled independently and uniformly with one of the m alphabet symbols.

codeforcescompetitive-programmingmathprobabilities
CF 935C - Fifa and Fafa

Sure - I can do that, but I’ll need the problem first. Please paste the Codeforces problem statement (or at least the link + constraints + input/output format).

codeforcescompetitive-programminggeometry
CF 935B - Fafa and the Gates

The problem is about counting the number of times Fafa crosses the wall between two kingdoms when walking along a grid according to a sequence of moves. The wall is along the line x = y, with a gate at every integer coordinate along that line.

codeforcescompetitive-programmingimplementation
CF 92113 - Labyrinth-13

We are given a maze-like structure that can be interpreted as a graph where each cell or node represents a position in the labyrinth and some connections between them define possible moves.

codeforcescompetitive-programming
CF 92111 - Labyrinth-11

We are given a two-dimensional labyrinth represented as an n × m grid, where each cell is either empty or contains a wall. We start at the top-left corner and want to reach the bottom-right corner. The allowed moves are one step up, down, left, or right into empty cells.

codeforcescompetitive-programming
CF 92109 - Labyrinth-9

The robot is placed in a grid-like maze where each cell is connected to its four neighbors, but movement between adjacent cells can be blocked either by an impassable wall or by a locked door. Some cells contain keys, and some cells are exits.

codeforcescompetitive-programming
CF 92104 - Labyrinth-4

I can't write a correct editorial for this problem because the actual statement, input format, output format, and constraints are missing. For this specific task, Codeforces problem 92104 ("Labyrinth-4") does not contain its statement on the problem page.

codeforcescompetitive-programming
CF 920D - Tanks

We have several tanks containing water. A single operation is unusual: when we choose a source tank, we do not decide how much water to take. The scoop automatically takes min(currentamount, K) milliliters from that tank and immediately pours all of it into another tank.

codeforcescompetitive-programmingdpgreedyimplementation
CF 920G - List Of Integers

The problem asks us to generate a special list of integers for multiple queries. For a given query with integers x, p, and k, we need to find the k-th integer greater than x that is coprime with p. Coprime means that the greatest common divisor (gcd) of the number and p is 1.

codeforcescompetitive-programmingbinary-searchbitmasksbrute-forcecombinatoricsmathnumber-theory
CF 920E - Connected Components?

The graph in this problem is not given in the usual way. Instead of listing edges that exist, the input lists pairs of vertices that are explicitly disconnected. Every pair of vertices that does not appear in this list should be treated as having an edge between them.

codeforcescompetitive-programmingdata-structuresdfs-and-similardsugraphs
CF 920C - Swap Adjacent Elements

We are given a permutation of size n, meaning every integer from 1 to n appears exactly once. Alongside this array is a string that describes which adjacent positions are “connected” by an allowed swap.

codeforcescompetitive-programmingdfs-and-similargreedymathsortingstwo-pointers
CF 919F - A Game With Numbers

We are given a two-player game where Alice and Bob each hold 8 cards with numbers from 0 to 4. On a player’s turn, they select one of their cards with a non-zero number and one of the opponent’s cards with a non-zero number, add them modulo 5, and replace their own card with…

codeforcescompetitive-programminggamesgraphsshortest-paths
CF 919C - Seat Arrangements

We are given a classroom represented as a grid. Each cell is either empty (.) or occupied (). We want to seat exactly k students in a straight line. The seats must be consecutive and must lie entirely within a single row or entirely within a single column.

codeforcescompetitive-programmingbrute-forceimplementation
CF 919D - Substring

We are given a directed graph where each vertex carries a lowercase letter. A valid walk follows directed edges from node to node, and we are allowed to revisit nodes and edges as long as we respect direction.

codeforcescompetitive-programmingdfs-and-similardpgraphs
CF 918B - Radio Station

We are given a small registry of servers, where each server is identified by a unique IP address and also has a human-readable name. After that, we are given a list of configuration commands, and each command references a server only through its IP.

codeforcescompetitive-programmingimplementationstrings
CF 917D - Stranger Trees

We are asked to examine variations of a given labeled tree with $n$ vertices, counting how many labeled trees share exactly $k$ edges with the given one for each $k$ from 0 to $n-1$. The input is the number of vertices followed by $n-1$ edges that define Will's tree.

codeforcescompetitive-programmingdpmathmatricestrees
CF 917E - Upside Down

The tree describes a network of junctions connected by directed tunnels, where each tunnel carries a lowercase letter. Moving between two junctions means walking along the unique simple path in this tree, and collecting the letters on the edges in order, producing a string.

codeforcescompetitive-programmingdata-structuresstring-suffix-structuresstringstrees
CF 917C - Pollywog

We are asked to move a group of x pollywogs from the first x stones in a line to the last x stones. The stones are numbered 1 through n, and each pollywog occupies exactly one stone.

codeforcescompetitive-programmingcombinatoricsdpmatrices
CF 917B - MADMAX

We are given a directed acyclic graph where each edge carries a lowercase letter. Two tokens start on possibly different vertices: one belongs to Max and one to Lucas.

codeforcescompetitive-programmingdfs-and-similardpgamesgraphs
CF 916E - Jamie and Tree

We are given a tree with values on its vertices, and we need to support three kinds of operations under a changing notion of what “subtree” means. The tree is rooted, but the root is not fixed. Whenever the root changes, the definition of subtree changes accordingly.

codeforcescompetitive-programmingdata-structurestrees
CF 916C - Jamie and Interesting Graph

We are asked to construct an undirected weighted graph with exactly n vertices and m edges that satisfies two prime-related constraints. First, the length of the shortest path from vertex 1 to vertex n must be prime.

codeforcescompetitive-programmingconstructive-algorithmsgraphsshortest-paths
CF 916D - Jamie and To-do List

The system maintains a dynamic collection of named tasks. Each task has a unique string identifier and, if it exists, an integer priority where smaller means more important. Over time, tasks are added, removed, or have their priorities changed.

codeforcescompetitive-programmingdata-structuresinteractivetrees
CF 916A - Jamie and Alarm Snooze

We are given a wake-up time on a 24-hour clock and a fixed interval x in minutes. Jamie sets an alarm some unknown amount of time before the wake-up moment. After the alarm rings, he repeatedly snoozes it every x minutes until the wake-up time is reached exactly.

codeforcescompetitive-programmingbrute-forceimplementationmath
CF 915G - Coprime Arrays

We are asked to study arrays of fixed length where each element is chosen from a bounded range, and classify them by a global property: whether the entire array has greatest common divisor equal to one.

codeforcescompetitive-programmingmathnumber-theory
CF 915F - Imbalance Value of a Tree

We are given a tree with n vertices, where each vertex carries an integer label. For any pair of vertices x and y, we define the imbalance of the path connecting them as the difference between the maximum and minimum labels along that path.

codeforcescompetitive-programmingdata-structuresdsugraphstrees
CF 915E - Physical Education Lessons

We are managing a line of days from 1 to n, where each day can be either working or non-working. Initially every day is working. Then a sequence of updates arrives, and after each update we must report how many working days currently exist.

codeforcescompetitive-programmingdata-structuresimplementationsortings
CF 915A - Garden

We are asked to water a linear garden of length k using one of n buckets. Each bucket waters a fixed segment of the garden every hour, specifically a continuous stretch of length ai. Luba must water the entire garden without leaving gaps and cannot water any part twice.

codeforcescompetitive-programmingimplementation
CF 915D - Almost Acyclic Graph

We are given a directed graph with n vertices and m edges. Each edge has a direction from some vertex u to another vertex v. The task is to determine whether we can remove at most one edge to make the graph acyclic.

codeforcescompetitive-programmingdfs-and-similargraphs
CF 915B - Browser

We have a browser with n tabs numbered 1 through n. The mouse is currently at tab pos. Luba wants to end up with only the tabs in the segment [l, r] open. Every other tab needs to be closed, and the goal is to do it in the minimum number of seconds.

codeforcescompetitive-programmingimplementation
CF 914H - Ember and Storm's Tree Game

The game begins with Ember choosing a tree on $n$ labeled vertices, with the restriction that no vertex has degree exceeding $d$. After that, Storm selects an ordered pair of vertices $(u, v)$, which determines a simple path in the tree.

codeforcescompetitive-programmingcombinatoricsdpgamestrees
CF 914A - Perfect Squares

We are given an array of integers and need to find the largest element that is not a perfect square. A perfect square is a number that can be expressed as the square of an integer. The input consists of a number n, the size of the array, followed by the array elements.

codeforcescompetitive-programmingbrute-forceimplementationmath
CF 914C - Travelling Salesman and Special Numbers

We are given an upper bound n, but n is not provided as a decimal integer. Instead, it is given directly as a binary string whose length can be as large as 1000 bits.

codeforcescompetitive-programmingbrute-forcecombinatoricsdp
CF 914D - Bash and a Tough Math Puzzle

We maintain an array that supports two kinds of operations. The first operation asks about a segment [l, r] and a value x. We want to know whether it is possible to modify at most one element inside that segment so that the gcd of the entire segment becomes exactly x.

codeforcescompetitive-programmingdata-structuresnumber-theory
CF 913F - Strongly Connected Tournament

We are asked to compute the expected total number of games in a recursively defined chess tournament. There are n players, each with a known probability of beating any lower-numbered player.

codeforcescompetitive-programmingdpgraphsmathprobabilities
CF 913G - Power Substring

Each query gives a positive integer $a$, and we need to construct another integer $k$. The constraint is not about optimizing $k$, but about shaping the number $2k$.

codeforcescompetitive-programmingmathnumber-theory
CF 913E - Logical Expression

We are working with Boolean functions of exactly three variables, x, y, and z. A Boolean function on three variables has only eight possible input assignments. The input gives the value of the function on each of those eight assignments as a binary string of length eight.

codeforcescompetitive-programmingbitmasksdpshortest-paths
CF 913D - Too Easy Problems

We are given a set of exam problems, each with a solving time and a “strictness limit” that controls whether it contributes to our score. We can pick any subset of problems to solve as long as the total time does not exceed the exam duration.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresgreedysortings
CF 913C - Party Lemonade

We are asked to buy at least L liters of lemonade at minimum cost. The store offers n types of bottles, where the i-th type has a volume of 2^(i-1) liters and a cost of c[i] roubles, and we can buy an unlimited number of each type.

codeforcescompetitive-programmingbitmasksdpgreedy
CF 913A - Modular Exponentiation

The problem asks us to compute the remainder when an integer m is divided by $2^n$, where n and m are positive integers. In other words, we are given the size of a power-of-two modulus and a dividend, and we must find what is left after dividing the dividend by that modulus.

codeforcescompetitive-programmingimplementationmath
CF 912B - New Year's Eve

We are asked to help Grisha maximize his happiness by choosing up to k candies from a bag of n candies, each with a unique tastiness from 1 to n.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsnumber-theory
CF 912D - Fishes

We have a rectangular pond of size n by m where each cell can hold at most one fish. Sasha has a square scoop of size r by r that can catch all fishes inside the square if its bottom-left corner is placed within the pond.

codeforcescompetitive-programmingdata-structuresgraphsgreedyprobabilitiesshortest-paths
CF 912C - Perun, Ult!

We are asked to choose a single moment in time to cast a global ability that deals fixed damage to all enemies, with the goal of maximizing the gold gained from kills.

codeforcescompetitive-programmingbrute-forcegreedysortings
CF 912A - Tricky Alchemy

We have two kinds of crystals available: yellow and blue. Producing each type of ball consumes crystals in a fixed recipe. A yellow ball requires 2 yellow crystals. A green ball requires 1 yellow crystal and 1 blue crystal. A blue ball requires 3 blue crystals.

codeforcescompetitive-programmingimplementation
CF 911F - Tree Destruction

We are asked to process a tree with n vertices by performing n - 1 operations that each choose two leaves, add the distance between them to a running total, and remove one of the leaves.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similargraphsgreedytrees
CF 911E - Stack Sorting

Problem Statement: You are given an array of integers $a1, a2, dots, an$ and an integer $k$. You can perform at most $k$ operations. In each operation, you can remove either the first or the last element of the array.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresgreedyimplementation
CF 911G - Mass Change Queries

We are given a one-dimensional array of integers, and we must process a sequence of queries that selectively replace values in subarrays. Each query specifies a range within the array and two integers, x and y. For every element in that range equal to x, we replace it with y.

codeforcescompetitive-programmingdata-structures
CF 911C - Three Garlands

We are asked to decide whether three periodic garlands can be switched on so that at least one of them is always lit starting from the moment the last garland is switched on. Each garland has a fixed period, which means that once turned on, it lights every k-th second.

codeforcescompetitive-programmingbrute-forceconstructive-algorithms
CF 911B - Two Cakes

We are given two collections of indivisible cake pieces, one cake split into a pieces and another split into b pieces. We also have n plates, and we must distribute all pieces onto these plates.

codeforcescompetitive-programmingbinary-searchbrute-forceimplementation
CF 911D - Inversion Counting

We are given a permutation of integers from 1 to n, meaning every number in that range appears exactly once in some order. An inversion is a pair of positions where a larger index holds a smaller number than a smaller index, effectively a local "disorder.

codeforcescompetitive-programmingbrute-forcemath
CF 910A - The Way to Home

We are given a one-dimensional line of positions from 1 to n. Some positions contain a lily, represented by a 1, while others are empty, represented by a 0. A frog starts at position 1 and wants to reach position n.

codeforcescompetitive-programmingdfs-and-similardpgreedyimplementation
CF 910B - Door Frames

We have a workshop scenario where Petya wants to build two identical door frames using uniform wooden bars of length n. Each door frame consists of three sides: two vertical sides of length a and one horizontal top of length b.

codeforcescompetitive-programminggreedyimplementation
CF 909A - Generate Login

We are asked to construct a login from a user's first and last names by concatenating a non-empty prefix of the first name with a non-empty prefix of the last name.

codeforcescompetitive-programmingbrute-forcegreedysortings
CF 909F - AND-permutations

We must construct two completely different permutations of the numbers 1...N. For the first permutation p, every position i must receive a different value, and the bitwise AND of the position and its assigned value must be exactly zero.

codeforcescompetitive-programmingconstructive-algorithms
CF 909D - Colorful Points

The input is a string where each character represents the color of a point on a line. Adjacent characters correspond to neighboring points. During one operation, every point that has at least one neighboring point of a different color is deleted.

codeforcescompetitive-programmingdata-structuresgreedyimplementation
CF 908G - New Year and Original Order

We are given a very large integer $X$, potentially with up to 700 decimal digits. This number is not something we can treat as a standard integer in memory, so any solution must work directly on its digit representation.

codeforcescompetitive-programmingdpmath
CF 908F - New Year and Rainbow Roads

We are given a sequence of points on the number line, each colored red, green, or blue. The goal is to connect the points with edges such that every point is reachable from every other point, and the total sum of edge lengths is minimized.

codeforcescompetitive-programminggraphsgreedyimplementation
CF 908E - New Year and Entity Enumeration

We work with binary vectors of length m, which can be viewed as integers from 0 to 2^m - 1. A valid set S must satisfy three structural properties. First, it contains every vector from the given set T. Second, it is closed under XOR.

codeforcescompetitive-programmingbitmaskscombinatoricsdpmath
CF 908B - New Year and Buggy Bot

We have a robot placed in a 2D grid that represents a maze. Each cell of the maze is either empty, denoted by '.', or blocked, denoted by ''. There is a unique starting position 'S' and a unique exit 'E'.

codeforcescompetitive-programmingbrute-forceimplementation
CF 908D - New Year and Arbitrary Arrangement

We build a string one character at a time. At each step we append 'a' with probability $$frac{pa}{pa+pb}$$ and append 'b' with probability $$frac{pb}{pa+pb}.$$ For a fixed string, the number of subsequences equal to "ab" is easy to describe.

codeforcescompetitive-programmingdpmathprobabilities
CF 908C - New Year and Curling

We are given a set of disks of equal radius that are initially positioned above the plane at a very high y coordinate.

codeforcescompetitive-programmingbrute-forcegeometryimplementationmath
CF 906D - Power Tower

We are asked to compute a "power tower" modulo a given number. Conceptually, imagine a sequence of rocks, each with a positive integer power.

codeforcescompetitive-programmingchinese-remainder-theoremmathnumber-theory
CF 906E - Reverses

We are given two strings of equal length. The first string, s, is the original string. The second string, t, is obtained after several pairwise disjoint substrings of s were reversed. The hurricane has already performed those reversals and produced t.

codeforcescompetitive-programmingdpstring-suffix-structuresstrings
CF 906C - Party

We have a connected friendship graph. Choosing a vertex means that all of its neighbors become pairwise adjacent. In graph theory language, we are allowed to pick a vertex and turn its open neighborhood into a clique.

codeforcescompetitive-programmingbitmasksbrute-forcedpgraphs
CF 906B - Seating of Students

We are asked to rearrange students in a classroom so that no two students who were neighbors in the original seating remain neighbors in the new arrangement. The classroom is an n×m grid, and the students are numbered sequentially from 1 to n·m in row-major order.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsmath
CF 906A - Shockers

Valentin is playing a game where a single unknown letter has been chosen, and every time he pronounces a word containing that letter, he gets shocked. He can also make guesses about the letter, and incorrect guesses result in shocks.

codeforcescompetitive-programmingimplementationstrings
CF 903G - Yet Another Maxflow Problem

The graph consists of two directed chains. Vertices $A1,dots,An$ form one chain and $B1,dots,Bn$ form another. Capacities on the $B$-chain are fixed. Capacities on the $A$-chain are updated online.

codeforcescompetitive-programmingdata-structuresflowsgraphs
CF 903F - Clear The Matrix

We are given a 4-row by n-column matrix filled with either asterisks or dots. The asterisks represent tiles that must be cleared. The allowed operation is selecting a square submatrix of size 1×1 up to 4×4 and replacing every asterisk inside it with dots.

codeforcescompetitive-programmingbitmasksdp
CF 903B - The Modcrab

Vova is fighting a monster called the Modcrab. He has a set amount of health, an attack value, and an unlimited supply of healing potions. Each potion restores a fixed number of health points, and crucially, the potion heals more than the Modcrab can deal in a single attack.

codeforcescompetitive-programminggreedyimplementation
CF 903D - Almost Difference

We are given an array of up to 200000 integers. For every pair of positions $(i,j)$ with $ile j$, we evaluate a special function $d(ai,aj)$, and we need the sum over all pairs. The function behaves differently from a normal difference.

codeforcescompetitive-programmingdata-structuresmath
CF 903E - Swapping Characters

We are given $k$ strings of the same length $n$. Each of them was produced from a single unknown original string by performing exactly one swap of two different positions. The swapped characters are allowed to be equal, so a string may remain unchanged after the operation.

codeforcescompetitive-programmingbrute-forcehashingimplementationstrings
CF 903C - Boxes Packing

We are given n cubic boxes, each with a side length specified by an array a. Mishka wants to nest these boxes inside each other according to strict rules: a box can go into another box only if it is strictly smaller and the larger box does not already contain another box.

codeforcescompetitive-programminggreedy
CF 903A - Hungry Student Problem

The task asks whether Ivan can buy exactly x chicken chunks using only small portions of 3 chunks and large portions of 7 chunks.

codeforcescompetitive-programminggreedyimplementation
CF 902B - Coloring a Tree

We are given a rooted tree with n vertices, where vertex 1 is the root. Each vertex must be colored with a target color specified in the input. Initially, all vertices are color 0.

codeforcescompetitive-programmingdfs-and-similardsugreedy
CF 908H - New Year and Boolean Bridges

We are given an unknown directed graph with n nodes. For each pair of nodes u and v, we are told a Boolean condition that involves reachability in the graph: either the AND, OR, or XOR of whether u can reach v and whether v can reach u is true.

codeforcescompetitive-programming
CF 908A - New Year and Counting Cards

We see one side of every card. A visible side can be either a lowercase letter or a digit. The statement we want to verify is: "Whenever a card has a vowel on one side, the other side contains an even digit." We may flip some cards.

codeforcescompetitive-programmingbrute-forceimplementation
CF 909C - Python Indentation

We are given a sequence of program statements. Each statement is either: f , a for statement whose body must contain at least one statement at one indentation level deeper. s , a simple statement that occupies exactly one line and does not create a new block.

codeforcescompetitive-programmingdp
CF 910C - Minimum Sum

We are given several strings made from the letters 'a' through 'j'. Originally, these strings were decimal numbers. A prankster replaced every digit with a unique letter, creating a one-to-one correspondence between the ten digits 0...9 and the ten letters a...j.

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 911A - Nearest Minimums

We are given an array of integers. Among all values in the array, there is a smallest value, and the problem guarantees that this minimum value appears at least twice. Our task is to find the smallest distance between any two occurrences of that minimum value.

codeforcescompetitive-programmingimplementation
CF 913B - Christmas Spruce

We are given a rooted tree with vertices numbered from 1 to n. Vertex 1 is always the root. For every other vertex, the input tells us its parent, which completely defines the tree structure. A vertex is considered a leaf if it has no children and is not the root.

codeforcescompetitive-programmingimplementationtrees
CF 914F - Substrings in a String

We are given a mutable string and a sequence of queries. Each query either changes a character at a specific position or asks how many times a smaller string appears as a substring within a specific substring of the main string.

codeforcescompetitive-programmingbitmasksbrute-forcedata-structuresstring-suffix-structuresstrings
CF 914B - Conan and Agasa play a Card Game

We have a game where Conan and Agasa take turns removing cards from a pile. Each card has a positive integer written on it. When a player chooses a card, not only does that card get removed, but all cards with strictly smaller numbers are removed as well.

codeforcescompetitive-programminggamesgreedyimplementation
CF 915C - Permute Digits

We are given two integers, a and b. Our task is to rearrange the digits of a to produce the largest possible number that does not exceed b. The resulting number must use all digits of a exactly once and cannot have leading zeros.

codeforcescompetitive-programmingdpgreedy
CF 916B - Jamie and Binary Sequence (changed after round)

We want to represent a positive integer n as a sum of exactly k powers of two: $$n = 2^{a1} + 2^{a2} + cdots + 2^{ak}$$ The exponents may be positive, zero, or even negative. Among all valid sequences of length k, we first minimize the largest exponent that appears.

codeforcescompetitive-programmingbitmasksgreedymath
CF 917A - The Monster

We are given a string consisting of three possible characters: '(', ')', and '?'. For every substring, we ask whether it can be turned into a non-empty correct bracket sequence by replacing each '?' independently with either '(' or ')'. Such a substring is called pretty.

codeforcescompetitive-programmingdpgreedyimplementationmath
CF 918A - Eleven

We are asked to generate a string of length n consisting only of the letter 'O' in uppercase and lowercase, following a rule based on the Fibonacci sequence. The positions in the string that correspond to Fibonacci numbers (1, 2, 3, 5, 8, ...

codeforcescompetitive-programmingbrute-forceimplementation
CF 919B - Perfect Number

A positive integer is called perfect when the sum of all of its decimal digits is exactly 10. We are given an integer k, and we must output the k-th smallest positive integer whose digit sum equals 10. The ordering is the usual numerical ordering.

codeforcescompetitive-programmingbinary-searchbrute-forcedpimplementationnumber-theory
CF 920A - Water The Garden

We are given a linear garden with n consecutive beds and a subset of these beds containing water taps. Each tap, once turned on, waters the bed it occupies immediately, and in each subsequent second it extends its coverage by one bed in both directions.

codeforcescompetitive-programmingimplementation
CF 1089F - Fractions

We are given an integer $n$, and we want to represent a fixed rational number, specifically $1 - frac{1}{n}$, as a sum of several smaller fractions. Each fraction must have a denominator that is a proper divisor of $n$, meaning it divides $n$ but is neither 1 nor $n$.

codeforcescompetitive-programmingmath
CF 1089B - Bimatching

We are given two sets of vertices, each with n nodes, and m edges that connect vertices from the first set to vertices in the second. Each edge has an associated cost.

codeforcescompetitive-programminggraphs
CF 1091F - New Year and the Mallard Expedition

We are given a long one-dimensional route made of consecutive segments. Each segment has a length and a terrain type, either grass, water, or lava. Bob starts just before the first segment and wants to reach the far end after the last segment.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1091B - New Year and the Treasure Geolocation

We are given a set of obelisks on a 2D plane and a set of clues that indicate vectors from obelisks to a hidden treasure. Each obelisk has exactly one clue, but the mapping is scrambled, so we do not know which clue belongs to which obelisk.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedyimplementation
CF 1095F - Make It Connected

We are given n vertices, each with a number ai written on it, and no edges initially. We can connect any two vertices by paying the sum of their numbers ax + ay. Additionally, there are m special offers, each allowing a particular edge to be added at a discounted cost w.

codeforcescompetitive-programmingdsugraphsgreedy
CF 1095B - Array Stabilization

We are given a list of numbers representing an array, and we are allowed to remove exactly one element. After removing it, we look at how “spread out” the remaining numbers are, defined as the difference between the largest and smallest remaining value.

codeforcescompetitive-programmingimplementation
CF 1097F - Alex and a TV Show

We are asked to simulate operations on a set of multisets, each initially empty. The operations are either assigning a single value to a multiset, combining two multisets via union, combining two multisets via a multiset product using greatest common divisors, or querying the…

codeforcescompetitive-programmingbitmaskscombinatoricsnumber-theory
CF 1097A - Gennady and a Card Game

The game Gennady plays involves matching cards either by rank or suit. In practical terms, you are given a single card on the table and a hand of five cards.

codeforcescompetitive-programmingbrute-forceimplementation
CF 1099B - Squares and Segments

We are asked to think about building a figure composed of unit squares drawn on a grid, where every square is outlined by horizontal and vertical unit segments. Each segment can be either horizontal or vertical, and every segment has length exactly one.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsmath
CF 1100C - NN and the Optical Illusion

We are building a very specific circle configuration. There is one central circle of radius $r$. Around it, $n$ identical circles are placed so that they form a ring.

codeforcescompetitive-programmingbinary-searchgeometrymath
CF 1101F - Trucks and Cities

We have a sequence of cities arranged along a single road at increasing distances from the origin. Each truck travels from a starting city to a destination city along this road. The trucks consume fuel linearly with distance and start with a full tank.

codeforcescompetitive-programmingbinary-searchdp