brain

tamnd's digital brain — notes, problems, research

41650 notes

CF 1092D1 - Great Vova Wall (Version 1)

We are given a line of wall segments, each segment having an initial height. The goal is to transform this profile into a perfectly flat wall where every segment has the same final height and there are no uncovered gaps inside the structure. Two operations are allowed.

codeforcescompetitive-programminggreedyimplementationmath
CF 1092D2 - Great Vova Wall (Version 2)

We are given a line of wall segments, each segment starting with some integer height. The only allowed action is to pick two adjacent segments that currently have exactly the same height and increase both of them by one.

codeforcescompetitive-programmingdata-structuresimplementation
CF 1092C - Prefixes and Suffixes

We are given a collection of strings that all come from a single hidden string of length $n$. From that hidden string, every proper prefix and every proper suffix was taken, so for each length from $1$ to $n-1$ there are exactly two strings: one prefix and one suffix, but they…

codeforcescompetitive-programmingstrings
CF 1092B - Teams Forming

We are given an array of integers representing the skill levels of students. The students must be paired into exactly $frac{n}{2}$ disjoint pairs, so every student is used exactly once. A pair is only “valid” if both students in it end up with exactly the same skill level.

codeforcescompetitive-programmingsortings
CF 1091H - New Year and the Tricolore Recreation

Each row contains three ordered tokens on an infinite number line: a blue token on the left, a white token in the middle, and a red token on the right.

codeforcescompetitive-programminggames
CF 1091G - New Year and the Factorisation Collaboration

We are interacting with a hidden integer modulus $n$, and our goal is to recover its full factorisation. The twist is that we cannot access $n$ directly through arithmetic or inspection.

codeforcescompetitive-programminginteractivemathnumber-theory
CF 1091E - New Year and the Acquaintance Estimation

We are given a simple undirected graph on $n+1$ vertices, but one vertex is missing from the data. Every vertex except Bob’s vertex has a known degree, meaning we know how many neighbors each of those $n$ vertices has.

codeforcescompetitive-programmingbinary-searchdata-structuresgraphsgreedyimplementationmathsortings
CF 1091A - New Year and the Christmas Ornament

We are given three piles of ornaments: yellow, blue, and red. From each pile we may choose some number of ornaments, but the chosen numbers are not independent.

codeforcescompetitive-programmingbrute-forceimplementationmath
CF 1091C - New Year and the Sphere Transmission

We are placing $n$ people around a circle and repeatedly moving a ball in fixed jumps. Starting from person $1$, we choose a step size $k$. Each time the ball is passed, we move $k$ positions clockwise, wrapping around the circle.

codeforcescompetitive-programmingmathnumber-theory
CF 1091D - New Year and the Permutation Concatenation

We are given a number $n$, and we conceptually build a very large sequence by listing every permutation of $1 ldots n$ in lexicographic order and concatenating them one after another. Each permutation contributes exactly $n$ elements, so the full sequence has length $n cdot n!$.

codeforcescompetitive-programmingcombinatoricsdpmath
CF 1090L - Berland University

There are t students and n lectures. A student passes if they attend at least k lectures. Lectures alternate between two auditoriums. Lectures with odd indices are held in the first auditorium, which can hold at most a students.

codeforcescompetitive-programminggreedymath
CF 1090M - The Pleasant Walk

We are given a line of houses, each painted with an integer color. We want to choose a contiguous segment of this line such that inside the chosen segment, no two neighboring houses share the same color.

codeforcescompetitive-programmingimplementation
CF 1090J - Two Prefixes

We are given two strings, s and t. From s, we can take any prefix that is not empty, and independently from t, we can also take any non-empty prefix. For every pair of such choices, we concatenate the chosen prefix of s with the chosen prefix of t.

codeforcescompetitive-programmingstrings
CF 1090K - Right Expansion Of The Mind

Each participant is described by two finite strings. From these two strings we build an infinite sequence by writing the first string once and then repeating the second string forever. So the structure is prefix-then-periodic-tail, where the tail repeats without end.

codeforcescompetitive-programmingmath
CF 1090F - How to Learn You Score

I can’t safely produce a correct, detailed editorial for Codeforces 1090F from the information given here, because the actual problem statement (what the interaction allows, what the judge returns, and what needs to be reconstructed) is missing.

codeforcescompetitive-programmingconstructive-algorithmsinteractive
CF 1090I - Minimal Product

We are given a sequence of integers and asked to choose exactly a fixed number of elements from it. After choosing them, we multiply the chosen values together and obtain a single number.

codeforcescompetitive-programming
CF 1090H - Linearization

The problem statement section is empty, so I don’t have the actual definition of Codeforces 1090H - Linearization to base the editorial on.

codeforcescompetitive-programminggraphs
CF 1090G - Combostone

We are given a configuration of stones arranged in a line. Each stone carries some information, and the game is played by two players who alternate moves.

codeforcescompetitive-programminggamesimplementation
CF 1090E - Horseback Riding

The problem statement sections are empty, so there isn’t enough information to reconstruct what Codeforces 1090E - Horseback Riding actually asks or which flow/graph construction it uses.

codeforcescompetitive-programmingflowsgraphs
CF 1090D - Similar Arrays

We are given a set of positions $1 dots n$ and a list of constraints between some pairs of positions. Each constraint tells us the relationship between the values at two indices: either the first is greater than the second, smaller, or equal.

codeforcescompetitive-programmingconstructive-algorithms
CF 1090C - New Year Presents

We are given several boxes, each containing a set of distinct items. Each item has a type, and no box contains duplicates of the same type. The total number of items is large, and items can be moved one at a time between boxes.

codeforcescompetitive-programmingconstructive-algorithmsdata-structures
CF 1090A - Company Merging

We are given several companies, and each company contains employees with fixed salaries. We are allowed to merge companies one pair at a time until everything becomes a single company.

codeforcescompetitive-programminggreedy
CF 1090B - LaTeX Expert

I can’t reliably reconstruct Codeforces 1090B - LaTeX Expert from memory with enough confidence to write a correct, detailed editorial without risking inventing key parts of the statement or solution.

codeforcescompetitive-programming
CF 1089M - Minegraphed

Got it - I can write a full Codeforces-style editorial (intuition, key idea, proof, implementation details, complexity, etc.).

codeforcescompetitive-programmingconstructive-algorithmsgraphs
CF 1089K - King Kog's Reception

We are maintaining a dynamic collection of knights, where each knight is defined by two values: an arrival time and a fixed service duration.

codeforcescompetitive-programmingdata-structures
CF 1089J - JS Minification

We are given a small programming language source file together with a set of reserved tokens. The original source may contain comments, arbitrary spaces, and user-defined identifiers.

codeforcescompetitive-programminggreedyimplementation
CF 1089L - Lazyland

We are given a collection of workers, each of whom has already picked a job they would like to do. There are exactly $k$ distinct jobs, and each worker points to one of them.

codeforcescompetitive-programming
CF 1089I - Interval-Free Permutations

Sure-please paste the full Codeforces problem statement (or at least the link / input-output / constraints). Once I have it, I’ll write a proper competitive programming editorial with: - Key idea / intuition - Step-by-step reasoning - Formal solution - Complexity analysis -…

codeforcescompetitive-programmingcombinatorics
CF 1089A - Alice the Fan

A volleyball match here is a short sequence of sets, with at most five sets played, and the first team to win three sets takes the match.

codeforcescompetitive-programmingdp
CF 1089G - Guest Student

We are given a weekly schedule of classes that repeats every seven days. Each day of the week is marked either active or inactive for guest student classes. Alongside this schedule, we are given a target number of class days, denoted as $k$.

codeforcescompetitive-programmingmath
CF 1089H - Harder Satisfiability

We are given a logical system built from boolean variables, where constraints are expressed as implications between literals.

codeforcescompetitive-programming2-satdfs-and-similargraphs
CF 1089E - Easy Chess

We are given an $n times n$ chessboard and need to assign the numbers from $1$ to $n^2$ to all cells exactly once. The assignment must satisfy a constraint involving “chess interaction”: the numbering order should not create unwanted adjacency between consecutive integers.

codeforcescompetitive-programmingconstructive-algorithms
CF 1089D - Distance Sum

I can't write a correct editorial for Codeforces 1089D from the information provided. The prompt asks for a complete editorial, proof, algorithm, implementation, worked examples, and tests. For a 3100-rated graph problem, that requires knowing the actual solution.

codeforcescompetitive-programminggraphs
CF 1089C - Cactus Search

We are given a connected structure that is almost a tree but may contain simple cycles, with the restriction that any edge belongs to at most one cycle. Inside this graph there is a hidden vertex chosen by the judge.

codeforcescompetitive-programminginteractive
CF 935F - Fafa and Array

We are given an array of positive integers that changes over time through range increments. Alongside this, we repeatedly answer hypothetical questions about a function that depends on the entire array.

codeforcescompetitive-programmingdata-structuresgreedy
CF 935A - Fafa and his Company

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

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

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

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

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

codeforcescompetitive-programmingmathprobabilities
CF 935C - Fifa and Fafa

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

codeforcescompetitive-programminggeometry
CF 935B - Fafa and the Gates

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

codeforcescompetitive-programmingimplementation
CF 92113 - Labyrinth-13

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

codeforcescompetitive-programming
CF 92111 - Labyrinth-11

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

codeforcescompetitive-programming
CF 92109 - Labyrinth-9

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

codeforcescompetitive-programming
CF 92104 - Labyrinth-4

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

codeforcescompetitive-programming
CF 920D - Tanks

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

codeforcescompetitive-programmingdpgreedyimplementation
CF 920G - List Of Integers

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

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

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

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

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

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

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

codeforcescompetitive-programminggamesgraphsshortest-paths
CF 919C - Seat Arrangements

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

codeforcescompetitive-programmingbrute-forceimplementation
CF 919D - Substring

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

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

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

codeforcescompetitive-programmingimplementationstrings
CF 917D - Stranger Trees

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

codeforcescompetitive-programmingdpmathmatricestrees
CF 917E - Upside Down

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

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

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

codeforcescompetitive-programmingcombinatoricsdpmatrices
CF 917B - MADMAX

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

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

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

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

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

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

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

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

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

codeforcescompetitive-programmingbrute-forceimplementationmath
CF 915G - Coprime Arrays

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

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

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

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

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

codeforcescompetitive-programmingdata-structuresimplementationsortings
CF 915A - Garden

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

codeforcescompetitive-programmingimplementation
CF 915D - Almost Acyclic Graph

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

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

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

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

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

codeforcescompetitive-programmingcombinatoricsdpgamestrees
CF 914A - Perfect Squares

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

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

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

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

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

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

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

codeforcescompetitive-programmingdpgraphsmathprobabilities
CF 913G - Power Substring

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

codeforcescompetitive-programmingmathnumber-theory
CF 913E - Logical Expression

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

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

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

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

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

codeforcescompetitive-programmingbitmasksdpgreedy
CF 913A - Modular Exponentiation

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

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

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

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

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

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

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

codeforcescompetitive-programmingbrute-forcegreedysortings
CF 912A - Tricky Alchemy

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

codeforcescompetitive-programmingimplementation
CF 911F - Tree Destruction

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

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

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

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

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

codeforcescompetitive-programmingdata-structures
CF 911C - Three Garlands

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

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

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

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

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

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

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

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

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

codeforcescompetitive-programminggreedyimplementation
CF 909A - Generate Login

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

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

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

codeforcescompetitive-programmingconstructive-algorithms
CF 909D - Colorful Points

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

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

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

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

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

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

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

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

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

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

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

codeforcescompetitive-programmingdpmathprobabilities
CF 908C - New Year and Curling

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

codeforcescompetitive-programmingbrute-forcegeometryimplementationmath
CF 906D - Power Tower

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

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

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

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

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

codeforcescompetitive-programmingbitmasksbrute-forcedpgraphs