brain

tamnd's digital brain — notes, problems, research

41650 notes

CF 106310A - Строитель Боб

This is an output-only constructive task where the real problem is not computing a number from input, but deriving a closed-form expression for a very specific geometric object. We are given a 3D structure that can be thought of as a tunnel built out of unit cubes.

codeforcescompetitive-programming
CF 106315A - Delete, Deduct, and Destroy

We are working with a decimal string that is repeatedly modified by single-digit updates. After each modification, we need to evaluate a function defined over all ways of deleting a digit from a number and measuring how much the value changes.

codeforcescompetitive-programming
CF 106315H - Chemical Reaction

We start with a set of chemical types already present in a chamber. Each second, any pair of chemicals that has a known reaction rule can produce a new chemical type.

codeforcescompetitive-programming
CF 106315E - The Perfect View

We are given several candidate cafe locations and several landmark points in the plane. For each fixed cafe location $Ci$, we consider every pair of distinct landmarks $Lj, Lk$. Each such pair together with the cafe forms a triangle $CiLjLk$.

codeforcescompetitive-programming
CF 106315C - Least Compatible Ancestor

We are given a rooted tree with nodes labeled from 1 to n, where node 1 is the root. Each node u must be assigned a value au in the range [1, n]. The assignment is considered valid if it avoids a specific global consistency condition across all pairs of nodes.

codeforcescompetitive-programming
CF 106318D - Seating Arrangement

The problem statement for “Codeforces 106318D - Seating Arrangement” is missing from your prompt, so I don’t have the actual rules, input format, or what needs to be computed.

codeforcescompetitive-programming
CF 106318C - Basketball Tournament

I can’t write a correct editorial yet because the problem statement for Codeforces 106318C - Basketball Tournament is not included, and it’s not reliably retrievable from the context provided.

codeforcescompetitive-programming
CF 106328K - One Line

We are working on a grid of integer coordinates, where both x and y must lie between 1 and n inclusive. The task is to construct a fairly large set of points inside this n by n grid while satisfying a geometric constraint: no three chosen points are allowed to lie on the same…

codeforcescompetitive-programming
CF 106328F - Random Walk

We start at the origin of an infinite grid and perform a random walk of exactly $n$ steps. At every step, we move uniformly to one of the four neighboring cells.

codeforcescompetitive-programming
CF 106328B - Odd Cycle

We are given a directed graph and asked, for every vertex, whether it belongs to at least one directed cycle whose length is odd.

codeforcescompetitive-programming
CF 106507G - Xor Tree

We are given a collection of integer-labeled vertices, and every pair of vertices has an implicit connection cost defined by the bitwise XOR of their values.

codeforcescompetitive-programming
CF 106507F - Turtles

We are given a rectangular grid with 2 rows and $n$ columns, and a multiset of $2n$ numbers representing the values of the cells. We are allowed to permute these values arbitrarily across the grid.

codeforcescompetitive-programming
CF 106507A - Digits

The task defines a simple numeric transformation on integers. For any integer $y$, consider the sum of its digits, denoted $d(y)$. A number $y$ is considered compatible with a given integer $x$ if subtracting the digit sum from $y$ yields exactly $x$, meaning $y - d(y) = x$.

codeforcescompetitive-programming
CF 106508J - GCD and LCM Subsequences

We are given a sequence of integers and we are asked to consider all its non-empty subsequences. For each subsequence, we compute two values: the greatest common divisor of all elements in it and the least common multiple of all elements in it.

codeforcescompetitive-programming
CF 106508L - Matrix Construction

I cannot safely reconstruct the exact statement of “Codeforces 106508L - Matrix Construction” from the information available here.

codeforcescompetitive-programming
CF 106508K - Choose

I can’t reliably reconstruct Codeforces 106508K - Choose from the title alone, and I don’t have the actual problem statement in the context you provided.

codeforcescompetitive-programming
CF 106508I - Parallel Pipeline Scheduling

I don’t have the exact Codeforces statement text for 106508I - Parallel Pipeline Scheduling available from the sources I can reliably retrieve, so I can’t truthfully reconstruct its precise constraints or intended model without risking inventing details.

codeforcescompetitive-programming
CF 106508H - Substring Game

We are given a game built on a single string of lowercase letters. Two players, Alice and Bob, take turns modifying the string until it becomes empty.

codeforcescompetitive-programming
CF 106508E - Phantoms of the XOR Tree

Got it. Please send the full problem statement (or link/text, constraints, and any samples). Once I have that, I’ll write a proper Codeforces-style editorial with: - Intuition / key observation - Step-by-step solution - Correctness argument - Complexity analysis - Edge cases…

codeforcescompetitive-programming
CF 106508G - Delete or not

We are given a sequence of distinct values that is already sorted in increasing order. From any contiguous segment of this sequence, we are allowed to repeatedly remove elements as long as they satisfy a local convexity condition: an interior element can be deleted if it is…

codeforcescompetitive-programming
CF 106508F - PigeonG's Encoded Sequences

We are given a binary string, and we imagine splitting it into several contiguous pieces. Each piece is interpreted as a binary number using the usual left-to-right significance, meaning the leftmost character in the piece contributes the highest power of two.

codeforcescompetitive-programming
CF 106508C - Leyline Resonance

We are given a rooted tree where every node already has a real-valued “desired level” written on it. We are allowed to assign a new real value to every node, and this assignment is what we are optimizing. Two kinds of costs interact.

codeforcescompetitive-programming
CF 106508D - SCUT Classroom Relocation

I can’t reliably write a correct editorial yet because the problem statement for Codeforces 106508D - SCUT Classroom Relocation is not available in the context, and it does not appear in the retrieved sources.

codeforcescompetitive-programming
CF 106508A - Basic Matrix Recurrence Practice

I can’t reliably write a correct editorial for this without the actual problem statement. “Codeforces 106508A - Basic Matrix Recurrence Practice” isn’t included in your prompt, and the sections (input/output/problem description) are empty.

codeforcescompetitive-programming
CF 106508B - The Light Boat Has Passed Ten Thousand Mountains

I can’t write a correct editorial for this yet because the actual problem statement for Codeforces 106508B - “The Light Boat Has Passed Ten Thousand Mountains” isn’t included, and I don’t have enough reliable information about what the task is to reconstruct it safely.

codeforcescompetitive-programming
CF 106511L - Maximize the Area

We are given a set of points on a plane and we are allowed to choose either three or four of them. The chosen points must form a simple polygon, meaning edges cannot cross, and we want the shape that maximizes the enclosed area.

codeforcescompetitive-programming
CF 106511M - Task For Benq

I don’t have the problem statement for Codeforces 106511M - Task For Benq, and without it I can’t responsibly write a correct editorial. The solution structure, key observation, and even the intended difficulty can vary completely between problems with similar names.

codeforcescompetitive-programming
CF 106511K - Some 3-SUMs

We are given a sequence of integers and asked to count how many distinct triples of positions produce a fixed target sum condition, which in this problem is the classic “3-sum” condition: three different elements chosen by indices must add up to zero.

codeforcescompetitive-programming
CF 106511H - Bichromatic Cycles

We are given a graph whose vertices are each painted one of two colors. Edges connect pairs of vertices, and the graph is undirected.

codeforcescompetitive-programming
CF 106511J - Permutation Game

I can’t write a correct editorial yet because the actual problem statement for Codeforces 106511J - Permutation Game isn’t included in your message.

codeforcescompetitive-programming
CF 106511I - Ant Colony Expansion

I can’t write a correct editorial for Codeforces 106511I - Ant Colony Expansion without the actual problem statement.

codeforcescompetitive-programming
CF 106511G - Median Solve Order

I can’t responsibly write a full editorial yet because the actual statement of Codeforces 106511G - Median Solve Order is not included in your prompt, and it does not appear in the accessible context.

codeforcescompetitive-programming
CF 106511E - Mingle

We are given an array of values that changes over time, and we need to answer queries about subarrays. Each query picks a segment of the array and a number of initial players, then asks what is the maximum number of players that can survive a multi-round process.

codeforcescompetitive-programming
CF 106511F - Manhattan Patrol

We are given an $n times m$ grid, and every cell initially contains a distinct officer, so there are exactly $n cdot m$ officers total. We then rearrange these officers onto the same set of grid positions, so the final configuration is a permutation of the original assignment.

codeforcescompetitive-programming
CF 106511D - House Numbers

We are given an upper bound $n$. There are houses numbered from 1 to $n$, but we do not know which house we will end up owning.

codeforcescompetitive-programming
CF 106511C - LCM Queries

We are given a sequence of integers and a set of queries. Each query asks for the least common multiple of all numbers inside a contiguous segment of the array. The task is to answer each query independently and output the resulting value for that segment.

codeforcescompetitive-programming
CF 106511B - Six Seven

We are given several test cases, and each test case is a string made only of the characters 6 and 7. The task is to count how many pairs of positions we can pick such that the first position contains a 6, the second position contains a 7, and the 7 appears strictly to the…

codeforcescompetitive-programming
CF 106511A - Favorite Phrase

I can absolutely write this editorial in the exact style you want, but I’m missing the actual problem statement for Codeforces 106511A - Favorite Phrase.

codeforcescompetitive-programming
CF 106513D - Highway

We are given a set of cities connected by potential highways, each highway having a fixed construction cost. These roads already form a connected undirected graph, so we know that a spanning tree always exists using some subset of these edges.

codeforcescompetitive-programming
CF 106513E - Largest Sorted Partitions

We are given an array of integers and we want to split it into consecutive chunks by choosing a fixed block size k. Starting from the left, each chunk takes exactly k elements, except possibly the last chunk which may be shorter if the array length is not divisible by k.

codeforcescompetitive-programming
CF 106513A - Big Back

Please send either: - the full problem statement, or - a screenshot, or - the input/output description plus constraints. Even a partial statement is enough. A Codeforces A-problem can be anything from a simple greedy to a small constructive trick.

codeforcescompetitive-programming
CF 106513C - Sprinkler Piping

I can’t reliably write a correct Codeforces-style editorial for “106513C - Sprinkler Piping” because the actual problem statement (input/output definition and constraints) isn’t included in your prompt, and I don’t have a trustworthy way to reconstruct it.

codeforcescompetitive-programming
CF 106513B - Support Beam

I can write the full Codeforces-style editorial, but I’m missing the actual problem statement for 106513B - Support Beam. Right now the prompt only includes headers, so I don’t know what the input represents, what needs to be computed, or what constraints drive the solution.

codeforcescompetitive-programming
CF 106516E - Planar Exact Cover

We are given a planar graph that comes from a very structured combinatorial construction. Each vertex is constrained to behave in one of two ways. One type of vertex behaves like a “one-in” node: among all incident edges, exactly one edge must be oriented inward.

codeforcescompetitive-programming
CF 106516D - Sell in Pairs

We are given a sequence of counts indexed by position, where each position represents how many identical items of a certain “type” we have. The task is to repeatedly remove items in pairs, where each pair can either come from two adjacent positions or from the same position.

codeforcescompetitive-programming
CF 106516A - Edit Distance Parity

We are given two sequences, one of length n and another of length m. The exact symbols in these sequences are unknown, but we are given enough information about how similar their prefixes are under the classic edit distance definition. The edit distance between prefixes a[1..

codeforcescompetitive-programming
CF 106516B - Fruit Blast

We are given a long sequence whose length is $N^2$, and every value from $1$ to $N$ appears exactly $N$ times. The sequence is meant to be interpreted as a timeline of actions involving $N$ labeled tokens arranged in a cyclic structure.

codeforcescompetitive-programming
CF 106516C - Tree Partition

We are given a tree, and we are asked to count how many ways we can decompose its vertex set into disjoint simple paths such that every path has length that is a power of two when measured in number of vertices.

codeforcescompetitive-programming
CF 1725E - Electrical Efficiency

We are given a tree of $N$ factories. Each factory has an integer value, and the factories are connected by power lines so that electricity can travel between any two factories along unique paths in the tree.

codeforcescompetitive-programmingcombinatoricsdata-structuresdpmathnumber-theorytrees
CF 1725G - Garage

We are asked to generate an infinite increasing sequence of positive integers called “suitable” numbers. A number is suitable if it can be realized as the area of a square that appears in a specific geometric construction involving a right triangle attached to it, where…

codeforcescompetitive-programmingbinary-searchgeometrymath
CF 1559D1 - Mocha and Diana (Easy Version)

We are given two forests on the same set of labeled nodes from 1 to n. Each forest is just a collection of edges that never forms a cycle, though each forest can be disconnected and consist of multiple trees.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdsugraphsgreedytrees
CF 1559E - Mocha and Stars

We are counting how many ways we can assign an integer brightness value to each of $n$ stars. Each star has its own allowed interval, so the value of the $i$-th star must lie between $li$ and $ri$.

codeforcescompetitive-programmingcombinatoricsdpfftmathnumber-theory
CF 1558E - Down Below

We are given a graph of caves connected by tunnels, and a hero who starts at cave 1 with some initial power. Every other cave initially contains a monster. The hero’s task is to visit and defeat the monster in every cave at least once.

codeforcescompetitive-programmingbinary-searchdfs-and-similargraphsgreedymeet-in-the-middleshortest-paths
CF 1558D - Top-Notch Insertions

We are looking at a process that behaves like insertion sort, but instead of only caring about the final sorted array, we care about the exact sequence of “real insertions” it performs while sorting.

codeforcescompetitive-programmingcombinatoricsdata-structures
CF 1557D - Ezzat and Grid

We are given a very wide grid with a small number of rows. Each row is not stored explicitly as a full binary string. Instead, it is described by several disjoint or overlapping segments, and every segment marks a continuous interval of columns where the value is 1.

codeforcescompetitive-programmingdata-structuresdpgreedy
CF 1557E - Assiut Chess

We are playing an interactive game on an 8 by 8 chessboard. There is a queen that we control and a king controlled by the judge. The king starts at an unknown cell different from our queen’s starting cell.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsinteractive
CF 1553B - Reverse String

We are given a string that represents a line of characters. A chip starts on some chosen position in this string. After placing it, we repeatedly move it and each time we record the character at the chip’s current position.

codeforcescompetitive-programmingbrute-forcedphashingimplementationstrings
CF 1552D - Array Differentiation

We are given a list of integers, and we want to decide whether it is possible to assign another list of the same length, say $b1, b2, dots, bn$, such that every given number $ai$ can be expressed as a difference between two values in $b$.

codeforcescompetitive-programmingbitmasksbrute-forceconstructive-algorithmsdfs-and-similardpgraphsmath
CF 1552I - Organizing a Music Festival

We are asked to count how many permutations of singers are valid under a set of “group contiguity” constraints. Each singer is a distinct element from $1$ to $n$. We must arrange all of them in a line.

codeforcescompetitive-programmingdfs-and-similarmath
CF 1551E - Fixed Points

We are given an array of integers, and we are allowed to repeatedly remove elements from it. Every removal compresses the array so that indices always stay contiguous.

codeforcescompetitive-programmingbinary-searchbrute-forcedp
CF 1543D2 - RPD and Rap Sheet (Hard Version)

We are interacting with a hidden number that changes whenever we make a wrong guess. We know the number always stays within the range from 0 to n − 1, and we are allowed to ask up to n queries to discover it. Each query is a number y.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsinteractivemath
CF 1542E1 - Abnormal Permutation Pairs (easy version)

We are asked to count ordered pairs of permutations of size n. For each pair (p, q), we require two conditions at the same time: in lexicographic order p comes before q, and the inversion count of p is strictly larger than that of q.

codeforcescompetitive-programmingcombinatoricsdpfftmath
CF 1391B - Fix You

The grid describes a deterministic system where every cell contains exactly one outgoing instruction: either it sends any item to the right or it sends it downward.

codeforcescompetitive-programmingbrute-forcegreedyimplementation
CF 1389E - Calendar Ambiguity

We are given a fictional calendar system where time is structured in three layers. A year has m months, every month contains exactly d days, and the week repeats every w days.

codeforcescompetitive-programmingmathnumber-theory
CF 1389G - Directing Edges

We are given an undirected connected graph where each edge can be turned into a one-way edge of our choosing or kept as a two-way edge. Keeping it two-way is expensive, since every such edge contributes its weight to the cost.

codeforcescompetitive-programmingdfs-and-similardpgraphstrees
CF 1388E - Uncle Bogdan and Projections

We are given several horizontal line segments placed above the x-axis. Each segment has a fixed height and a horizontal interval with integer endpoints. The segments do not intersect each other in the plane, but they may lie at different heights and overlap in x-projection.

codeforcescompetitive-programmingdata-structuresgeometrysortings
CF 1387C - Viruses

We are given a system where each “gene” is an integer label, and every gene greater than 1 can expand into a sequence of genes according to a fixed mutation rule.

codeforcescompetitive-programming*specialdpshortest-pathsstring-suffix-structures
CF 1385E - Directing Edges

We are given a graph where every edge already knows its endpoints, but not all edges are allowed to choose their direction freely. Some edges are already directed and must stay exactly as they are, while the remaining edges are undirected and can be oriented however we want.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similargraphs
CF 1385G - Columns Swaps

We are given a two-row table with $n$ columns, and every cell contains a number between $1$ and $n$. In each column we are allowed to either leave the two values as they are or swap them, and each column can be swapped at most once.

codeforcescompetitive-programming2-satdfs-and-similardsugraphsimplementation
CF 1375D - Replace by MEX

We are given several arrays, each containing integers in the range from zero up to the array length. We are allowed to repeatedly pick a position in the array and overwrite its value with the current MEX of the entire array.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmssortings
CF 1367E - Necklace Assembly

We are given a multiset of colored beads, where each bead is just a lowercase letter. From these beads, we want to choose some subset and arrange it in a circle, forming a necklace. The arrangement is circular, so rotations matter but there is no fixed starting point.

codeforcescompetitive-programmingbrute-forcedfs-and-similardpgraphsgreedynumber-theory
CF 1360F - Spy-string

We are given several strings of equal length, and we want to construct a new string of the same length. The requirement is that this constructed string must be extremely close to every given string: for each input string, it is allowed to differ from our constructed string in…

codeforcescompetitive-programmingbitmasksbrute-forceconstructive-algorithmsdphashingstrings
CF 1346E - Magic Tricks

We start with a row of positions from 1 to n, and a special ball initially placed at position k. Then a sequence of m swap operations is given, where each operation swaps the contents of two positions.

codeforcescompetitive-programming*specialdpgraphs
CF 1307F - Cow and Vacation

We are working on a tree of cities connected by roads, where every pair of cities is reachable through a unique simple path. Some of these cities contain rest stops.

codeforcescompetitive-programmingdfs-and-similardsutrees
CF 1305G - Kuroni and Antihype

We are given a group of people, each with an associated integer value that can be interpreted as a bitmask. These people can form a network by joining a system where actions produce profit: once someone has joined, they can “invite” a person who has not joined yet, and each…

codeforcescompetitive-programmingbitmasksbrute-forcedpdsugraphs
CF 1268E - Happy Cactus

We are given a connected undirected cactus graph where every edge has a unique label from 1 to m. These labels define a strict global ordering of edges.

codeforcescompetitive-programmingdp
CF 1267K - Key Storage

A key is transformed into a sequence by repeatedly dividing it by growing divisors starting from 2. At each step with divisor $i$, we record the remainder of dividing the current number by $i$, then replace the number by the quotient.

codeforcescompetitive-programmingcombinatoricsmath
CF 1267I - Intriguing Selection

We are given a hidden set of $2n$ distinct values, one per player, and we can only compare two players at a time and learn which one is stronger. The goal is not to fully reconstruct the ranking, but to identify exactly which $n$ players belong to the globally strongest half.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsimplementationinteractivesortings
CF 1267L - Lexicography

We are given a multiset of letters whose total size is exactly enough to form $n$ strings, each of fixed length $l$.

codeforcescompetitive-programmingconstructive-algorithmsstrings
CF 1267H - Help BerLine

We are given a line of $n$ positions, each representing a base station placed from left to right. Each station must be assigned a frequency between 1 and 24.

codeforcescompetitive-programmingconstructive-algorithms
CF 1267D - DevOps Best Practices

Each server stores two independent kinds of information. First, for each of the three features, we know whether the company wants that feature to be installed on that server.

codeforcescompetitive-programmingconstructive-algorithms
CF 1267G - Game Relics

We are given a collection of $n$ distinct items called relics. Each relic $i$ can be obtained in two ways: either by directly purchasing it at a fixed cost $ci$, or by paying a fixed cost $x$ to receive a uniformly random relic among all $n$, where duplicates do not help…

codeforcescompetitive-programmingmathprobabilities
CF 1267E - Elections

We are given a voting system with multiple candidates and multiple polling stations. Each station reports how many votes each candidate received. The final score of a candidate is the sum of their votes across all stations that remain valid.

codeforcescompetitive-programminggreedy
CF 1267C - Cactus Revenge

I can absolutely write a full 3500-level editorial in the exact style you want, but I can’t do it correctly from just the name “Codeforces 1267C - Cactus Revenge” without the actual problem statement.

codeforcescompetitive-programmingconstructive-algorithms
CF 1266G - Permutation Concatenation

We are given a fixed integer $n$. From it, we build a very long sequence by listing every permutation of numbers from $1$ to $n$ in lexicographic order and concatenating them one after another.

codeforcescompetitive-programmingstring-suffix-structures
CF 1266E - Spaceship Solitaire

We are trying to satisfy a set of resource requirements. Each resource type starts at zero, and we must reach at least a given target amount for every type. The only basic action is producing one unit of any chosen resource, which costs exactly one turn.

codeforcescompetitive-programmingdata-structuresgreedyimplementation
CF 1266F - Almost Same Distance

We are given a tree, and for every possible distance value $k$, we want to know how large a subset of vertices we can pick such that every pair of chosen vertices is “almost equidistant” in a very strict sense: if you pick any two vertices in the subset, their distance in…

codeforcescompetitive-programmingdfs-and-similargraphs
CF 1266C - Diverse Matrix

We are asked to fill an $r times c$ grid with positive integers so that a specific derived sequence of values becomes all distinct, while also making the largest of those values as small as possible. From each row we compute a single number: the gcd of all elements in that row.

codeforcescompetitive-programmingconstructive-algorithmsgreedymathnumber-theory
CF 1264C - Beautiful Mirrors with queries

Each mirror acts like a probabilistic “step” in a process that either advances forward or forces a restart. Creatnx begins at mirror 1 and repeatedly asks mirrors in increasing index order. When mirror i responds positively, the process moves to i + 1 on the next day.

codeforcescompetitive-programmingdata-structuresprobabilities
CF 1264D2 - Beautiful Bracket Sequence (hard version)

We are given a string made of three types of characters: left brackets, right brackets, and question marks. Each question mark can independently become either type of bracket, so the input describes a large family of fully specified bracket strings.

codeforcescompetitive-programmingcombinatoricsprobabilities
CF 1264A - Beautiful Regional Contest

We are given a non-increasing array of scores representing contest results. Our task is to split the top portion of this ranking into three contiguous groups: gold, silver, and bronze. Everyone after the bronze group receives no medal.

codeforcescompetitive-programminggreedyimplementation
CF 1264D1 - Beautiful Bracket Sequence (easy version)

We are given a string of length up to 2000, consisting of three kinds of characters: opening brackets, closing brackets, and wildcards.

codeforcescompetitive-programmingcombinatoricsdpprobabilities
CF 1263C - Everyone is a Winner!

We are given a fixed amount of rating points, call it $n$. A draw splits these points equally among $k$ participants, but only whole units are distributed, so each participant receives $lfloor n / k rfloor$ points. Any leftover points are discarded.

codeforcescompetitive-programmingbinary-searchmathmeet-in-the-middlenumber-theory
CF 1263B - PIN Codes

We are given several bank cards, each associated with a 4-digit PIN code. The task is to modify these PINs so that no two cards share the same final code, while performing as few single-digit changes as possible.

codeforcescompetitive-programminggreedyimplementation
CF 1260E - Tournament

We are given a knockout tournament with $n$ participants, where $n$ is a power of two. Each participant has a fixed strength, and in any direct match the stronger boxer always wins unless we have paid a bribe for the weaker one, in which case the weaker boxer is allowed to win…

codeforcescompetitive-programmingbrute-forcedpgreedy
CF 1256B - Minimize the Permutation

We are given several test cases, each consisting of a permutation, meaning an array containing every integer from 1 to n exactly once. The only allowed operation is a swap between adjacent positions i and i+1, and each such swap can be used at most once.

codeforcescompetitive-programminggreedy
CF 1256F - Equalizing Two Strings

We are given two strings of equal length, and we are allowed to repeatedly perform a synchronized operation: pick a length len, choose any substring of that length in the first string, reverse it, and independently choose any substring of the same length in the second string…

codeforcescompetitive-programmingconstructive-algorithmssortingsstrings
CF 1254D - Tree Queries

We are given a tree with values stored on vertices, initially all zero. The system processes two kinds of operations. One operation injects a value d into a region of the tree that depends on a randomly chosen root vertex r.

codeforcescompetitive-programmingdata-structuresprobabilitiestrees
CF 1254C - Point Ordering

We are given a hidden set of points in the plane, each point identified only by an index from 1 to n. We cannot see coordinates, but we can ask geometric queries involving any three distinct indices.

codeforcescompetitive-programmingconstructive-algorithmsgeometryinteractivemath
CF 1254A - Feeding Chicken

We are given a rectangular grid where each cell is either empty or contains rice. We also have $k$ chickens. The task is to partition the entire grid into exactly $k$ connected regions, one per chicken, so that every cell belongs to exactly one region and every region is…

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementation