brain

tamnd's digital brain — notes, problems, research

41650 notes

CF 2180D - Insolvable Disks

We are given a set of points on a line, each point representing the center of a disk we must draw. Every disk has a positive radius, and no two disks can overlap, though touching at the edges is allowed.

codeforcescompetitive-programmingdata-structuresdpgreedymath
CF 2180C - XOR-factorization

We are asked to take an integer $n$ and split it into exactly $k$ non-negative integers whose bitwise XOR equals $n$. Among all such splits, we want one that maximizes the sum of the numbers. Each number in the split must be between 0 and $n$ inclusive.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsdpgreedynumber-theory
CF 2180A - Carnival Wheel

We are given a circular prize wheel with l numbered sections from 0 to l-1. The wheel pointer starts at a section a. Each spin moves the pointer forward by exactly b positions modulo l.

codeforcescompetitive-programmingbrute-forcenumber-theory
CF 2180B - Ashmal

We are given a sequence of strings, and we must insert them one by one into an initially empty string. Each new string can be placed either at the left end or the right end of the current result. After all insertions, we obtain a single final string.

codeforcescompetitive-programminggreedystrings
CF 2181M - Medical Parity

We are given two binary strings, which we can think of as observed measurements from a medical test. The first string represents the recorded presence or absence of reactions to several allergens.

codeforcescompetitive-programmingdpstrings
CF 2181L - LLM Training

We are given several token sequences, each sequence representing a text where some positions are produced by a language model and others are written directly by a user. Only the positions marked as generated contribute to the training loss.

codeforcescompetitive-programmingmathstring-suffix-structures
CF 2181K - Knit the Grid

The canvas is a rectangular grid of cells, but the real structure lives on its grid graph: vertices are grid intersection points and edges connect adjacent intersections horizontally or vertically. Initially, some collection of simple cycles is drawn along these edges.

codeforcescompetitive-programming2-satconstructive-algorithmsgraphsmatrices
CF 2181I - Irrigation Interlock

We have two sets of points on a Cartesian plane: pumps scattered across a valley and reservoirs positioned on surrounding hills.

codeforcescompetitive-programminggeometry
CF 2181J - Jinx or Jackpot

We are given a casino machine whose behaviour is determined by one hidden probability value. There is an array of probabilities, and the casino owner secretly picks one index uniformly at random at the start and fixes it forever.

codeforcescompetitive-programmingbrute-forcedpmathprobabilities
CF 2181H - Honey Cake

We are given a rectangular cake with dimensions $w times h times d$. The goal is to divide this solid into exactly $n$ smaller rectangular pieces, all identical in size. The only allowed operations are cuts that are parallel to the faces of the cake.

codeforcescompetitive-programmingbrute-forcemathnumber-theory
CF 2181G - Greta's Game

Each round produces a choice of an integer at every position on a cycle. After the numbers are chosen, we look at each adjacent pair on the cycle and award one point to both endpoints whenever the left endpoint is strictly larger than the right endpoint.

codeforcescompetitive-programmingbinary-searchdpgraphsgreedymath
CF 2181E - Elevator Against Humanity

We have a skyscraper with floors numbered from 1 up to very large numbers, and several people waiting for an elevator on different floors. Each person has a distinct starting floor and a distinct destination floor, and no two floors overlap.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedysortings
CF 2181F - Fragmented Nim

We are asked to analyze a variation of the classical game of Nim. In the original Nim, players take turns picking a pile and removing any number of stones. The player who takes the last stone wins.

codeforcescompetitive-programminggames
CF 2181D - Doorway

Each layer of the doorway is a one-dimensional segment between two fixed walls. Inside that segment, there are several rigid door blocks placed in a line, but each block is allowed to slide left or right as long as it does not overlap other blocks or cross the walls.

codeforcescompetitive-programmingbinary-searchdata-structuressortings
CF 2181A - Alphabet City

We are asked to calculate how many full sets of street signs can be made when one street's order is missing. Each street in Alphabet City has a name made from capital letters, and each street has an order for m identical signs.

codeforcescompetitive-programmingbinary-searchmathstrings
CF 2181B - Battle of Arrays

We are asked to simulate a turn-based game between Alice and Bob. Each player starts with an array of positive integers. On their turn, a player picks any element from their own array and applies it against the maximal element in the opponent's array.

codeforcescompetitive-programmingdata-structuresgamesgreedy
CF 2181C - Cacti Classification

We are dealing with a hidden connected graph that has a very restricted structure: it is a cactus, meaning every edge participates in at most one simple cycle.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsinteractivemath
CF 2182G - Short Garland

We are given a rooted tree with vertex 1 fixed as the root. A sequence of n “placements” must be assigned, one for each vertex of the tree, but the twist is that the placement order is not arbitrary. The first placement is forced onto the root.

codeforcescompetitive-programmingcombinatoricsdata-structuresdfs-and-similardptrees
CF 2182F2 - Christmas Reindeer (hard version)

We have a dynamic herd of reindeer, each with strength $2^{ci}$, and we need to answer three types of queries: adding a reindeer, removing a reindeer, or counting how many subsets of the herd meet a certain carrying capacity threshold.

codeforcescompetitive-programmingbitmasksbrute-forcecombinatoricsdata-structuresgreedymath
CF 2182E - New Year's Gifts

Monocarp wants to make as many friends happy as possible with a limited budget. He has a number of friends and a set of boxes.

codeforcescompetitive-programmingbinary-searchdata-structuresgreedysortingstwo-pointers
CF 2182F1 - Christmas Reindeer (easy version)

We maintain a multiset of reindeer. Each reindeer is identified by a power level, but the real value that matters is a power of two, $2^{ci}$.

codeforcescompetitive-programmingbitmasksbrute-forcecombinatoricsdpmath
CF 2182D - Christmas Tree Decoration

We are given several independent scenarios. In each scenario, there are $n$ people and $n+1$ boxes of decorations. Box $0$ is special, and each person $i$ has their own personal box $i$. Each box starts with some number of decorations.

codeforcescompetitive-programmingcombinatoricsdpgreedymath
CF 2182A - New Year String

We are given a string composed of the characters 0, 2, 5, and 6. A string is considered a New Year string if it either contains the substring 2026 somewhere or does not contain the substring 2025 at all.

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementationstrings
CF 2182B - New Year Cake

We are asked to help Monocarp bake a layered cake under two constraints: the size of each layer grows exponentially and the chocolate covering each layer must alternate between white and dark. The top layer always has size 1.

codeforcescompetitive-programmingbrute-force
CF 2182C - Production of Snowmen

We are given three circular sequences of equal length, each representing sizes of snowballs on a conveyor belt. From each conveyor we choose a starting position, and then we simultaneously walk forward step by step around all three cycles.

codeforcescompetitive-programmingbrute-forcecombinatoricsdp
CF 2183I2 - Pairs Flipping (Hard Version)

We are given a binary string where each position contains either a 0 or a 1. We are allowed a fixed number of operations, exactly one for each value from 1 up to half the length of the string.

codeforcescompetitive-programmingconstructive-algorithms
CF 2183I1 - Pairs Flipping (Easy Version)

We are working with a binary string where each position holds either a 0 or a 1, and we are allowed to repeatedly apply a very specific kind of operation. Each operation is indexed from 1 upward, and on operation number x we may choose a starting position l.

codeforcescompetitive-programmingconstructive-algorithms
CF 2183G - Snake Instructions

The interactive version allows us to ask up to three carefully chosen instructions and observe the surviving snakes. In the hacked version, the speeds are already given in the input, and our job is to reproduce the answer that an optimal interactive solution would output.

codeforcescompetitive-programmingconstructive-algorithmsgreedyinteractive
CF 2183H - Minimise Cost

We are given an array of integers and asked to divide it into exactly $k$ non-empty subsequences. For any subsequence $b$, its cost is defined as the product of its length and the sum of its elements. Our goal is to minimize the total cost across all $k$ subsequences.

codeforcescompetitive-programmingbinary-searchdpgreedysortings
CF 2183F - Jumping Man

We are given a rooted tree with each node labeled by a lowercase letter. For each node $i$, we are asked to analyze all strings that can be formed by starting at any node in the subtree of $i$ and repeatedly jumping to a proper descendant, concatenating the letters along the…

codeforcescompetitive-programmingbrute-forcecombinatoricsdfs-and-similardptrees
CF 2183E - LCM is Legendary Counting Master

We are given a sequence of length $n$ where some positions are fixed numbers between $1$ and $m$, and some positions are zero placeholders that must be filled. After filling all zeros with values in $[1, m]$, the resulting sequence must satisfy two conditions at the same time.

codeforcescompetitive-programmingdpmathnumber-theory
CF 2183D2 - Tree Coloring (Hard Version)

We are given a rooted tree, where all nodes are initially white, and we need to color all nodes black in the minimum number of operations.

codeforcescompetitive-programmingcombinatoricsconstructive-algorithmsdata-structuresdfs-and-similargreedyimplementationtrees
CF 2183D1 - Tree Coloring (Easy Version)

We are given a rooted tree with n vertices, where the root is vertex 1, and initially all vertices are white. The distance di of a vertex i is the number of edges on the path from the root to i.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similargreedytrees
CF 2183B - Yet Another MEX Problem

We are given an array of non-negative integers and a number $k$. The task is to repeatedly remove elements from the array, always choosing a window of length $k$ whose MEX is maximal, and deleting any element within that window.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 2183C - War Strategy

We have a linear arrangement of bases numbered from 1 to n. Our home base is at position k, and we start with exactly one soldier there. Every day, we can select a base and move any number of soldiers from it either left or right by exactly one position.

codeforcescompetitive-programmingbinary-searchgreedymathtwo-pointers
CF 2183A - Binary Array Game

We are given a binary array that evolves through a merging game. Two players, Alice and Bob, alternate turns. On each turn, a player selects a contiguous segment of length at least two, removes it, and replaces it with a single value derived from that segment.

codeforcescompetitive-programminggames
CF 2184F - Cherry Tree

We have a rooted tree whose leaves each contain exactly one cherry. A shake performed at vertex v makes the cherries fall from every leaf inside the subtree of v. Once a cherry has fallen, it must never be affected by another shake.

codeforcescompetitive-programmingdfs-and-similardpgraphstrees
CF 2184G - Nastiness of Segments

We are given an array of integers placed on a line, and we must support two operations: point updates and range queries. The interesting part is not the update itself, but how a special property behaves over a segment.

codeforcescompetitive-programmingbinary-searchdata-structures
CF 2184D - Unfair Game

Working

codeforcescompetitive-programmingcombinatoricsdpmath
CF 2184E - Exquisite Array

We are given a permutation of length $n$, which is simply an array of integers from $1$ to $n$ in some order without repeats.

codeforcescompetitive-programmingcombinatoricsdata-structuresdsusortings
CF 2184B - Hourglass

Vadim has an hourglass that measures exactly s minutes. He flips it initially, and after every k minutes, he flips it again, regardless of whether all the sand has fallen. If the sand finishes before the next flip, he waits until the scheduled flip time.

codeforcescompetitive-programmingmath
CF 2184A - Social Experiment

We have $n$ people. They must be partitioned into teams, where every team has either 2 or 3 members. After the teams are formed, each team independently chooses one of two civilizations.

codeforcescompetitive-programmingmath
CF 2184C - Huge Pile

Andrei starts with a single pile containing $n$ apples. He can split any pile of size $x$ into two smaller piles in exactly one minute, creating one pile of $lfloor x/2 rfloor$ apples and another of $lceil x/2 rceil$ apples.

codeforcescompetitive-programmingbinary-searchdfs-and-similardpgraphsmath
CF 2185H - BattleCows 2

The tournament has a surprisingly simple structure once we stop thinking about individual matches. Whenever a cow survives a match, its new skill becomes the sum of the two participants.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresdpgreedy
CF 2185G - Mixing MEXes

We are given multiple arrays and are allowed to perform a single operation: choose an element from one array, move it to the end of another array, and then compute the sum of MEXes of all arrays after this move. The task is to sum the values of all possible such operations.

codeforcescompetitive-programmingdata-structuresimplementationmath
CF 2185F - BattleCows

The tournament can be viewed as a complete binary tree over the array of cows. Each leaf is a single cow. Every internal node represents a contiguous segment of cows. The skill of a node is the XOR of all values inside that segment.

codeforcescompetitive-programmingdata-structuresdivide-and-conquerimplementation
CF 2185E - The Robotic Rush

Every robot receives exactly the same sequence of moves. After the first instruction, all robots shift by the same displacement. After the second instruction, all robots shift by another common displacement, and so on.

codeforcescompetitive-programmingbinary-searchgreedyimplementationtwo-pointers
CF 2185D - OutOfMemoryError

We start with an array and a sequence of update operations. Each operation adds some value to one position. The unusual part is the crash rule. After every update, if any element of the current array becomes larger than h, the computer immediately crashes.

codeforcescompetitive-programmingdata-structuresimplementationmathtwo-pointers
CF 2185C - Shifted MEX

We are given an array of integers, which may include negative numbers. The task allows us to pick a single integer shift x and add it to every element of the array. After performing this shift, we want to maximize the MEX of the array.

codeforcescompetitive-programmingimplementationsortings
CF 2185A - Perfect Root

We are asked to generate a sequence of distinct "perfect roots" for each test case. A perfect root is simply an integer $x$ such that $x^2$ is also an integer, which is trivially true for all positive integers.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 2185B - Prefix Max

We are given an array. For every position, we look at the prefix ending there and take the maximum value seen so far. The score of the array is the sum of all those prefix maxima. We may swap any two elements at most once, or choose not to swap at all.

codeforcescompetitive-programminggreedy
CF 2187G - Many Cartesian Trees

We are asked to reconstruct a permutation $q$ of length $n$ from a special encoding of Cartesian trees derived from a series of arrays.

codeforcescompetitive-programminggreedysortingstrees
CF 2187F1 - Al Fine (Maximizing Version)

We are given two DFS preorder traversals of the same set of vertices {0,1,...,n}. The tree itself is unknown. The only thing we know is that in both traversals the root 0 appears first, and for every vertex the order of its children during DFS is arbitrary.

codeforcescompetitive-programmingbinary-searchdata-structuresdivide-and-conquertrees
CF 2187F2 - Al Fine (Counting Version)

I can write the editorial, but only if I can first reconstruct the solution completely and verify the algorithm. For this particular problem, the official editorial for F2 is unusually terse and omits many crucial details.

codeforcescompetitive-programmingdptrees
CF 2187E - Doors and Keys

We have a sequence of $n+1$ rooms connected by $n$ doors. Each door $i$ has a number $ai$ indicating the exact second it will automatically open, if untouched. Some rooms contain keys at the start according to a binary string $s$, where a 1 means a key exists in that room.

codeforcescompetitive-programmingbrute-forcedata-structuresdp
CF 2187A - Restricted Sorting

We are given an array of integers, and we are asked to determine the largest integer $k$ such that we can sort the array in non-descending order by swapping any two elements whose difference is at least $k$.

codeforcescompetitive-programminggreedysortings
CF 2187C - Jerry and Tom

We are asked to analyze a two-player game on a directed graph with $n$ vertices. The graph is almost a chain: for every vertex $u$ from 1 to $n-1$, there is an edge $u to u+1$.

codeforcescompetitive-programmingdata-structuresdfs-and-similardsugamesgraphsgreedytrees
CF 2188B - Seats

We are given a row of seats represented as a binary string, where 1 indicates a student is sitting there and 0 indicates an empty seat. No two students are adjacent initially.

codeforcescompetitive-programminggreedy
CF 2189F - Zhora the Vacuum Cleaner

We have a tree. Vertex i initially contains ai nuts. There are two kinds of electricity costs. The first cost comes from a special redistribution operation. We choose a vertex v. Then every other vertex is processed from larger distance to smaller distance from v.

codeforcescompetitive-programmingdata-structuresdfs-and-similardpgreedyimplementationsortingstrees
CF 2189D2 - Little String (Hard Version)

We are not asked to count permutations directly. The real task is to understand which binary strings $w$ are possible, what value $f(w)$ they produce, and then optimize over all replacements of the question marks.

codeforcescompetitive-programmingcombinatoricsdpgreedymathnumber-theory
CF 2189E - Majority Wins?

We are given a binary string s of length n. Our goal is to transform this string into a single character "1" using a special operation: we can take any contiguous substring, and replace it with the character that occurs at least as many times as the other character in that…

codeforcescompetitive-programmingconstructive-algorithmsgreedymathstrings
CF 2189D1 - Little String (Easy Version)

We are given a string of length $n$ consisting of 0s and 1s. For a permutation $p$ of $[0, 1, dots, n-1]$, the function $f(w)$ counts the number of permutations such that, for each position $i$, the minimum excluded value (MEX) condition is satisfied: if $wi = 1$, there exists…

codeforcescompetitive-programmingcombinatoricsdpgreedymathnumber-theory
CF 2189A - Table with Numbers

We have an array of numbers. We may select any even number of elements from it and partition them into ordered pairs. A pair (x, y) contributes 1 to the table only if row x and column y exist.

codeforcescompetitive-programminggreedyimplementation
CF 2189C1 - XOR Convenience (Easy Version)

We need to construct a permutation of the numbers from 1 to n. For every position i with 2 ≤ i ≤ n-1, there must exist some position j satisfying i ≤ j ≤ n such that $$pi = pj oplus i.$$ Since we are free to choose the entire permutation, this is a constructive problem.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsmath
CF 2189B - The Curse of the Frog

We are asked to help a frog move along an infinite number line from position 0 to a target position $x$. The frog has $n$ types of magical jumps.

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 2190G - Maximize Determinant

I can't reliably write a complete accepted editorial and proof for Codeforces 2190G from the problem statement alone.

codeforcescompetitive-programminggraphs
CF 2190D - Prufer Vertex

We start with a forest. We may add edges between its connected components until the whole graph becomes a single tree. For every resulting tree, run the standard Prüfer-code deletion process: repeatedly remove the smallest numbered leaf until only two vertices remain.

codeforcescompetitive-programmingcombinatoricsdsunumber-theoryprobabilitiestrees
CF 2190E - Median Permutation

Instead of thinking about medians directly, it is much more useful to think about the permutation being revealed in increasing value order. Suppose we process the values of a permutation from 1 to n. When value x is processed, its position becomes "active".

codeforcescompetitive-programmingcombinatorics
CF 2190F - Xor Product

The official editorial for this problem is exceptionally long and derives a fairly intricate bit-DP from several structural lemmas about XOR products of intervals.

codeforcescompetitive-programmingbitmasksdp
CF 2190C - Comparable Permutations

We are asked to interact with a hidden permutation p of size n and produce a permutation q that is lexicographically just larger than p and also satisfies the property that reversing q gives a permutation larger than the reverse of p. The catch is that we never see p directly.

codeforcescompetitive-programminggreedyimplementationinteractivesortingstwo-pointers
CF 2190B2 - Sub-RBS (Hard Version)

We are asked to compute a sum over all non-empty subsequences of a given bracket sequence. Each subsequence has a “score” defined as the length of its longest regular bracket subsequence that is strictly “better” than itself.

codeforcescompetitive-programmingdpgamesimplementationstrings
CF 2190B1 - Sub-RBS (Easy Version)

We are given a regular bracket sequence s. A regular bracket sequence (RBS) is one where every prefix contains at least as many '(' as ')', and the total numbers of opening and closing brackets are equal.

codeforcescompetitive-programmingcombinatoricsconstructive-algorithmsdpgreedystringstwo-pointers
CF 2190A - Sorting Game

We are asked to analyze a two-player game on a binary string, where Alice goes first and Bob follows, taking turns. On their turn, a player may select any strictly non-increasing subsequence of the string and rearrange it to be non-decreasing.

codeforcescompetitive-programmingconstructive-algorithmsgamesgreedy
CF 2191A - Array Coloring

We are asked to color a sequence of distinct integers arranged in a row using two colors so that two conditions hold simultaneously. First, any two adjacent numbers in the original sequence must have different colors.

codeforcescompetitive-programmingconstructive-algorithms
CF 2192E - Swap to Rearrange

Each position i contains a pair of values (ai, bi). For that position we have exactly two choices. If we do nothing, the value ai stays in array a and bi stays in array b. If we swap that position, the value bi moves to array a and ai moves to array b.

codeforcescompetitive-programmingconstructive-algorithmsdfs-and-similargraph-matchingsgraphsgreedystrings
CF 2192D - Cost of Tree

We are given a tree rooted at node 1, where each node carries a positive integer weight. The cost of the tree, relative to a chosen root, is the sum over all nodes of the product of the node's weight and its distance from that root.

codeforcescompetitive-programmingdpgreedytrees
CF 2192F - Fish Fight

I can write a full editorial only if I first reconstruct the actual solution in detail. For this problem, the official editorial contains a fairly intricate two-phase DP with interval states, probability propagation, prefix/suffix aggregation, and a second DP once the two…

codeforcescompetitive-programmingdpmathprobabilities
CF 2192B - Flipping Binary String

We are given a binary string, which is a sequence of 0s and 1s, and we can perform a very specific operation: pick one index i, and flip every bit in the string except the bit at index i. Flipping means changing 0 to 1 and 1 to 0.

codeforcescompetitive-programmingconstructive-algorithmsstrings
CF 2192C - All-in-one Gun

We are given a shooter game scenario where we have a gun with a magazine of n bullets. Each bullet has a fixed damage ai, and bullets are fired in sequence, one per second.

codeforcescompetitive-programmingbinary-searchgreedymath
CF 2192A - String Rotation Game

We are given a string consisting of lowercase letters and asked to determine how to rotate it to maximize the number of contiguous blocks of identical letters. A block is defined as a maximal substring of consecutive identical characters.

codeforcescompetitive-programmingbrute-forcestrings
CF 2193H - Remove the Grail Tree

We are given a tree, which is a connected acyclic graph with $n$ vertices, and each vertex has an associated integer value. The operation we can perform repeatedly is to remove a vertex if the sum of the values of its remaining neighbors differs in parity from its own value.

codeforcescompetitive-programmingdfs-and-similardpgraphsgreedyimplementationtrees
CF 2193G - Paths in a Tree

We are given a tree, which is an undirected, connected, acyclic graph of $n$ vertices. Two hidden vertices, $x$ and $y$, define a unique path because trees have exactly one simple path between any pair of vertices.

codeforcescompetitive-programmingdfs-and-similarinteractivesortingstrees
CF 2193F - Pizza Delivery

The courier starts at $(Ax, Ay)$, must visit every house, and finally reach $(Bx, By)$. The movement rules are unusual. He may move one unit to the right, one unit up, or one unit down. He can never decrease his $x$-coordinate.

codeforcescompetitive-programmingdpgreedy
CF 2193E - Product Queries

We are given an array whose values lie between 1 and n. An element may be reused any number of times, so the only thing that matters is which values are present in the array, not how many times they occur.

codeforcescompetitive-programmingdpmathnumber-theoryshortest-paths
CF 2193D - Monster Game

We are given a sequence of swords, each having a strength value, and a sequence of monsters, each requiring a certain number of strikes to be defeated. Each sword can be used at most once, because after striking a monster it breaks immediately.

codeforcescompetitive-programmingbinary-searchsortingstwo-pointers
CF 2193C - Replace and Sum

We start with two arrays of the same length. For any position, we may directly overwrite a[i] with b[i]. We may also copy values from right to left by replacing a[i] with the current value of a[i+1]. Each query asks for the largest possible sum on a subarray a[l..

codeforcescompetitive-programmingdata-structuresgreedy
CF 2193B - Reverse a Permutation

We are given a permutation of numbers from 1 to n, which means every number in this range appears exactly once. We are allowed to choose a single continuous segment of this permutation and reverse it.

codeforcescompetitive-programminggreedy
CF 2193A - DBMB and the Array

We are given an array of integers and a fixed increment value. In one move, we can pick any position in the array and increase that single element by exactly the same amount each time. We can repeat this operation as many times as we want on any indices.

codeforcescompetitive-programmingbrute-forcemath
CF 2194F2 - Again Trees... (hard version)

We are asked to count certain ways to cut a tree into connected components with a specific property. The tree has n vertices, each with a value av. We are also given a small set of numbers b1, ..., bk.

codeforcescompetitive-programmingbitmasksdata-structuresdfs-and-similardpffttrees
CF 2194E - The Turtle Strikes Back

We have a rectangular grid. Every cell contains an integer value, positive or negative. Michelangelo chooses a path from the top-left corner to the bottom-right corner. He may only move right or down.

codeforcescompetitive-programmingdpgraphsgreedyimplementation
CF 2194D - Table Cut

We are given a grid of size $n times m$ filled with zeros and ones. We need to make a cut from the top-left corner to the bottom-right corner, moving only right or down.

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementation
CF 2194F1 - Again Trees... (Easy Version)

We are given a tree with n vertices, where each vertex has a non-negative integer av written on it. We are also given a set of k distinct non-negative integers b1, ..., bk.

codeforcescompetitive-programmingbitmasksdfs-and-similardptrees
CF 2194B - Offshores

We are given several independent scenarios. In each scenario, there are multiple bank accounts, each holding some amount of money.

codeforcescompetitive-programminggreedyimplementationmath
CF 2194C - Secret message

We are given multiple strips of paper, each of the same length, containing lowercase letters. Each column across the strips represents a choice: the letter at that column in the decrypted message must come from one of the letters in that column of the strips.

codeforcescompetitive-programmingbitmasksbrute-forcedpmathnumber-theory
CF 2194A - Lawn Mower

We are given a fence made of $n$ unit-width boards arranged in a line. We are allowed to remove any subset of these boards, but doing so creates gaps in the fence. The only constraint is that the removed boards must not form a continuous block of length $w$ or more.

codeforcescompetitive-programminggreedymath
CF 2195H - Codeforces Heuristic Contest 001

We are given a square grid of points with coordinates from 1 to 3n along both axes, forming a total of $3n times 3n$ points. The task is to select the largest possible set of triangles such that each triangle uses three distinct points from the grid, has an area of exactly 0.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgeometryimplementation
CF 2195G - Idiot First Search and Queries

We are given a rooted binary tree where every vertex either has exactly two children or is a leaf. The root is vertex 0, and all other vertices are numbered from 1 to n. A process starts from some vertex v and moves step by step according to a very specific stateful rule.

codeforcescompetitive-programmingbinary-searchdata-structuresdpgraphstrees
CF 2195F - Parabola Independence

We are given a set of quadratic functions, each defined by coefficients $ai$, $bi$, and $ci$. Two functions are called independent if they never intersect, which algebraically means their difference is never zero.

codeforcescompetitive-programmingdpgraphsgreedymathsortings
CF 2195E - Idiot First Search

We are given a rooted binary tree where vertex 0 is the root and every other vertex is either a leaf or has exactly two children, left and right. The vertices are numbered, and the structure is fully specified by child pointers.

codeforcescompetitive-programmingdfs-and-similardptrees
CF 2195D - Absolute Cinema

We are given a hidden sequence of integers $a1, a2, dots, an$ and, instead of the sequence itself, we are provided with a function evaluated at each index: $f(x) = sum{i=1}^n ai cdot Given that $n$ can be as large as 300,000 and the total sum over all test cases is also…

codeforcescompetitive-programmingmath