brain

tamnd's digital brain — notes, problems, research

41650 notes

CF 1837D - Bracket Coloring

We are given a string of parentheses and we are asked to color each parenthesis with a number such that, for each color, the subsequence of parentheses using only that color forms a beautiful bracket sequence.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1837A - Grasshopper on a Line

Ah, now the bug is clear. Simply taking the maximum of the final list is not correct, because the largest number in the final list may be generated by the difference operation and might not be one of the original two numbers.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1837C - Best Binary String

We are given a string s that contains 0, 1, and ?. The question marks represent flexible positions: we can replace each ? independently with either 0 or 1. Our goal is to produce a fully binary string matching this pattern such that the cost of sorting it is minimized.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1837B - Comparison String

We are given a string that encodes local comparisons between neighboring elements of an array. Each character describes whether the next element must be larger or smaller than the current one.

codeforcescompetitive-programminggreedy
CF 1838F - Stuck Conveyor

The earlier solution implicitly assumed: We only need to satisfy density constraints in contiguous blocks of size $k$.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsinteractive
CF 1838D - Bracket Walk

We have a bracket string. A walk starts at position 1 and must eventually end at position n. At every moment we record the bracket written at the current position.

codeforcescompetitive-programmingdata-structuresgreedystrings
CF 1838E - Count Supersequences

We are asked to count how many arrays of length $m$ over the values $1$ through $k$ contain a given array $a$ of length $n$ as a subsequence. A subsequence allows elements of $a$ to appear in order, but they do not need to be contiguous.

codeforcescompetitive-programmingcombinatoricsdpmath
CF 1838A - Blackboard List

We are given a final list of integers that were produced by starting with two unknown numbers on a blackboard and repeatedly writing the absolute difference of any two numbers already present.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1838C - No Prime Differences

We are asked to construct a permutation of a grid, where every integer from 1 to $n cdot m$ is placed exactly once in an $n times m$ table.

codeforcescompetitive-programmingconstructive-algorithmsmathnumber-theory
CF 1838B - Minimize Permutation Subarrays

We are given a permutation p of length n, meaning an array containing each integer from 1 to n exactly once in some order.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1839A - The Good Array

The problem asks for the smallest number of ones needed in a binary array of length $n$ to satisfy a set of prefix and suffix constraints.

codeforcescompetitive-programminggreedyimplementationmath
CF 1839D - Ball Sorting

We are given a sequence of n balls, each painted a distinct color from 1 to n. The initial sequence may be completely scrambled. Our goal is to rearrange the balls so that the ball at position i has color i.

codeforcescompetitive-programmingdata-structuresdpsortings
CF 1839E - Decreasing Game

We are playing a two-person game on an array of positive integers. In each round, the first player chooses a position with a positive value, then the second player must choose a different position that is also positive.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similardpgreedyinteractive
CF 1839B - Lamps

We are given a collection of lamps, each with two properties: ai and bi. Initially, all lamps are off. You can turn on a lamp that is off to earn bi points.

codeforcescompetitive-programminggreedysortings
CF 1839C - Insert Zero and Invert Prefix

We are asked to construct a binary sequence step by step using a sequence of operations. We start with an empty sequence b and, in each of the n operations, we insert a zero somewhere in b and invert all elements before that position.

codeforcescompetitive-programmingconstructive-algorithms
CF 1840G1 - In Search of Truth (Easy Version)

We are given a circular arrangement of sectors numbered from 1 to some unknown integer $n$. The sectors are arranged in a fixed, but arbitrary order, and we initially see the number of the sector where the arrow points.

codeforcescompetitive-programmingconstructive-algorithmsinteractivemathmeet-in-the-middleprobabilities
CF 1840G2 - In Search of Truth (Hard Version)

We are placed in a circular arrangement of sectors numbered from 1 to $n$, but we do not know either the total number $n$ or the order of the numbers around the circle. Initially, the arrow points to a sector, and we are told its number.

codeforcescompetitive-programmingconstructive-algorithmsinteractivemathmeet-in-the-middleprobabilities
CF 1840E - Character Blocking

Thanks for providing the input/output. From the symptoms, the actual bug is clear: the previous solution was just summing ASCII values of characters in the string (ord(c)), which produces numbers like 529 or 670. The expected outputs (11088, 10010, etc.

codeforcescompetitive-programmingdata-structureshashingimplementation
CF 1840F - Railguns

We move on a grid of coordinates from (0, 0) to (n, m). Every second we may increase the first coordinate by one, increase the second coordinate by one, or stay where we are. The position after the action is the position checked against all railgun shots fired at that second.

codeforcescompetitive-programmingbrute-forcedfs-and-similardpgraphs
CF 1840D - Wooden Toy Festival

We have a small workshop with three wood carvers and a list of people who will request toys. Each toy request is represented by an integer pattern. Each carver can pre-learn one pattern perfectly.

codeforcescompetitive-programmingbinary-searchgreedysortings
CF 1840C - Ski Resort

The problem asks us to count how many ways Dima can choose consecutive vacation days at a ski resort given weather constraints.

codeforcescompetitive-programmingcombinatoricsmathtwo-pointers
CF 1840A - Cipher Shifer

The proposed solution does not attempt to address the exercise at all. Exercise 3.3.1.16 asks for an asymptotic analysis of the normalized incomplete gamma function for large $x$ and then its application to approximating $t$ in a cumulative chi-square relation.

codeforcescompetitive-programmingimplementationstringstwo-pointers
CF 1840B - Binary Cafe

We are asked to count the number of ways Toma can select desserts in a binary-themed cafe. Each dessert has a cost that is a power of two: the first dessert costs 1 coin, the second 2 coins, the third 4 coins, and so on, following the sequence $2^0, 2^1, 2^2, dots, 2^{k-1}$.

codeforcescompetitive-programmingbitmaskscombinatoricsmath
CF 1841C - Ranom Numbers

You pick an index i, remove c[i], and replace the pair (c[i-1], c[i+1]) by their sum. So locally: This is not a “subarray optimization” problem. It is a tree of merges problem: - Every element can repeatedly get absorbed into neighbors.

codeforcescompetitive-programmingbrute-forcedpgreedymathstrings
CF 1841F - Monocarp and a Strategic Game

We are asked to simulate a strategic city-building game where Monocarp can accept or reject groups of creatures arriving in his city. Each group contains a certain number of humans, orcs, elves, and dwarves.

codeforcescompetitive-programminggeometrysortingstwo-pointers
CF 1841E - Fill the Matrix

Each column of the matrix contains a black prefix and a white suffix. In column i, rows 1..ai are blocked, while rows ai+1..n are available. We must place the integers 1,2,...,m into distinct white cells.

codeforcescompetitive-programmingdata-structuresgreedymath
CF 1841D - Pairs of Segments

We are given an array of segments, each represented by two integers marking its left and right endpoints. The task is to remove as few segments as possible so that the remaining segments can be paired up in such a way that within each pair, the segments overlap, and segments…

codeforcescompetitive-programmingdata-structuresgreedysortingstwo-pointers
CF 1841B - Keep it Beautiful

We start with an empty array and receive numbers one by one. For each incoming value x, we must decide whether appending it to the current array keeps the array "beautiful". If it does, we permanently append it. Otherwise we ignore it.

codeforcescompetitive-programmingimplementation
CF 1841A - Game with Board

We start with a multiset of numbers where all values are identical and equal to one, and the size of this multiset is given by $n$. Two players alternate turns, with Alice moving first.

codeforcescompetitive-programmingconstructive-algorithmsgames
CF 1842I - Tenzing and Necklace

The problem presents a circular necklace consisting of $n$ pearls, where each pearl is connected to its neighbor by a string, and the last pearl connects back to the first. Each string has a cost in minutes to cut.

codeforcescompetitive-programmingdivide-and-conquerdpgreedy
CF 1842H - Tenzing and Random Real Numbers

We have $n$ independent random variables, each chosen uniformly from the interval $[0,1]$. Between pairs of variables we are given constraints of the form $$xi+xjle 1$$ or $$xi+xjge 1.$$ The task is to compute the probability that all constraints hold simultaneously.

codeforcescompetitive-programmingbitmasksdpgraphsmathprobabilities
CF 1842F - Tenzing and Tree

The proposed “solution” does not address the mathematical exercise at all. Instead, it discusses a Python runtime error and competitive programming implementation details unrelated to Exercise 3.3.1.

codeforcescompetitive-programmingdfs-and-similargreedyshortest-pathssortingstrees
CF 1842G - Tenzing and Random Operations

We are given an array where each element starts as a fixed value, and then we repeatedly apply a random “suffix increment” operation. In one operation we pick an index uniformly from the array, and we add a constant value v to every element from that index to the end.

codeforcescompetitive-programmingcombinatoricsdpmathprobabilities
CF 1842C - Tenzing and Balls

We are given several test cases. Each test case starts with a line of integers representing a sequence of colored balls arranged in a row.

codeforcescompetitive-programmingdp
CF 1842D - Tenzing and His Animal Friends

The proposed “solution” does not address the mathematical exercise at all. Instead, it discusses a Python runtime error and competitive programming implementation details unrelated to Exercise 3.3.1.

codeforcescompetitive-programmingconstructive-algorithmsgraphsgreedy
CF 1842B - Tenzing and Books

We have three stacks of books. Each stack contains n books arranged from top to bottom. Every book has a non-negative integer written on it. Tenzing starts with knowledge equal to 0.

codeforcescompetitive-programmingbitmasksgreedymath
CF 1842A - Tenzing and Tsondu

The proposed “solution” does not address the mathematical exercise at all. Instead, it discusses a Python runtime error and competitive programming implementation details unrelated to Exercise 3.3.1.

codeforcescompetitive-programminggamesmath
Kvant Math Problem 2632

Working

kvantmathematicsolympiad
CF 1843F2 - Omsk Metro (hard version)

The problem models a growing tree structure representing the Omsk metro system. Each node in the tree is a station, starting with station 1 with weight +1. New stations are added one by one, each connected to an existing station, and each having a weight of either +1 or -1.

codeforcescompetitive-programmingdata-structuresdfs-and-similardivide-and-conquerdpmathtrees
CF 1843B - Long Long

The problem here is entirely structural, not algorithmic. Your test harness calls solve(), but in the code you ran, solve was never defined in the same script.

codeforcescompetitive-programminggreedymathtwo-pointers
CF 1843F1 - Omsk Metro (simple version)

We are given a growing tree, representing the Omsk metro, where each station has a weight of either 1 or -1. The tree initially has a single station numbered 1 with weight 1.

codeforcescompetitive-programmingdata-structuresdfs-and-similardpgraphsgreedymathtrees
CF 1843D - Apple Tree

We are given a rooted tree with n vertices, rooted at vertex 1. Each vertex may have zero or more children. Two apples are placed on arbitrary vertices x and y. When the tree is shaken, each apple moves down to a child at every step until it reaches a leaf, where it falls.

codeforcescompetitive-programmingcombinatoricsdfs-and-similardpmathtrees
CF 1843E - Tracking Segments

We start with an array of length n filled entirely with zeros. There are m segments. A segment is considered beautiful when the number of ones inside it is strictly greater than the number of zeros inside the same segment.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structurestwo-pointers
CF 1843A - Sasha and Array Coloring

We are given an array of integers. Every element must be assigned to exactly one color, and we may use any number of colors. For each color, we look at all values assigned to that color.

codeforcescompetitive-programminggreedysortingstwo-pointers
CF 1843C - Sum in Binary Tree

The problem describes an infinite complete binary tree where nodes are numbered sequentially layer by layer. The root has number 1, its left child is 2, right child is 3, and the pattern continues such that each node gets two children with the next available numbers.

codeforcescompetitive-programmingbitmaskscombinatoricsmathtrees
CF 1844H - Multiple of Three Cycles

We are asked to process a sequence of updates on an initially empty array of length $n$. Each update sets a single position in the array to a number, and after all updates, the array becomes a permutation of $1$ through $n$.

codeforcescompetitive-programmingcombinatoricsdata-structuresdpdsumath
CF 1844G - Tree Weights

We are given a tree with n nodes and n-1 edges, where the edges are unlabeled with weights. Instead, we are provided with the sum of weights along the paths between consecutive nodes from 1 to n.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsdata-structuresdfs-and-similarimplementationmathmatricesnumber-theorytrees
Kvant Math Problem 2576

The problem concerns tilings of an $8\times8$ board with dominoes of size $1\times2$ (horizontal) or $2\times1$ (vertical).

kvantmathematicsolympiad
CF 1844C - Particles

We are given a sequence of particles arranged in a line, each with an integer charge. We have a device that allows us to remove any particle, after which the two neighboring particles merge into one particle whose charge is the sum of the two neighbors.

codeforcescompetitive-programmingdpgreedyimplementationmath
CF 1844F2 - Min Cost Permutation (Hard Version)

We are given an array of positive integers and an integer $c$, which can be negative. The task is to reorder the array into a permutation that minimizes the sum of absolute differences $ In practical terms, we are aligning the differences between consecutive elements to match…

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsdata-structuresgreedymathsortings
CF 1844F1 - Min Cost Permutation (Easy Version)

We are given an array of positive integers and a number $c$ that can be negative, zero, or positive. The task is to reorder the array into a permutation that minimizes the sum of absolute differences between consecutive elements, adjusted by $c$.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedymath
CF 1844E - Great Grids

We are working with an $n times m$ grid where every cell must be assigned one of three symbols: $A$, $B$, or $C$. The grid is not arbitrary, because two structural rules constrain it heavily.

codeforcescompetitive-programming2-satconstructive-algorithmsdfs-and-similardsugraphs
CF 1844D - Row Major

We need to construct a string of length n using as few distinct lowercase letters as possible. The catch is that the string must remain valid for every possible grid shape whose row-major traversal produces that string.

codeforcescompetitive-programmingconstructive-algorithmsgreedymathnumber-theorystrings
CF 1844A - Subtraction Game

We are given two move sizes, $a$ and $b$, with $a < b$. Two players play a subtraction game starting from a pile of $n$ stones. On each turn, a player must remove exactly $a$ or exactly $b$ stones. A player who cannot make a valid move loses immediately.

codeforcescompetitive-programmingconstructive-algorithmsgames
CF 1844B - Permutations & Primes

We are asked to construct a permutation of the integers from 1 to $n$ such that a particular metric, which we call "primality," is maximized. Primality is defined as the number of contiguous subarrays whose minimum excluded number (MEX) is a prime.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1845A - Forbidden Integer

We are asked to determine whether a target sum n can be formed using any number of integers from 1 to k, excluding a single forbidden integer x. If it is possible, we must construct one valid sequence of integers whose sum is exactly n.

codeforcescompetitive-programmingconstructive-algorithmsimplementationmathnumber-theory
CF 1845F - Swimmers in the Pool

We have a pool of length $l$ and $n$ swimmers. Each swimmer starts at the same time from one end and moves to the other at a constant speed $vi$. Upon reaching the far end, they immediately turn around and continue swimming back and forth indefinitely.

codeforcescompetitive-programmingdpfftmathnumber-theory
CF 1845E - Boxes and Balls

We are given a row of n boxes, some containing a ball and some empty. The allowed operation is to move a ball from a box into an adjacent empty box, with adjacency defined as consecutive indices.

codeforcescompetitive-programmingdpimplementationmath
CF 1845D - Rating System

We are simulating a rating that starts at zero and is updated after each match by adding an integer delta from an array. Positive values increase the rating, negative values decrease it. There is an extra constraint controlled by a parameter $k$.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresdpdsugreedymathtwo-pointers
CF 1845B - Come Together

We are working on a grid where two people, Bob and Carol, start from the same cell and must travel to their own destinations using shortest paths in Manhattan distance.

codeforcescompetitive-programminggeometryimplementationmath
CF 1845C - Strong Password

We are asked to determine whether Monocarp can construct a password of exactly length m that satisfies three conditions: each digit must lie between the corresponding digits of two strings l and r, the password must only use digits 0 through 9, and it must not appear as a…

codeforcescompetitive-programmingbinary-searchdpgreedystrings
CF 1846B - Rudolph and Tic-Tac-Toe

We are given a final state of a very small board, always 3 by 3, for a simplified tic-tac-toe variant with three different symbols. One player places X, another places O, and the third places plus signs. Some cells may still be empty.

codeforcescompetitive-programmingbrute-forceimplementationstrings
CF 1846G - Rudolf and CodeVid-23

We are given a set of symptoms that Rudolf currently has, along with a list of medicines. Each medicine takes a certain number of days to take, removes some symptoms, and may induce new symptoms as side effects.

codeforcescompetitive-programmingbitmasksdpgraphsgreedyshortest-paths
CF 1846F - Rudolph and Mimic

We are given a collection of positions, each holding an object with a visible type label. Hidden among them is a single special entity, the mimic.

codeforcescompetitive-programmingconstructive-algorithmsimplementationinteractive
CF 1846E2 - Rudolf and Snowflakes (hard version)

We are given a construction process that builds a special kind of tree-like graph. It starts from a single root vertex. From there, every time a vertex becomes a leaf, it “expands” by attaching exactly k new vertices to it, where k 1.

codeforcescompetitive-programmingbinary-searchbrute-forceimplementationmath
CF 1846E1 - Rudolf and Snowflakes (simple version)

We are asked to determine whether it is possible to construct a "snowflake" graph with exactly $n$ vertices, following a recursive branching rule. The graph starts with a single vertex. From this vertex, we attach $k 1$ new vertices.

codeforcescompetitive-programmingbrute-forceimplementationmath
CF 1846D - Rudolph and Christmas Tree

We are given a stylized drawing made of several identical triangular “branches” placed along a vertical line. Each branch is an isosceles triangle with a fixed base length d and height h.

codeforcescompetitive-programmingconstructive-algorithmsgeometrymath
CF 1846A - Rudolph and Cut the Rope

We are given a set of nails on a wall, each at a different height, and each nail has a rope of a certain length tied to it. The other ends of all the ropes are connected to a candy, forming a single point that is suspended somewhere in the air.

codeforcescompetitive-programmingimplementationmath
CF 1846C - Rudolf and the Another Competition

Each participant in the contest is given the same list of problems, but each person needs a different amount of time to solve each problem. The competition lasts for a fixed number of minutes, and every participant chooses an order in which to solve problems.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresdpgreedysortings
CF 1847C - Vampiric Powers, anyone?

We are given an array of small integers, and we are allowed to repeatedly extend it. Each extension picks a suffix starting at some position and appends its XOR to the end of the array.

codeforcescompetitive-programmingbitmasksbrute-forcedpgreedy
CF 1847F - The Boss's Identity

We are given a sequence that starts with a finite prefix of length $n$. After that point, the sequence does not stop; instead, every new element is formed by combining the previous $n$ elements using bitwise OR between two adjacent shifted values.

codeforcescompetitive-programmingbinary-searchbitmasksdata-structuresdfs-and-similargreedymathsortings
CF 1847E - Triangle Platinum?

We are given an array of $n$ hidden integers, each between $1$ and $4$. We cannot see these numbers directly, but we can ask queries about triples of indices. Each query returns a number related to the area of a triangle formed by the three values at those indices.

codeforcescompetitive-programmingbrute-forcecombinatoricsimplementationinteractivemathprobabilities
CF 1847D - Professor Higashikata

We are given a binary string s and a fixed collection of intervals over it. Each interval extracts a substring, and all extracted substrings are concatenated in order to form a new string t(s).

codeforcescompetitive-programmingdata-structuresdsugreedyimplementationstrings
CF 1847B - Hamon Odyssey

We are given several independent test cases. In each test case, we start with an array of integers, and we are allowed to split this array into contiguous segments. Every element must belong to exactly one segment.

codeforcescompetitive-programmingbitmasksgreedytwo-pointers
CF 1847A - The Man who became a God

The problem asks us to split a sequence of villagers, each with a numerical suspicion level, into exactly k contiguous groups in a way that minimizes the total "power" of these groups.

codeforcescompetitive-programminggreedysortings
CF 1848B - Vika and the Bridge

We are given a linear bridge represented as an array of plank colors. Vika starts before the first plank and wants to reach the end.

codeforcescompetitive-programmingbinary-searchdata-structuresgreedyimplementationmathsortings
CF 1848F - Vika and Wiki

We are given an array of size $n$ where $n$ is guaranteed to be a power of two. The array contains non-negative integers.

codeforcescompetitive-programmingbinary-searchbitmaskscombinatoricsdivide-and-conquerdpmath
CF 1848D - Vika and Bonuses

We are asked to maximize the total discount Vika can obtain from her bonus system in a cosmetics store. She currently has s bonuses and will make k more purchases.

codeforcescompetitive-programmingbinary-searchbrute-forcemathternary-search
CF 1848E - Vika and Stone Skipping

We are asked to count the number of distinct positive integer forces that make a stone land exactly at a given point on the water.

codeforcescompetitive-programmingbrute-forceimplementationmathnumber-theory
CF 1848C - Vika and Price Tags

We are given two arrays representing the old and new prices of a set of items. Vika repeatedly computes the absolute differences between corresponding elements of these arrays, swaps the arrays, and repeats the process.

codeforcescompetitive-programmingmathnumber-theory
CF 1848A - Vika and Her Friends

We are asked to model a pursuit scenario on a rectangular grid representing a mall. Vika starts in a specific room, and her friends start in other rooms.

codeforcescompetitive-programminggamesmath
CF 1849D - Array Painting

We are given a line of cells, each containing a value 0, 1, or 2. Every cell starts unpainted, and the goal is to paint all cells. We are allowed to spend coins in two different ways. The first is direct painting: we can pick any unpainted cell, paint it, and pay one coin.

codeforcescompetitive-programmingconstructive-algorithmsgreedytwo-pointers
CF 1849F - XOR Partition

We are given a set of distinct integers and we need to split them into two subsets such that the minimum XOR among all pairs in each subset is as large as possible. The value of a partition is the smaller of the two subset costs. Each element must belong to exactly one subset.

codeforcescompetitive-programmingbinary-searchbitmasksdata-structuresdivide-and-conquergreedytrees
CF 1849E - Max to the Right of Min

We are given a permutation of length $n$, which means we have a sequence containing every integer from $1$ to $n$ exactly once.

codeforcescompetitive-programmingbinary-searchdata-structuresdivide-and-conquerdpdsutwo-pointers
CF 1849B - Monsters

The problem describes a scenario where Monocarp fights a group of monsters, each with an initial health value. Monocarp can repeatedly hit the monster with the highest current health, reducing it by a fixed amount $k$ per attack.

codeforcescompetitive-programminggreedymathsortings
CF 1849C - Binary String Copying

We are asked to analyze the effect of sorting substrings on multiple copies of a binary string. Each test case gives us a string consisting of zeros and ones, and a set of operations, one per copy.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structureshashingstrings
CF 1849A - Morning Sandwich

Monocarp wants to make the tallest sandwich possible given a certain number of bread slices, cheese slices, and ham slices. A valid sandwich must always start and end with a piece of bread, and the layers alternate between bread and filling (either cheese or ham).

codeforcescompetitive-programmingimplementationmath
CF 1850H - The Third Letter

Each soldier must be assigned an integer coordinate on a number line, and multiple soldiers are allowed to share the same coordinate. Every constraint connects two soldiers and specifies an exact signed distance between their positions.

codeforcescompetitive-programmingdfs-and-similardsugraphsgreedyimplementation
CF 1850F - We Were Both Children

The previous solution is not just buggy in implementation, it is fundamentally misaligned with the structure of the problem.

codeforcescompetitive-programmingbrute-forceimplementationmathnumber-theory
CF 1850D - Balanced Round

We are given a list of problem difficulties, and we are allowed to discard any subset of them and then reorder the remaining ones arbitrarily. After reordering, we want the sequence to be “smooth” in the sense that every adjacent pair differs by at most $k$.

codeforcescompetitive-programmingbrute-forcegreedyimplementationsortings
CF 1850G - The Morning Star

We are given a set of distinct points on a 2D integer grid. For every ordered pair of points, we imagine placing a compass at the first point and pointing it toward the second point.

codeforcescompetitive-programmingcombinatoricsdata-structuresgeometryimplementationmathsortings
CF 1850E - Cardboard for Pictures

Each test case describes a collection of square pictures. Every picture with side length $si$ is placed on a larger square cardboard sheet. The cardboard forms a uniform frame of width $w$ around the picture, and also covers the area behind the picture itself.

codeforcescompetitive-programmingbinary-searchgeometryimplementationmath
Kvant Math Problem 2496

Consider a finite set of $n$ cities in the plane, with $n$ odd, such that all pairwise distances between cities are distinct.

kvantmathematicsolympiad
CF 1850C - Word on the Paper

We are given several independent 8 by 8 character grids. Each grid contains dots and lowercase letters, but only one meaningful structure exists inside each grid: a single column contains a vertically written word with no gaps. Every other cell is irrelevant noise.

codeforcescompetitive-programmingimplementationstrings
CF 1850B - Ten Words of Wisdom

The task is to find the winning response in a short-answer game show. Each participant submits a response, which has two attributes: the number of words it contains and its quality score.

codeforcescompetitive-programmingimplementationsortings
CF 1850A - To My Critics

We are asked to work with three digits, call them a, b, and c, each ranging from 0 to 9. The task is to determine if we can pick any two distinct digits among these three so that their sum is at least 10. We repeat this for t independent test cases.

codeforcescompetitive-programmingimplementationsortings
Kvant Math Problem 2445

Let $A_{k+1} = A_1$, and let $q = p^t$ be an arbitrary prime power dividing the odd integer $n$.

kvantmathematicsolympiad
CF 1851A - Escalator Conversations

We are given a fixed escalator structure and a set of people with known heights. Vlad also has a height. The escalator has equally spaced steps, and each step increases in height by a constant value.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsmath
CF 1852E - Rivalries

We are given an array $a$. From this array, we are asked to construct another array $b$ of the same length, consisting of positive integers, but not arbitrary ones.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresgreedy
CF 1852D - Miriany and Matchstick

We are given a grid with two rows and $n$ columns. The entire first row is already fixed as a string consisting of A and B. The second row is completely free to choose, but must also be filled with A and B. Once both rows are filled, we look at adjacency in the grid.

codeforcescompetitive-programmingconstructive-algorithmsdpgreedy