brain

tamnd's digital brain — notes, problems, research

43815 notes

CF 1313A - Fast Food Restaurant

We are given three independent supplies: dumplings, juice, and pancakes. Each visitor receives a subset of these three items, with two constraints. First, a visitor cannot receive more than one of each item type. Second, no two visitors may receive the exact same subset.

codeforcescompetitive-programmingbrute-forcegreedyimplementation
CF 1312B - Bogosort

We are given an array of integers and are allowed to permute it arbitrarily. After rearranging, we assign each value to a position starting from 1. The array is considered valid if no two positions share the same value of the expression i - a[i].

codeforcescompetitive-programmingconstructive-algorithmssortings
CF 1311E - Construct the Binary Tree

We are asked to build a rooted tree on vertices labeled from 1 to n, where vertex 1 is the root. Every vertex except the root has exactly one parent, and each vertex is allowed to have at most two children, so the structure must be a binary tree in the rooted sense.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmstrees
CF 1310D - Tourism

We are given a complete directed graph of cities where every ordered pair of distinct cities has a travel cost. Starting from city 1, we must perform exactly $k$ moves, and end again at city 1. Each move is just choosing a directed edge and paying its cost.

codeforcescompetitive-programmingdpgraphsprobabilities
CF 1310B - Double Elimination

We are given a full double elimination tournament with $2^n$ teams, where the bracket structure is completely fixed.

codeforcescompetitive-programmingdpimplementation
CF 1307G - Cow and Exercise

We are given a directed weighted graph with up to 50 vertices, representing fields connected by roads. A cow starts at node 1 and wants to reach node n, and the time it takes is determined by the shortest path in this graph. Now the twist: we are allowed to “slow down” edges.

codeforcescompetitive-programmingflowsgraphsshortest-paths
CF 1307B - Cow and Friend

A rabbit starts at the origin in the plane and wants to land exactly at the point $(x, 0)$. He moves by making a sequence of jumps, and each jump can have any direction, but its length must match one of the allowed values given in the input.

codeforcescompetitive-programminggeometrygreedymath
CF 1307D - Cow and Fields

We are given an undirected, connected graph representing fields connected by roads. A traveler starts at node 1 and wants to reach node n using the shortest possible route.

codeforcescompetitive-programmingbinary-searchdata-structuresdfs-and-similargraphsgreedyshortest-pathssortings
CF 1305E - Kuroni and the Score Distribution

We are asked to construct a strictly increasing sequence of integers $a1 < a2 < dots < an$, all between 1 and $10^9$, such that a specific combinatorial condition on triples is satisfied.

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementationmath
CF 1305H - Kuroni the Private Tutor

We are given an exam with a fixed number of questions, where each question contributes either 0 or 1 point to each student.

codeforcescompetitive-programmingbinary-searchgreedy
CF 1305D - Kuroni and the Celebration

We are given a fixed tree with up to 1000 vertices. Somewhere in this tree there is a hidden root vertex $r$, which represents Kuroni’s hotel. The structure of the tree is known, but the root is not.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similarinteractivetrees
CF 1304F2 - Animal Observation (hard version)

We are given a grid of values over time. Each row represents a day, and each column represents a spatial segment of a forest. The value in a cell tells how many animals can be observed in that segment on that day.

codeforcescompetitive-programmingdata-structuresdpgreedy
CF 1304B - Longest Palindrome

We are given a collection of distinct strings, all of the same length, and we are allowed to pick any subset of them and arrange the chosen strings in some order. After concatenation, the goal is to obtain a palindrome with maximum possible total length.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedyimplementationstrings
CF 1304F1 - Animal Observation (easy version)

We are given a grid that evolves over time. Each day produces a full array of animal counts across a line of forest sections. We want to place two cameras repeatedly over a sequence of days, where each camera always covers a contiguous segment of exactly $k$ forest sections.

codeforcescompetitive-programmingdata-structuresdp
CF 1304D - Shortest and Longest LIS

We are given a pattern of strict comparisons between consecutive positions in a permutation of size n. Each position tells whether the next value must be larger or smaller than the current one. From this constraint, many permutations are possible.

codeforcescompetitive-programmingconstructive-algorithmsgraphsgreedytwo-pointers
CF 1303D - Fill The Bag

We are given a target amount of space, and a collection of available blocks whose sizes are powers of two. The task is to decide whether we can exactly compose the target size using these blocks, and if not, report impossibility.

codeforcescompetitive-programmingbitmasksgreedy
CF 1303G - Sum of Prefix Sums

We are given a tree where each node stores a positive integer. For any simple path between two vertices, we read the values along that path in order and then compute a special score: we first form all prefix sums of that sequence and then sum those prefix sums together.

codeforcescompetitive-programmingdata-structuresdivide-and-conquergeometrytrees
CF 1303F - Number of Components

We are working on a grid that starts completely empty in the sense that every cell contains the same value, zero. Over time, we perform a sequence of updates.

codeforcescompetitive-programmingdsuimplementation
CF 1303B - National Project

We are building a road of length $n$, where each unit of road must eventually be asphalted exactly once. The construction proceeds day by day, and on each day we may either work on exactly one unit or do nothing. The weather is periodic.

codeforcescompetitive-programmingmath
CF 1303C - Perfect Keyboard

We are given a string consisting of lowercase letters, and we want to decide whether it is possible to arrange all 26 letters of the alphabet in a single line such that every consecutive pair of characters appearing in the string are also adjacent in this line layout.

codeforcescompetitive-programmingdfs-and-similargreedyimplementation
CF 1302J - Keep talking and nobody explodes -- hard

We are given a lock described by a sequence of exactly 100 decimal digits. Think of it as a row of 100 small wheels, each showing a digit from 0 to 9.

codeforcescompetitive-programming
CF 1302G - Keep talking and nobody explodes -- medium

We are given a fixed 5-digit lock state. Each digit can be incremented cyclically, so 9 wraps back to 0. Starting from an initial 5-digit configuration, we must apply a long, fixed sequence of conditional rules.

codeforcescompetitive-programming
CF 1302E - Amazing bitset

We are given a binary string of length $n$, but instead of being fixed, each position is generated independently as a random bit: it becomes $1$ with probability $p = frac{a}{b}$ and $0$ with probability $1 - p$.

codeforcescompetitive-programming
CF 1302F - Keep talking and nobody explodes -- easy

We are given a 5-digit lock state. Each digit behaves like a circular counter from 0 to 9, so increasing a digit by 1 means moving to the next digit and wrapping 9 back to 0. The process consists of a fixed sequence of 20 deterministic instructions.

codeforcescompetitive-programmingbitmasksbrute-forceexpression-parsing
CF 1302A - Nash equilibrium

We are working with a rectangular grid of numbers. Each cell behaves like a player in a two-dimensional game: it is compared vertically against its column and horizontally against its row.

codeforcescompetitive-programming
CF 1301E - Nanosoft

We are given a colored grid where each cell is one of four colors. Inside this grid, we are asked many independent queries.

codeforcescompetitive-programmingbinary-searchdata-structuresdpimplementation
CF 1301D - Time to Run

The grid in this problem can be viewed as a directed version of the standard rectangular lattice where every pair of horizontally or vertically adjacent cells is connected by two opposite directed edges.

codeforcescompetitive-programmingconstructive-algorithmsgraphsimplementation
CF 1301B - Motarack's Birthday

We are given an array of length $n$ where some positions contain fixed integers and some positions are marked as missing. All missing positions will be filled with a single chosen value $k$.

codeforcescompetitive-programmingbinary-searchgreedyternary-search
CF 1301A - Three Strings

We are given three strings of equal length. Think of them as three rows of characters aligned in columns. At each column position, we are allowed to perform exactly one operation: we pick either the character in the third string and swap it with the character in the first…

codeforcescompetitive-programmingimplementationstrings
CF 1299E - So Mean

We are given a hidden permutation of numbers from $1$ to $n$, where $n$ is even. We cannot directly see it, but we can query any subset of indices. For a chosen subset, the judge tells us only whether the average value of the selected positions is an integer.

codeforcescompetitive-programminginteractivemath
CF 1299C - Water Balance

We are given a sequence of water volumes arranged in a line. One operation allows us to pick any contiguous segment and replace every value in that segment with their average. This operation can be repeated any number of times on any segments.

codeforcescompetitive-programmingdata-structuresgeometrygreedy
CF 1297I - Falling Blocks

We are given a sequence of horizontal segments that arrive one after another on a 1D board of length $d$. Each segment represents a block that falls vertically until it either touches the ground or touches the top of some previously placed block.

codeforcescompetitive-programming*specialdata-structures
CF 1297H - Paint the String

We are given a string and must assign each character to one of two groups, which we can think of as placing each character into either a red bucket or a blue bucket while preserving their original order inside each bucket.

codeforcescompetitive-programming*specialdpstrings
CF 1297G - M-numbers

We are given a target value $m$ and asked to consider all positive integers whose digits multiply exactly to $m$. These integers form an infinite set in general, and we are asked to sort this set in increasing numerical order and return the $k$-th element.

codeforcescompetitive-programming*specialdpmath
CF 1297F - Movie Fan

We are given several movies, each movie has a time window during which it can be watched in the cinema. If a movie is watched inside its window, it is considered “on time”.

codeforcescompetitive-programming*specialdata-structuresgreedyimplementationsortings
CF 1297D - Bonus Distribution

Each employee has a fixed base salary, and we are allowed to distribute an additional integer bonus so that the total bonus across all employees is exactly k. After adding bonuses, each employee’s final salary becomes their original salary plus their assigned bonus.

codeforcescompetitive-programming*specialbinary-searchgreedysortings
CF 1297E - Modernization of Treeland

We are given a tree of cities. From this tree we must choose a subset of cities $S$ such that two conditions hold simultaneously.

codeforcescompetitive-programming*specialdfs-and-similartrees
CF 1297C - Dream Team

We are given an array of integers for each test case, where each value represents the contribution of a developer. We want to pick a subset of indices to form a team, and the value of the team is simply the sum of the chosen elements.

codeforcescompetitive-programming*specialgreedy
CF 1296F - Berland Beauty

We are given a connected network of $n$ stations connected by $n-1$ railway segments, which means the structure is a tree. Each edge in this tree has an unknown integer weight in the range from 1 to $10^6$. We are also given several observations from passengers.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similargreedysortingstrees
CF 1296D - Fight with Monsters

We are given a sequence of monsters standing in a fixed order. Each monster has a certain amount of health, and they must be defeated one after another from left to right.

codeforcescompetitive-programminggreedysortings
CF 1296E2 - String Coloring (hard version)

We are given a string and we are allowed to assign a color label to each character position. After coloring, we gain a very specific operation: we may swap two adjacent characters only if their colors are different. Swaps can be repeated arbitrarily many times.

codeforcescompetitive-programmingdata-structuresdp
CF 1296B - Food Buying

We are given an initial amount of money, and we repeatedly perform a very specific type of purchase operation. In each operation, we choose some amount $x$ that we can afford at that moment, spend it, and immediately receive back $lfloor x/10 rfloor$.

codeforcescompetitive-programmingmath
CF 1295E - Permutation Separation

We are given a permutation where every value from 1 to n appears exactly once, but the order is arbitrary. Each position also has a cost associated with its element, and that cost is what we pay whenever we move that element between two groups.

codeforcescompetitive-programmingdata-structuresdivide-and-conquer
CF 1295D - Same GCDs

We are working with a fixed number $a$ and a modulus-like bound $m$. For every integer shift $x$ in the range $[0, m-1]$, we look at the number $a + x$ and compare its greatest common divisor with $m$ against the original value $gcd(a, m)$.

codeforcescompetitive-programmingmathnumber-theory
CF 1294F - Three Paths on a Tree

We are working with a tree, which means there is exactly one simple path between any two vertices. From this tree we must choose three distinct vertices, call them $a$, $b$, and $c$.

codeforcescompetitive-programmingdfs-and-similardpgreedytrees
CF 1293B - JOE is on TV!

The game can be seen as a process where we start with n opponents and repeatedly trigger rounds that remove some of them.

codeforcescompetitive-programmingcombinatoricsgreedymath
CF 1292D - Chaotic V.

The graph in this problem is not given explicitly, but fully determined by the structure of integers. Every positive integer is a node, and each number $x 1$ has a directed edge to $x / f(x)$, where $f(x)$ is the smallest prime factor of $x$.

codeforcescompetitive-programmingdpgraphsgreedymathnumber-theorytrees
CF 1292E - Rin and The Unknown Flower

We are trying to reconstruct a hidden string of length up to 50. The string is guaranteed to use only three symbols: C, H, and O.

codeforcescompetitive-programmingconstructive-algorithmsgreedyinteractivemath
CF 1292C - Xenon's Attack on the Gangs

We are given a tree with $n$ nodes and $n-1$ edges. Each edge is assigned a distinct label from $0$ to $n-2$, so every label appears exactly once. For any pair of nodes $u, v$, we look at the unique path between them and collect all edge labels on that path.

codeforcescompetitive-programmingcombinatoricsdfs-and-similardpgreedytrees
CF 1291B - Array Sharpening

We are given an array of non-negative integers. We are allowed to repeatedly decrease any element by 1 as long as it stays non-negative.

codeforcescompetitive-programminggreedyimplementation
CF 1291A - Even But Not Even

We are given a digit string and we are allowed to delete some of its digits while keeping the remaining digits in the same relative order.

codeforcescompetitive-programminggreedymathstrings
CF 1291F - Coffee Varieties (easy version)

We are given a hidden sequence of café types, where each café produces exactly one integer “coffee variety”. We do not know the sequence itself, but we can probe cafés one by one. The interaction tool behaves like a sliding-window memory system.

codeforcescompetitive-programminggraphsinteractive
CF 1290F - Making Shapes

We are given a small set of integer vectors in the plane. Each vector can be used repeatedly as a step, and we form a closed polygonal walk by starting at the origin, repeatedly adding chosen vectors head-to-tail, and eventually returning to the origin.

codeforcescompetitive-programmingdp
CF 1290A - Mind Control

We are given an array of numbers and a line of people who will remove elements from the array one by one. Each person, when it becomes their turn, sees the current array and takes either the leftmost or rightmost element.

codeforcescompetitive-programmingbrute-forcedata-structuresimplementation
CF 1290E - Cartesian Tree

We are building a sequence one element at a time, where after inserting the first i values, we take the current array and construct its Cartesian tree.

codeforcescompetitive-programmingdata-structures
CF 1290D - Coffee Varieties (hard version)

We are given a hidden array of length $n$, where each position represents a café and each café produces exactly one type of coffee. The value at position $i$ is the coffee variety label $ai$, but we never see it directly.

codeforcescompetitive-programmingconstructive-algorithmsgraphsinteractive
CF 1288E - Messenger Simulator

We are maintaining a dynamic “recent chat list” of friends, represented as a permutation of the numbers from 1 to n. The list is ordered from most recent to least recent interaction.

codeforcescompetitive-programmingdata-structures
CF 1288F - Red-Blue Graph

We are given a bipartite graph where every edge can optionally be assigned one of two colors, red or blue, or left unused. Coloring an edge is not free: red costs r, blue costs b, and leaving it unused costs nothing.

codeforcescompetitive-programmingconstructive-algorithmsflows
CF 1286C2 - Madhouse (Hard version)

A hidden string of length $n$ is fixed before the game starts. The player’s goal is to recover this exact string. Instead of being given it directly, the only way to gain information is by querying substrings of ranges.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmshashinginteractivemath
CF 1286B - Numbers on Tree

We are given a rooted tree where every node has a hidden integer value. What we do know is the tree structure and, for each node, a number ci.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresdfs-and-similargraphsgreedytrees
CF 1286C1 - Madhouse (Easy version)

We are dealing with a hidden string of length $n$, made of lowercase English letters. We cannot see the string directly. Instead, we can query any segment $s[l..

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsinteractivemath
CF 1285D - Dr. Evil Underscores

We are given a list of integers, and we are allowed to choose a single integer $X$. Once $X$ is fixed, every array value is transformed by XOR with $X$, and we care about the largest transformed value. The goal is to pick $X$ so that this maximum value is as small as possible.

codeforcescompetitive-programmingbitmasksbrute-forcedfs-and-similardivide-and-conquerdpgreedystringstrees
CF 1285E - Delete a Segment

We are given several intervals on a number line. Each interval represents a continuous segment of covered points. If multiple intervals overlap or touch, their combined covered region merges into a single continuous piece when we take the union.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdata-structuresdpgraphssortingstreestwo-pointers
CF 1285F - Classical?

We are given a list of positive integers and we want to choose two different positions in the list such that the least common multiple of the chosen values is as large as possible.

codeforcescompetitive-programmingbinary-searchcombinatoricsnumber-theory
CF 1284G - Seollal

The task is to take a small grid with blocked and open cells and construct a special “maze representation” on a refined grid. Each input cell becomes a node in a graph, and adjacency exists between orthogonally neighboring open cells.

codeforcescompetitive-programminggraphs
CF 1284F - New Year and Social Network

We are given two different spanning trees over the same set of $n$ vertices. One tree, call it $T1$, represents the main network, and the second tree $T2$ is a backup structure. Each edge in $T1$ is a potential failure point.

codeforcescompetitive-programmingdata-structuresgraph-matchingsgraphsmathtrees
CF 1284E - New Year and Castle Construction

We are given a set of points in the plane, with the restriction that no three points lie on a single line. For every point (p), we want to count how many subsets of exactly four other points can form a simple quadrilateral that strictly contains (p).

codeforcescompetitive-programmingcombinatoricsgeometrymathsortings
CF 1284A - New Year and Naming

We are given two circular lists of strings. The first list has size $n$, the second has size $m$. Each year $y$ produces a name by taking the $y$-th string from the first list and the $y$-th string from the second list, both indexed cyclically, and concatenating them.

codeforcescompetitive-programmingimplementationstrings
CF 1284B - New Year and Ascent Sequence

We are given a collection of integer sequences, and we consider ordered pairs of them. For any pair of sequences $sx$ and $sy$, we concatenate them to form a longer sequence $sx + sy$.

codeforcescompetitive-programmingbinary-searchcombinatoricsdata-structuresdpimplementationsortings
CF 1284D - New Year and Conference

Each lecture in the conference has two possible time schedules, depending on which venue is chosen. If we pick venue A, every lecture follows its A-interval. If we pick venue B, every lecture follows its B-interval.

codeforcescompetitive-programmingbinary-searchdata-structureshashingsortings
CF 1283E - New Year Parties

We are given a set of people placed on integer points on a line. Each person starts at a fixed coordinate and is allowed to move at most one step left, stay where they are, or move one step right.

codeforcescompetitive-programmingdpgreedy
CF 1283F - DIY Garland

We are given a tree with $n$ vertices, where each vertex represents a lamp. One of these lamps is directly connected to a power source, and from it power spreads through directed connections formed by the wires of the tree.

codeforcescompetitive-programmingconstructive-algorithmsgreedytrees
CF 1283D - Christmas Trees

We are given a set of fixed points on a number line, each representing a Christmas tree. We are also asked to place another set of points representing people, but with a twist: each person contributes cost equal to the distance to the nearest tree, and we want to choose all…

codeforcescompetitive-programminggraphsgreedyshortest-paths
CF 1283B - Candies Division

We are distributing a fixed number of identical candies among a fixed number of children. Each child must receive a non-negative integer number of candies, and we are allowed to leave some candies unused.

codeforcescompetitive-programmingmath
CF 1282D - Enchanted Artifact

We are interacting with a hidden binary string $s$ consisting only of characters a and b. We do not know its length, but it is at most 300. Our task is to discover $s$ using queries.

codeforcescompetitive-programmingconstructive-algorithmsinteractivestrings
CF 1282E - The Cake Is a Lie

We are given a collection of triangles that once formed a triangulation of a convex polygon with $n$ vertices. Each triangle corresponds to one cut made during a process where we repeatedly remove a boundary triangle from a convex polygon until nothing remains except the…

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresdfs-and-similargraphs
CF 1282B1 - K for the Price of One (Easy Version)

We are given several independent test cases. In each one, Vasya has a budget and a list of item prices. He wants to maximize how many items he can take from the store. The store has a special promotion with groups of two items.

codeforcescompetitive-programmingdpgreedysortings
CF 1282B2 - K for the Price of One (Hard Version)

We are given a list of item prices and a budget. Vasya wants to maximize the number of items he acquires. He has two ways to buy: he can purchase a single item at its full price, or he can activate a bundle purchase where he chooses a “base” item and simultaneously takes up…

codeforcescompetitive-programmingdpgreedysortings
CF 1281B - Azamon Web Services

We are given two uppercase strings, one representing Jeff’s current product name and another representing a competitor’s product name. We are allowed to improve Jeff’s name by swapping at most one pair of characters inside his string. We may also choose to do nothing.

codeforcescompetitive-programminggreedy
CF 1280E - Kirchhoff's Current Loss

The circuit is given as a fully parenthesized expression that builds a tree of components. Leaves are individual resistors, each represented by . Internal nodes are either series connections or parallel connections over two or more subcircuits.

codeforcescompetitive-programmingmath
CF 1280C - Jeremy Bearimy

We are given a weighted tree with $2k$ vertices. On these vertices we must place $2k$ people, where the people are grouped into $k$ fixed pairs.

codeforcescompetitive-programmingdfs-and-similargraphsgreedytrees
CF 1280D - Miss Punyverse

We are given a tree where each node represents a “nesting place” that contains two types of insects: bees and wasps. Every insect votes for its own side, so bees always contribute to the bee count of a region and wasps always contribute to the wasp count.

codeforcescompetitive-programmingdpgreedytrees
CF 1280B - Beingawesomeism

We are given a grid of size $r times c$, where each cell is either $A$ or $P$. The goal is to convert every $P$ into $A$ using a special operation that behaves like a directional flood from a chosen line segment.

codeforcescompetitive-programmingimplementationmath
CF 1279F - New Year and Handle Change

We are given a string consisting of uppercase and lowercase Latin letters. The task is to apply at most a fixed number of operations, where each operation flips the case of every character in a contiguous segment of fixed length.

codeforcescompetitive-programmingbinary-searchdp
CF 1279E - New Year Permutations

We are given a permutation of the numbers from 1 to n, and a rather unusual procedure that breaks this permutation into consecutive “blocks” based on reachability through functional edges defined by the permutation itself.

codeforcescompetitive-programmingcombinatoricsdp
CF 1279C - Stack of Presents

The situation is a stack of uniquely numbered items, where only the top of the stack is directly accessible. A sequence of operations asks us to repeatedly remove specific items in a given order.

codeforcescompetitive-programmingdata-structuresimplementation
CF 1278E - Tests for problem D

We are given a tree with n labeled vertices. The task is not to manipulate the tree directly, but to construct a completely different object: n line segments on the number line, using the integers from 1 to 2n exactly once as endpoints.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similardivide-and-conquertrees
CF 1277B - Make Them Odd

We are given several independent test cases. In each test case, we start with a list of positive integers. One operation lets us pick a value $c$, but only if it is even, and then we simultaneously replace every occurrence of $c$ in the array by $c/2$.

codeforcescompetitive-programminggreedynumber-theory
CF 1276C - Beautiful Rectangle

We are given a multiset of integers, and we are allowed to select some of them and arrange the selected elements into a rectangular grid. Every chosen element occupies exactly one cell, and the grid is completely filled with chosen values.

codeforcescompetitive-programmingbrute-forcecombinatoricsconstructive-algorithmsdata-structuresgreedymath
CF 1276A - As Simple as One and Two

We are given a string consisting of lowercase letters. Certain length-3 patterns are considered “bad”: specifically, the substrings "one" and "two". A string becomes unacceptable if any such bad triple appears anywhere inside it.

codeforcescompetitive-programmingdpgreedy
CF 1275A - Скрытый друг

We are given a directed friendship graph of $n$ users, where each user lists some other users as friends. The important detail is that friendship is not guaranteed to be mutual. If user $u$ lists $v$, it does not imply that $v$ lists $u$.

codeforcescompetitive-programming*special
CF 1275E2 - Контрольная сумма

We are working with a byte array, and a checksum function, CRC32, that compresses the entire array into a single 32-bit value.

codeforcescompetitive-programming*special
CF 1272B - Snow Walking Robot

We are given a sequence of moves for a robot on an infinite grid starting from the origin. Each character in the string tells the robot to move one step in one of the four cardinal directions.

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementation
CF 1271B - Blocks

We are given a line of blocks, each painted either black or white. The only allowed move is to pick two neighboring blocks and flip both of them at the same time, turning white into black and black into white.

codeforcescompetitive-programminggreedymath
CF 1270I - Xor on Figures

We are given a toroidal grid of size $2^k times 2^k$, where each cell contains a 60-bit integer. The grid wraps around both horizontally and vertically, so shifting beyond an edge brings us back to the opposite side.

codeforcescompetitive-programmingconstructive-algorithmsfftmath
CF 1270G - Subset with Zero Sum

We are given an array of integers where each position i has a value a[i] constrained in a tight interval that depends on its index. The i-th element is never too negative and never too large: it always lies between i − n and i − 1.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similargraphsmath
CF 1270H - Number of Components

The array defines a complete ordering between positions: for every pair of indices $i < j$, we draw a directed comparison that becomes an undirected edge if the value on the left is smaller than the value on the right.

codeforcescompetitive-programmingdata-structures
CF 1270B - Interesting Subarray

We are given several test cases, and each test case provides an array of integers. The task is to determine whether there exists a contiguous segment of this array whose spread is large enough compared to its length.

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 1270F - Awesome Substrings

We are given a binary string and asked to count how many of its contiguous substrings satisfy a very specific structural constraint. A substring is considered valid if it contains at least one 1, and if its total length is divisible by the number of 1s inside it.

codeforcescompetitive-programmingmathstrings
CF 1270E - Divide Points

We are given a collection of points on a plane, each with integer coordinates, and we must split them into two nonempty groups. After splitting, every pair of points produces a distance value, since we consider Euclidean distances between all pairs.

codeforcescompetitive-programmingconstructive-algorithmsgeometrymath