brain

tamnd's digital brain — notes, problems, research

41650 notes

CF 1032G - Chattering

We are given a circular arrangement of parrots, where each parrot has a numeric “influence radius” derived from its respect level. If a parrot at position i starts speaking at time 0, then at time 1 all parrots within distance ri to its left and right also start speaking.

codeforcescompetitive-programming
CF 1032E - The Unbearable Lightness of Weights

We are given a multiset of weights, each weight having an integer mass between 1 and 100, but the weights are indistinguishable to us. We do not know which physical item corresponds to which mass, only the full list of masses exists somewhere in our friend’s knowledge.

codeforcescompetitive-programmingdpmath
CF 1032F - Vasya and Maximum Matching

We are given a tree and we are allowed to remove any subset of its edges. After removals, the tree becomes a forest. On this resulting forest, we consider all possible matchings and focus on those that achieve maximum size.

codeforcescompetitive-programmingdptrees
CF 1032A - Kitchen Utensils

We are given the multiset of utensils that remained after a banquet and the number of guests who attended. Each guest received several identical “dishes”, and each dish came with a fixed set of utensils.

codeforcescompetitive-programming
CF 1032B - Personalized Cup

We are given a single string representing the winner’s handle, and we must print it as a rectangular grid. Each cell of the grid contains either a character from the string or an asterisk.

codeforcescompetitive-programming
CF 1032D - Barcelonian Distance

We are working in a city where movement is allowed only along two types of roads. The first type is the standard integer grid: you can travel freely along any vertical line x = k or horizontal line y = k, and the cost is simply Euclidean distance along those lines, which…

codeforcescompetitive-programminggeometryimplementation
CF 1033F - Boolean Computer

We are given a collection of up to 30,000 integers, each representable in at most 12 bits. Alongside this, we are given many “bitwise machines”, where each machine defines a transformation from two input numbers into one output number.

codeforcescompetitive-programmingbitmasksbrute-forcefftmath
CF 1033G - Chip Game

We are given several independent piles of chips. Each pile has a large initial size, and two players, Alice and Bob, first choose how many chips they will remove per move, denoted by a and b. After these choices, they play a turn-based game on all piles combined.

codeforcescompetitive-programminggames
CF 1033D - Divisors

We are given a collection of integers, each of which is known to be “almost prime structured” in the sense that its number of divisors is very small, between 3 and 5.

codeforcescompetitive-programminginteractivemathnumber-theory
CF 1033C - Permutation Game

We are given a permutation of values placed on a line of positions from 1 to n. A token starts on any chosen position, and two players alternate moving it.

codeforcescompetitive-programmingbrute-forcedpgames
CF 1033B - Square Difference

We start with a large square piece of cloth with side length $a$. From one corner, a smaller square of side $b$ is cut out. The remaining cloth is an L-shaped region whose area is simply the area of the big square minus the area of the removed square, so $a^2 - b^2$.

codeforcescompetitive-programmingmathnumber-theory
CF 1033A - King Escape

We are given a square chessboard with coordinates from 1 to n in both directions. A queen is fixed at one cell, and it attacks along rows, columns, and diagonals in the usual chess sense.

codeforcescompetitive-programmingdfs-and-similargraphsimplementation
CF 1034D - Intervals of Intervals

We are given a sequence of geometric intervals on the number line. Think of each interval as a segment of paint on an infinite ruler. Now instead of working with single intervals, we look at contiguous blocks of these intervals.

codeforcescompetitive-programmingbinary-searchdata-structurestwo-pointers
CF 1034E - Little C Loves 3 III

We are given two arrays indexed by bitmasks of length n, so each index represents a subset of an n-element universe encoded as a binary number from 0 to 2^n - 1.

codeforcescompetitive-programmingbitmasksdpmath
CF 1034C - Region Separation

Codeforces 1034C: Region Separation

codeforcescompetitive-programmingcombinatoricsdpnumber-theorytrees
CF 1034A - Enlarge GCD

We are given a list of positive integers and are allowed to delete some of them. After deletion, we look at the greatest common divisor of the remaining numbers.

codeforcescompetitive-programmingnumber-theory
CF 1034B - Little C Loves 3 II

We are given a very large rectangular grid where each cell can be identified by coordinates $(x, y)$. We repeatedly place two chess pieces at a time, but only if the Manhattan distance between the two chosen empty cells is exactly 3.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsflowsgraph-matchings
CF 1036E - Covered Points

We are given a collection of straight line segments drawn on the integer grid. Each segment connects two lattice points, but the segment itself may pass through many other lattice points depending on its slope.

codeforcescompetitive-programmingfftgeometrynumber-theory
CF 1036G - Sources and Sinks

We start with a directed acyclic graph. Some vertices have no incoming edges, these are called sources, and some have no outgoing edges, these are sinks. The graph is guaranteed to have the same number of sources and sinks, and this number is at most 20.

codeforcescompetitive-programmingbitmasksbrute-forcedfs-and-similar
CF 1036F - Relatively Prime Powers

We are looking at integers through the lens of their prime factorizations. Every number (x ge 2) can be uniquely written as a product of primes, and we focus on the exponents in that decomposition.

codeforcescompetitive-programmingcombinatoricsmathnumber-theory
CF 1036C - Classy Numbers

We are working with a notion of “sparse” numbers in base 10. A number is considered valid if, when you write it in decimal, at most three of its digits are non-zero.

codeforcescompetitive-programmingcombinatoricsdp
CF 1036A - Function Height

The figure is a broken line made from points at integer x-coordinates from 0 to 2n. Initially every point lies on the x-axis, so every y-coordinate is zero. The only way to modify the shape is to pick an odd-indexed point and increase its height by one unit per move.

codeforcescompetitive-programmingmath
CF 1037G - A Game on Strings

We are given a base string and then asked to answer many independent games played on substrings of it. Each game starts from a chosen segment of the string, and two players alternate turns.

codeforcescompetitive-programminggames
CF 1037H - Security

We are given a fixed base string s. Each query selects a contiguous segment s[l..r] and a comparison string x. From that segment, we consider every distinct substring, meaning every string formed by choosing a start i and end j with l ≤ i ≤ j ≤ r.

codeforcescompetitive-programmingdata-structuresstring-suffix-structures
CF 1037A - Packets

Codeforces 1037A: Packets

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 1037C - Equalize

We are given two binary strings of equal length. Think of them as two rows of switches, where each position is either on or off.

codeforcescompetitive-programmingdpgreedystrings
CF 1037D - Valid BFS?

We are given a tree with vertices labeled from 1 to n, and a proposed ordering of all vertices. The task is to decide whether this ordering could arise from running a breadth-first search starting at vertex 1, under some valid choice of adjacency ordering.

codeforcescompetitive-programmingdfs-and-similargraphsshortest-pathstrees
CF 1037B - Reach Median

We are given a list of integers and a target value s. The goal is not to make all elements equal to s, but only to ensure that after we sort the array, the middle element becomes exactly s. Since the length is odd, there is a single well-defined median position.

codeforcescompetitive-programminggreedy
CF 1038A - Equality

We are given a string made of uppercase letters, but only from the first $k$ letters of the alphabet. The task is not to rearrange or modify the string, but to select a subsequence of characters while preserving order.

codeforcescompetitive-programmingimplementationstrings
CF 1038F - Wrap Around

We are given a binary string s and a length n. We want to construct all binary strings t of length n. Each such t is treated as circular, meaning its end wraps back to its beginning.

codeforcescompetitive-programmingdpstrings
CF 1038E - Maximum Matching

Each block can be viewed as a weighted undirected edge between two colors, where each endpoint is one of two possible colors depending on orientation.

codeforcescompetitive-programmingbitmasksbrute-forcedfs-and-similardpgraphs
CF 1038D - Slime

We are given a line of slimes, each carrying an integer value, and we repeatedly perform an operation where one slime absorbs an adjacent slime. If a slime with value $x$ eats a neighbor with value $y$, that neighbor disappears and the eater’s value becomes $x - y$.

codeforcescompetitive-programmingdpgreedyimplementation
CF 1038B - Non-Coprime Partition

We are given the integers from 1 to n, and we must split them into two non-empty groups so that every number is used exactly once. After splitting, we compute the sum of numbers in each group and look at the greatest common divisor of these two sums.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1039E - Summer Oenothera Exhibition

We are given a sequence of photo intervals on a very large number line. Each photo covers a fixed window of length w, starting at position xi, so photo i covers [xi, xi + w - 1].

codeforcescompetitive-programmingdata-structures
CF 1039B - Subway Pursuit

We are dealing with a single moving target on a very large numbered line of stations from 1 to n. At any moment there is exactly one station where the train is located, but after every query the train is allowed to move up to k stations left or right, and this movement is…

codeforcescompetitive-programmingbinary-searchinteractiveprobabilities
CF 1039D - You Are Given a Tree

We are working with a tree where we want to select several simple paths, with a strict rule that no vertex can belong to more than one selected path.

codeforcescompetitive-programmingdata-structuresdptrees
CF 1039C - Network Safety

We are given a network of servers where each server has an integer label (an encryption key) in a fixed bit range. Some pairs of servers are connected, and a connection is considered safe only if the two endpoints currently hold different values.

codeforcescompetitive-programmingdfs-and-similardsugraphsmathsortings
CF 1039A - Timetable

We are given a fixed sequence of departure times from station A, strictly increasing, and for each bus we also know a constraint on how “late” it can possibly appear in the arrival order at station B.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresgreedymath
CF 1040A - Palindrome Dance

We are given a line of dancers, each occupying a fixed position. Every dancer must end up wearing either a white suit or a black suit, and some of these suits are already fixed while others are undecided.

codeforcescompetitive-programminggreedy
CF 1041E - Tree Reconstruction

We are given a multiset of information that originally came from a rooted structure, but the structure itself is hidden. There exists a tree on vertices numbered from 1 to n, and each vertex has a unique label equal to its number.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresgraphsgreedy
CF 1041C - Coffee Break

We are given a set of moments inside a working day when Monocarp is willing to drink coffee. Each moment is a specific minute inside a day that lasts from minute 1 to minute m.

codeforcescompetitive-programmingbinary-searchdata-structuresgreedytwo-pointers
CF 1041A - Heist

We are given a set of keyboard indices that survived a burglary. The key hidden structure is that before the theft, all keyboards formed one continuous block of integers, something like x, x+1, x+2, and so on up to some unknown length.

codeforcescompetitive-programminggreedyimplementationsortings
CF 1042E - Vasya and Magic Matrix

We are given a grid where every cell has a numeric value, and a chip starts at a specific cell. From its current position, the chip can only move to cells that have strictly smaller values than the current one.

codeforcescompetitive-programmingdpmathprobabilities
CF 1042C - Array Product

We are given an array of integers, and we repeatedly reduce it until only one value remains. Each reduction step either merges two positions by multiplying their values and storing the result into one of the positions, or removes a single element entirely, but that removal…

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 1042A - Benches

We are given several benches, each already occupied by some number of people. Then a group of new people arrives, and each of them must choose a bench and sit there.

codeforcescompetitive-programmingbinary-searchimplementation
CF 1043G - Speckled Band

We are given a long string and many queries, each asking about a substring. For each substring, we imagine splitting it into several consecutive pieces. Among those pieces, identical pieces are considered the same “band”.

codeforcescompetitive-programmingdata-structuresdivide-and-conquerhashingstring-suffix-structuresstrings
CF 1043D - Mysterious Crime

We are given several different observations of the same set of people, each observation being a full ordering of the same $n$ elements.

codeforcescompetitive-programmingbrute-forcecombinatoricsmathmeet-in-the-middletwo-pointers
CF 1043E - Train Hard, Win Easy

We are given a set of participants, each described by two numbers. These two numbers represent how much penalty a participant contributes depending on whether they solve the first task or the second task in a two-person training contest.

codeforcescompetitive-programmingconstructive-algorithmsgreedymathsortings
CF 1043F - Make It One

We are given a multiset of positive integers, and we are allowed to choose any subset of these numbers. For a chosen subset, we compute the greatest common divisor of all selected elements.

codeforcescompetitive-programmingbitmaskscombinatoricsdpmathnumber-theoryshortest-paths
CF 1043C - Smallest Word

We are given a binary string consisting only of characters a and b. We process its prefixes from left to right in a fixed order, meaning we first decide what to do with the prefix of length 1, then length 2, and so on until the full string.

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementation
CF 1043B - Lost Array

We are given a sequence of prefix values a[0], a[1], ..., a[n] where a[0] = 0. The sequence was originally generated from a hidden array x of length k, but that array is no longer available.

codeforcescompetitive-programmingimplementation
CF 1043A - Elections

Each student in the school is forced to distribute a fixed number of votes, denoted by $k$, between two candidates. For every student, we are given how many votes they intend to give to Elodreip.

codeforcescompetitive-programmingimplementationmath
CF 1044D - Deduction Queries

We are dealing with an extremely large conceptual array indexed from 0 up to $2^{30}-1$, but we never actually store its values.

codeforcescompetitive-programmingdata-structuresdsu
CF 1044F - DFS

We are working with a fixed tree on $n$ vertices.

codeforcescompetitive-programmingdata-structures
CF 1044A - The Tower is Going Home

We are given a huge grid, but movement is not about stepping cell by cell. Instead, a rook starts at the bottom-left corner and can teleport along an entire row or column, as long as nothing blocks its straight-line path. There are two kinds of obstacles.

codeforcescompetitive-programmingbinary-searchtwo-pointers
CF 1044E - Grid Sort

We are given a small grid, at most 20 by 20, containing a permutation of the numbers from 1 to nm. The goal is to transform this grid into sorted order when read row by row.

codeforcescompetitive-programmingimplementation
CF 1044B - Intersecting Subtrees

We are given a tree with n vertices, but there is a twist: there are two different labelings of the same underlying tree. In your view, the vertices are numbered from 1 to n and the edges are given in this numbering.

codeforcescompetitive-programmingdfs-and-similarinteractivetrees
CF 1044C - Optimal Polygon Perimeter

We are given a convex polygon with its vertices already listed in clockwise order. The geometry is fixed: we cannot move points, only choose subsets of vertices.

codeforcescompetitive-programmingdpgeometry
CF 1045J - Moonwalk challenge

The input describes a tree where each edge connects two craters and carries a single lowercase letter. If you walk between any two craters, there is exactly one simple path, and that path naturally produces a string formed by concatenating the edge labels along the way.

codeforcescompetitive-programmingdata-structuresstringstrees
CF 1045F - Shady Lady

We are given a fixed set of monomials in two variables, each monomial having the form $x^{ak}y^{bk}$, but with an unknown positive integer coefficient. Before the coefficients are chosen, Ani is allowed to remove at most one monomial.

codeforcescompetitive-programminggeometrymath
CF 1045G - AI robots

We are given a set of robots placed on a number line. Each robot sits at a coordinate and has a fixed symmetric visibility range around its position. Inside that range, it can potentially “see” other robots. However, visibility alone is not enough for interaction.

codeforcescompetitive-programmingdata-structures
CF 1045A - Last chance

We are given a collection of weapons and a line of ships, and we want to assign each destroyed ship to exactly one weapon. Each weapon has a limited way of interacting with ships, and the goal is to maximize how many ships get assigned and destroyed under those constraints.

codeforcescompetitive-programmingdata-structuresflowsgraph-matchingsgraphstrees
CF 1045C - Hyperspace Highways

We are given a connected undirected graph with up to one hundred thousand vertices and up to half a million edges. Each query asks for the shortest path length between two given vertices, measured in number of edges. A crucial extra constraint changes the structure of the graph.

codeforcescompetitive-programmingdfs-and-similargraphstrees
CF 2013B - Battle for Survive

We are given a group of fighters, each starting with a positive strength value. We repeatedly pick two still-alive fighters, and the one with the smaller index is always removed. The survivor’s strength is updated by subtracting the removed fighter’s strength from theirs.

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 2013C - Password Cracking

Codeforces 2013C: Password Cracking

codeforcescompetitive-programmingconstructive-algorithmsinteractivestrings
CF 1725J - Journey

We are given a weighted tree where each node represents a city and each edge represents a bidirectional road with a travel time. The traveler must design a walk that eventually visits every city at least once.

codeforcescompetitive-programmingdptrees
CF 1725I - Imitating the Key Tree

Working

codeforcescompetitive-programmingcombinatoricsdsutrees
CF 1725C - Circular Mirror

We are given a circle with lamps placed on its boundary in a fixed clockwise order. Between consecutive lamps we know the arc lengths, so the geometry of the circle is fully determined up to rotation.

codeforcescompetitive-programmingbinary-searchcombinatoricsgeometrymathtwo-pointers
CF 1725F - Field Photography

Each row initially contains a contiguous block of contestants placed on an extremely large integer line of columns. Row $i$ occupies every position from $Li$ to $Ri$, so geometrically each row is just a closed interval.

codeforcescompetitive-programmingbitmasksdata-structuressortings
CF 1561D1 - Up the Strip (simplified version)

We are standing on a vertical strip of numbered cells from 1 at the top down to n at the bottom. A token starts at cell n, and we repeatedly move it upward until it reaches cell 1.

codeforcescompetitive-programmingbrute-forcedata-structuresdpmathnumber-theory
CF 1560C - Infinity Table

We are given a rule that fills an infinite grid with positive integers starting from 1. The placement does not proceed row by row or column by column in a simple linear fashion.

codeforcescompetitive-programmingimplementationmath
CF 1560F2 - Nearest Beautiful Number (hard version)

We are asked to construct, for each query, the smallest integer that is at least a given number n, under a digit-restriction constraint. The constraint is that the resulting number may use at most k distinct decimal digits in its representation, with no leading zeros allowed.

codeforcescompetitive-programmingbitmasksbrute-forceconstructive-algorithmsdfs-and-similardpgreedy
CF 1560B - Who's Opposite?

We are given three distinct labels that refer to people placed on a perfectly even circle. The circle size is even, but unknown, and the labels are not guaranteed to be consecutive or small.

codeforcescompetitive-programmingmath
CF 1559B - Mocha and Red and Blue

We are given a line of positions, each position holding a tile that must end up colored either red or blue. Some tiles are already fixed, while others are blank and can be assigned either color.

codeforcescompetitive-programmingdpgreedy
CF 1559C - Mocha and Hiking

Codeforces 1559C: Mocha and Hiking

codeforcescompetitive-programmingconstructive-algorithmsgraphs
CF 1559D2 - Mocha and Diana (Hard Version)

We are given two different forests built on the same set of vertices from 1 to n. Each forest is already acyclic, but they may have multiple connected components.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdfs-and-similardsugraphsgreedytreestwo-pointers
CF 1558F - Strange Sort

We are given a permutation that is repeatedly processed by a very specific “two-phase bubble-like” routine. In each iteration, we do not scan all adjacent pairs; instead we alternate between touching only odd edges and only even edges.

codeforcescompetitive-programmingdata-structuressortings
CF 1558A - Charmed by the Game

We are given only the final match statistics of a tennis game: Alice has won a individual games and Borys has won b individual games. We do not know the order of these games, and we also do not know who served first. What we do know is that service alternates strictly every game.

codeforcescompetitive-programmingbrute-forcemath
CF 1558C - Bottom-Tier Reversals

We are given a permutation of length $n$, where $n$ is always odd. The only operation allowed is to take a prefix of odd length and reverse it. Each operation affects only the first $p$ elements, flipping their order, while the rest of the array remains untouched.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1557A - Ezzat and Two Subsequences

We are given an array of integers, and we must split it into two non-empty groups while preserving every element exactly once. Each group has a score equal to its arithmetic mean, and the goal is to maximize the sum of these two means.

codeforcescompetitive-programmingbrute-forcemathsortings
CF 1557B - Moamen and k-subarrays

We are given an array of distinct integers and allowed to perform a very specific transformation exactly once. First, we cut the array into exactly k contiguous pieces, each piece non-empty.

codeforcescompetitive-programminggreedysortings
CF 1554C - Mikasa

We are given a fixed integer n and a range of integers 0, 1, 2, ..., m. Each number in this range is XORed with n, producing a set of values. From this resulting set, we want the smallest non-negative integer that does not appear.

codeforcescompetitive-programmingbinary-searchbitmasksgreedyimplementation
CF 1554D - Diane

We are asked to construct a string of length n using lowercase English letters such that a very strong parity condition holds: every non-empty substring must appear inside the string an odd number of times when we count all occurrences.

codeforcescompetitive-programmingconstructive-algorithmsgreedystrings
CF 1553G - Common Divisor Graph

We are given a fixed set of nodes, each labeled by a distinct integer. Two nodes are connected if their labels share any prime factor. This means the graph is determined entirely by the prime factorizations of the given numbers. For each query, we are given two starting nodes.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdsugraphshashingmathnumber-theory
CF 1553F - Pairwise Modulo

We are given a sequence of distinct positive integers. After reading the first k elements, we define a score pk that aggregates the remainder produced by dividing every ordered pair (ai, aj) among the first k elements.

codeforcescompetitive-programmingdata-structuresmath
CF 1553D - Backspace

We are simulating a typing process where we scan a source string s from left to right. At each position, we either append the current character to an evolving text buffer or press backspace, which deletes the most recently added character if it exists.

codeforcescompetitive-programmingdpgreedystringstwo-pointers
CF 1553E - Permutation Shift

We start from the identity permutation, which is simply the numbers from 1 to n in order. Someone first rotates this array cyclically to the right by an unknown shift k, and then performs at most m arbitrary swaps of elements.

codeforcescompetitive-programmingbrute-forcecombinatoricsconstructive-algorithmsdfs-and-similardsugraphsmath
CF 1552H - Guess the Perimeter

We are dealing with a hidden axis-aligned rectangle whose corners lie on integer grid points inside a fixed 200 by 200 grid.

codeforcescompetitive-programmingbinary-searchinteractivenumber-theory
CF 1552C - Maximize the Intersections

We are given points placed around a circle in clockwise order. Some of these points are already connected by chords, and these initial chords never share endpoints.

codeforcescompetitive-programmingcombinatoricsconstructive-algorithmsgeometrygreedysortings
CF 1552E - Colors and Intervals

We are given a long line of positions from 1 to n·k, each position painted with one of n colors, and each color appears exactly k times. For every color i we must choose exactly one interval [ai, bi] such that both endpoints belong to positions colored i.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresgreedysortings
CF 1551D1 - Domino (easy version)

We are given a rectangular board with $n$ rows and $m$ columns, containing $n cdot m$ unit cells. Since this product is even, the board can be fully tiled by dominoes, where each domino always covers exactly two adjacent cells sharing a side.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1551B1 - Wonderful Coloring - 1

We are given a string made of lowercase Latin letters. We want to select some of its positions and assign each selected position one of two colors, red or green, with three rules. First, every chosen position gets exactly one color, while some positions may remain unpainted.

codeforcescompetitive-programminggreedystrings
CF 1543A - Exciting Bets

We are given two non-negative integers, and we can move them in lockstep: every operation changes both values by exactly the same amount, either increasing both by one or decreasing both by one (as long as we do not go below zero).

codeforcescompetitive-programminggreedymathnumber-theory
CF 1543D1 - RPD and Rap Sheet (Easy Version)

We are playing an interactive game with a hidden number that always stays in the range from 0 to n − 1. We repeatedly submit guesses. If a guess is correct, the interaction ends immediately.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsinteractivemath
CF 1542D - Priority Queue

We are given a sequence of operations that can either insert a value into a multiset or delete the smallest value currently present.

codeforcescompetitive-programmingcombinatoricsdpimplementationmathternary-search
CF 1542A - Odd Set

We are given a collection of numbers with even size, specifically 2n integers per test case. The task is to decide whether it is possible to partition these numbers into n disjoint pairs such that every pair consists of two numbers whose sum is odd.

codeforcescompetitive-programmingmath
CF 1538D - Another Problem About Dividing Numbers

We start with two numbers, and we are allowed to repeatedly “divide” either of them by some integer greater than one, as long as it divides cleanly.

codeforcescompetitive-programmingconstructive-algorithmsmathnumber-theory
CF 1538E - Funny Substrings

We are given a very small “programming language” where variables store strings. Each variable is either assigned a literal string of length at most five, or defined as the concatenation of two previously defined variables.

codeforcescompetitive-programmingdata-structureshashingimplementationmatricesstrings
CF 1391D - 505

We are given a binary grid and we are allowed to flip cells from 0 to 1 or 1 to 0. The goal is to transform the grid so that every square submatrix whose side length is even contains an odd number of ones.

codeforcescompetitive-programmingbitmasksbrute-forceconstructive-algorithmsdpgreedyimplementation
CF 1391A - Suborrays

We are asked to construct a permutation of the numbers from 1 to n such that every contiguous segment behaves in a very specific way under the bitwise OR operation. For any subarray, we take all values inside it and compute their bitwise OR.

codeforcescompetitive-programmingconstructive-algorithmsmath