brain

tamnd's digital brain — notes, problems, research

41650 notes

CF 2164C - Dungeon

We are asked to simulate a dungeon scenario where you have a set of swords, each with a damage value, and a set of monsters, each with a life value. You can kill a monster if your sword’s damage is at least equal to the monster’s life.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresgreedysortings
CF 2164B - Even Modulo Pair

We are given several test cases. In each one, we receive a strictly increasing list of positive integers. The task is to choose two different elements from this list, call them $x$ and $y$, with the restriction that $x < y$, such that when we divide $y$ by $x$, the remainder…

codeforcescompetitive-programmingbrute-forcemathnumber-theory
CF 2164A - Sequence Game

We are given a sequence of numbers, and we repeatedly compress it until only one value remains. Each operation takes two adjacent elements, removes them, and replaces them with any integer lying between the two original values, inclusive.

codeforcescompetitive-programmingbrute-forcesortings
CF 2165F - Arctic Acquisition

We are given a permutation of length $n$, which is an array of distinct integers from 1 to $n$ arranged in some order. The task is to count the number of contiguous subarrays (intervals) that contain a specific pattern, called a 21435-subsequence.

codeforcescompetitive-programmingdata-structuresgreedy
CF 2165C - Binary Wine

We are given an array of integers, and each element acts like a cap: for each position $i$, we are allowed to choose a value $bi$ anywhere between $0$ and $ai$, inclusive. From this chosen vector $b$, we look at the XOR of all its elements.

codeforcescompetitive-programmingbitmasksgreedymath
CF 2165E - Rainbow Branch

We are given a tree and we need to assign colors to its edges. The restriction is that we must use exactly $k$ distinct colors, each appearing at least once. Once the coloring is fixed, consider any two vertices and look at the simple path between them.

codeforcescompetitive-programmingconstructive-algorithmsdpgreedytrees
CF 2165D - Path Split

We are given a sequence of integers. Our goal is to split this sequence into the smallest number of subsequences where each subsequence is “consecutive in value.” That is, within a subsequence, every adjacent pair differs by exactly one.

codeforcescompetitive-programminggraph-matchingsgreedy
CF 2165B - Marble Council

We are given a multiset of integers, which we can think of as a bag of marbles where each marble has a color represented by a number.

codeforcescompetitive-programmingdpmathsortings
CF 2165A - Cyclic Merging

We are asked to merge elements arranged in a circle. Each element is a non-negative integer, and two elements are considered adjacent if they are next to each other in the array or if one is at the start and the other at the end.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 2167G - Mukhammadali and the Smooth Array

We are given an integer array and a corresponding cost array. For each position in the array, we can replace its value at a certain cost, and positions we do not change keep their original values.

codeforcescompetitive-programmingdata-structuresdp
CF 2167F - Tree, TREE!!!

We are given an unrooted tree and a parameter $k$. For every possible choice of a root $r$, we conceptually “re-root” the tree at $r$ and then look at all ways of selecting exactly $k$ distinct nodes.

codeforcescompetitive-programmingdfs-and-similardpmathtrees
CF 2167E - khba Loves to Sleep!

We are given a one-dimensional segment from 0 to x, and a set of n friends sitting at fixed integer positions on this segment. We are allowed to place k teleport points anywhere on the segment, all at distinct integer positions.

codeforcescompetitive-programmingbinary-searchdata-structuresgeometrygreedyimplementation
CF 2167D - Yet Another Array Problem

Each test case gives a collection of large integers, and the task is to find the smallest integer $x ge 2$ such that at least one element in the array is coprime with $x$.

codeforcescompetitive-programmingbrute-forceimplementationmathnumber-theory
CF 2167C - Isamatdin and His Magic Wand!

We are given several independent test cases. Each test case consists of a sequence of integers representing toys arranged in a line. The only operation allowed is swapping two elements if one is even and the other is odd. Swaps between two evens or two odds are forbidden.

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementationsortings
CF 2167B - Your Name

We are given two strings, s and t, each of length n. The first string represents a row of lettered cubes, and the second string is a target name. The task is to determine if it is possible to rearrange the letters of s to exactly match t.

codeforcescompetitive-programmingsortingsstrings
CF 2167A - Square?

We are given four stick lengths per test case, and we want to know whether these four sticks can be arranged to form the boundary of a square.

codeforcescompetitive-programmingmathsortings
CF 2168C - Intercepting Butterflies

Alice has a secret integer x between 1 and 2^15 that she wants to communicate to Bob using a set S drawn from the integers 1 through 20. The twist is that when Bob receives S, one element may have been added, one may have been removed, or S may be unchanged.

codeforcescompetitive-programmingbitmaskscommunicationconstructive-algorithmsgraphsinteractive
CF 2168B - Locate

Something went wrong. If this issue persists please contact us through our help center at help.openai.com.

codeforcescompetitive-programmingbinary-searchcombinatoricscommunicationconstructive-algorithmsgreedyinteractive
CF 2168A1 - Encode and Decode (Easy Version)

We are asked to design a two-phase program that communicates an array of integers through a single string. On the first run, the program receives an array of length n, where each element is at most 26.

codeforcescompetitive-programmingcommunicationconstructive-algorithmsinteractive
CF 2168A2 - Encode and Decode (Hard Version)

We are asked to implement a two-phase encoding and decoding process for an array of integers. In the first phase, the program receives an array a of size n with values up to one billion and must output a string s composed of lowercase letters.

codeforcescompetitive-programmingbitmaskscommunicationinteractivemath
CF 2169F - Subsequence Problem

We are asked to count arrays of length $n$ over the integers from 1 to $m$ that are “perfect” with respect to $k$ given sets of numbers. Each set defines the allowable value for a position in a hypothetical “beautiful” array of length $k$.

codeforcescompetitive-programmingcombinatoricsdpfftmath
CF 2169D2 - Removal of a Sequence (Hard Version)

We are given an infinite sequence of natural numbers starting from 1. Polycarp performs a special removal operation exactly $x$ times. Each operation removes all numbers in positions that are multiples of $y$ in the current sequence.

codeforcescompetitive-programmingbinary-searchdivide-and-conquergreedyimplementationmathnumber-theory
CF 2169E - Points Selection

We are asked to model a two-player game on a set of points in the plane, where each point has a cost. Alice removes some points with the goal of maximizing a total score, and Bob then draws the smallest axis-aligned rectangle containing all remaining points to minimize the score.

codeforcescompetitive-programmingdpgreedy
CF 2169D1 - Removal of a Sequence (Easy Version)

We start with an infinite sequence of natural numbers, effectively thinking of it as the array 1, 2, 3, 4, .... The process repeatedly removes elements based on a fixed step size y: every time we apply an operation, we delete the elements sitting at positions y, 2y, 3y, ...

codeforcescompetitive-programmingbinary-searchimplementationmathnumber-theory
CF 2169B - Drifting Away

We are given a one-dimensional river represented as a string of cells. Each cell has one of three behaviors: it can push Monocarp left, push him right, or do nothing. Monocarp chooses a starting cell and then moves step by step in discrete time.

codeforcescompetitive-programminggreedyimplementation
CF 2169A - Alice and Bob

Each test case gives a sorted list of marble values and a fixed integer chosen by Alice. Bob must pick his own integer, and then every marble independently awards its point to whoever is closer to that marble’s value, with Alice winning ties.

codeforcescompetitive-programminggreedyimplementation
CF 2169C - Range Operation

We are given an array of integers and allowed to perform a single operation at most once: choose a contiguous subarray and replace all its elements with the sum of its 1-based endpoints.

codeforcescompetitive-programmingdpgreedymathtwo-pointers
CF 2170F - Build XOR on a Segment

We are asked to process multiple queries on an array of integers, where each query specifies a segment of the array and a target number. For each query, we need to find the smallest subset of elements within that segment whose XOR equals the target.

codeforcescompetitive-programmingbitmasksdp
CF 2170E - Binary Strings and Blocks

We are asked to count binary strings of length n that satisfy multiple “beauty” constraints on certain substrings. A block is a maximal contiguous sequence of identical characters.

codeforcescompetitive-programmingcombinatoricsdata-structuresdp
CF 2170D - Almost Roman

We are given a string consisting of the characters 'X', 'V', 'I', and '?'. Each letter has a numeric value: 'X' is worth 10, 'V' is worth 5, and 'I' is usually worth 1, but if it is immediately followed by an 'X' or 'V', it counts as -1.

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementation
CF 2170B - Addition on a Segment

We are given an array of length $n$, initially all zeros. We perform exactly $n$ operations, and each operation adds $1$ to every element of some chosen contiguous segment.

codeforcescompetitive-programminggreedymath
CF 2170A - Maximum Neighborhood

We are asked to consider an $n times n$ grid of integers filled sequentially row by row. The first row contains numbers from $1$ to $n$, the second from $n+1$ to $2n$, and so on until the $n$-th row, which contains numbers from $n^2-n+1$ to $n^2$.

codeforcescompetitive-programmingbitmasksbrute-forcegreedyimplementationmath
CF 2170C - Quotient and Remainder

We are given two multisets of integers, one called $q$ and one called $r$, along with an upper bound $k$. The only way to remove elements is by pairing one value from $q$ with one value from $r$ through a hidden construction involving two integers $x$ and $y$, where $1 le y <…

codeforcescompetitive-programmingbinary-searchgreedytwo-pointers
CF 2171G - Sakura Adachi and Optimal Sequences

We are given two arrays of the same length, a and b, where each element of a is at most the corresponding element in b. The task is to transform a into b using two allowed operations: incrementing a single element of a by 1, or doubling all elements in a.

codeforcescompetitive-programmingbitmaskscombinatoricsgreedymath
CF 2171H - Shiori Miyagi and Maximum Array Score

The task asks us to construct an array of length n with strictly increasing integers, all bounded by m, such that a particular score is maximized. The score is the sum of v(i, ai) from i=2 to n, where v(b, x) is the largest power k such that b^k divides x.

codeforcescompetitive-programmingbinary-searchdata-structuresdpsortings
CF 2171F - Rae Taylor and Trees (hard version)

We are asked to construct a tree on $n$ vertices labeled from $1$ to $n$ such that for every edge connecting vertices $u$ and $v$ with $u < v$, the vertex $u$ appears before $v$ in a given permutation $p$.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsdata-structuresdpdsugreedyimplementationtrees
CF 2171E - Anisphia Wynn Palettia and Good Permutations

We are asked to construct permutations of integers from 1 to n such that in every consecutive triplet of elements, at most six indices are "bad." An index i is bad if the three consecutive numbers starting at i are pairwise coprime.

codeforcescompetitive-programmingconstructive-algorithmsgreedynumber-theory
CF 2171C1 - Renako Amaori and XOR Game (easy version)

Each test case gives two binary arrays of equal length. On position $i$, there is a pair of bits $(ai, bi)$. During the game, players go through indices from left to right.

codeforcescompetitive-programmingbitmasksgamesgreedy
CF 2171D - Rae Taylor and Trees (easy version)

We are asked to check whether a tree can be built from a permutation of numbers from 1 to n, subject to a specific ordering constraint.

codeforcescompetitive-programmingbinary-searchdata-structuresdpdsugreedyimplementationtrees
CF 2171C2 - Renako Amaori and XOR Game (hard version)

We are asked to simulate a two-player game on two arrays of integers, a and b, each of length n. Players take turns: Ajisai moves on odd-numbered turns, Mai moves on even-numbered turns. On a player’s turn, they can swap the current element a[i] with b[i] or leave it as is.

codeforcescompetitive-programmingbitmasksgamesgreedy
CF 2171B - Yuu Koito and Minimum Absolute Sum

We are given an array of nonnegative integers with some entries marked as -1, representing blanks. Our task is to replace each blank with a nonnegative integer to minimize the absolute value of the sum of differences between consecutive elements.

codeforcescompetitive-programmingmath
CF 2171A - Shizuku Hoshikawa and Farm Legs

Error in message stream

codeforcescompetitive-programmingbrute-forcemath
CF 2172N - New Kingdom

We are asked to construct an undirected simple connected graph on $n$ labeled vertices. The graph must satisfy three structural constraints at the same time. First, it must be a single connected component without multi-edges or self-loops.

codeforcescompetitive-programmingconstructive-algorithmsgraphsimplementation
CF 2172M - Maximum Distance To Port

We have a network of cities connected by roads, where each road is exactly one kilometer long. Each city produces one type of agricultural product, and city 1 is a central port.

codeforcescompetitive-programminggraphsshortest-paths
CF 2172L - Maximum Color Segment

We have a rope consisting of n units, each colored either red or black. The rope is represented as a string of length n where each character is R or B. We are allowed to perform up to m operations.

codeforcescompetitive-programmingdpimplementation
CF 2172I - Birthday

We are asked to cut a circular cake, represented as a circle centered at the origin with radius r, into two pieces using a single straight line. On the cake are n strawberries, each strictly within 0.9 times the radius from the center.

codeforcescompetitive-programminggeometry
CF 2172K - Kindergarten Homework

Error in message stream

codeforcescompetitive-programmingimplementationstrings
CF 2172J - Sliding Tiles

We are given an $n times n$ grid with tiles stacked in columns and vertical bars between adjacent columns. Each column $i$ starts with $ai$ tiles stacked from the bottom.

codeforcescompetitive-programmingdata-structuresdivide-and-conquerdsu
CF 2172H - Shuffling Cards with Problem Solver 68!

We are given a deck of $2^k$ cards represented as a string of lowercase letters. The deck can be rotated by moving the first $m$ cards to the end. After this optional rotation, the deck is riffle-shuffled $t$ times.

codeforcescompetitive-programminghashingstring-suffix-structuresstrings
CF 2172G - Gene Editor

We are asked to count how many gene sequences of a given length can be obtained from an initial sequence using a specific set of mutations. The sequences only contain A and B, and mutations allow inserting or deleting AA, BBB, or a special substring s.

codeforcescompetitive-programming
CF 2172E - Number Maze

We are given a very small “number universe” built from the digits of a base number. The base number is always one of three possibilities: a two-digit number, a three-digit number, or a four-digit number.

codeforcescompetitive-programmingimplementation
CF 2172F - Cluster Computing System

We are given a sequence of $n$ servers, each with a database protocol type $pi$, which is a positive integer. Initially, the servers are disconnected.

codeforcescompetitive-programminggraphsgreedymath
CF 2172D - Divisor Card Game

We are asked to model a probabilistic card game where each student starts with a subset of numbered cards and additional cards are revealed one by one.

codeforcescompetitive-programmingcombinatoricsdp
CF 2172B - Buses

Every bus moves along the road at the same speed x. Bus i starts at position si at time 0, moves to the right, and disappears once it reaches ti. A person starts at position p. They can walk at speed y, where y < x.

codeforcescompetitive-programminggreedysortings
CF 2172A - ASCII Art Contest

We are given the scores of three AI-powered creative assistants-Gemini, ChatGPT, and Claude-in an ASCII art contest. Each score is an integer between 80 and 100. The organizers want to decide if the judges' scores are consistent enough to announce a final result.

codeforcescompetitive-programmingimplementation
CF 2172C - Circles Are Far from Each Other

We are asked to place a sequence of circles on a single straight line of centers, while controlling how they may overlap and nest inside each other. Each circle has a fixed radius, and the radii are given in non-increasing order.

codeforcescompetitive-programmingbinary-searchgreedy
CF 2173F - Isla's Memory Thresholds

We are given a non-increasing array of positive integers, and we repeatedly process subsegments of it under a “capacity reset” rule. For each query, we pick a contiguous slice from index l to r. We then scan it left to right, maintaining a running sum.

codeforcescompetitive-programmingbinary-searchbrute-forcedata-structuresdivide-and-conquermath
CF 2173E - Shiro's Mirror Duel

We maintain a permutation of 1..n. A query chooses two indices x and y. The judge then flips a coin. Either positions (x,y) are swapped, or their mirrored positions (n-x+1, n-y+1) are swapped.

codeforcescompetitive-programmingconstructive-algorithmsgreedyinteractiveprobabilitiessortings
CF 2173D - Taiga's Carry Chains

Taiga is given a positive integer n and can perform exactly k moves. In each move, she chooses a power of two, 2^ℓ, and adds it to n. The score of each move is the number of binary carries that occur during the addition.

codeforcescompetitive-programmingbitmasksbrute-forcedpgreedymath
CF 2173A - Sleeping Through Classes

We are asked to plan our sleep schedule across a sequence of classes, each of which is either important or not. The day is represented as a binary string where '1' marks an important class and '0' a non-important one.

codeforcescompetitive-programminggreedyimplementation
CF 2173B - Niko's Tactical Cards

We process a sequence of turns. The current score starts at 0. At turn i, we are given two possible transformations: If we take the red card, the new score becomes k - k - a[i] If we take the blue card, the new score becomes k - b[i] - k We must choose exactly one…

codeforcescompetitive-programmingdpgreedymath
CF 2173C - Kanade's Perfect Multiples

We are given a multiset of numbers, all lying in the range from 1 to a large limit k. From this array we must construct a set B of distinct integers, also between 1 and k, but under two simultaneous constraints that interact in a non-trivial way.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedynumber-theory
CF 2174E2 - Game of Scientists (Version 2)

We are interacting with a hidden integer $x$ that is fixed for each game and always lies in the range $[1, c]$, where $c = 2 cdot 10^9$. Our goal is to determine this number using at most three queries. Each query chooses a base $b ge 2$.

codeforcescompetitive-programmingbinary-searchchinese-remainder-theoremdfs-and-similarinteractivemath
CF 2174F - Mosaic Tree

Working

codeforcescompetitive-programmingcombinatoricsdpfftmathtrees
CF 2174E1 - Game of Scientists (Version 1)

We are asked to guess a hidden number x between 1 and c by making queries about the sum of its digits in a chosen base. Each query specifies a base b (between 2 and c) and returns either the sum of digits of x in that base, or -1 if x is smaller than b.

codeforcescompetitive-programmingchinese-remainder-theoremconstructive-algorithmsinteractivemath
CF 2174D - Secret Message

We are asked to analyze a weighted undirected graph with n vertices and m edges. For each graph, we need to select n - 1 edges whose total weight is minimal, but these edges must not form a tree.

codeforcescompetitive-programmingdata-structuresdpgreedytrees
CF 2174C1 - Beautiful Patterns (Easy Version)

We are asked to compute the expected beauty of a linear mosaic of pebbles, where each pebble is painted in one of $m$ colors chosen independently and uniformly.

codeforcescompetitive-programmingcombinatoricsmathprobabilities
CF 2174C2 - Beautiful Patterns (Hard Version)

We are asked to calculate the expected beauty of a 1×n mosaic, where each cell is painted independently with one of m colors. Beauty is defined as the square of the number of palindromic subsegments. A subsegment is palindromic if it reads the same forwards and backwards.

codeforcescompetitive-programmingcombinatoricsmathprobabilities
CF 2174A - Needle in a Haystack

We are given two strings, s and t, both composed of lowercase English letters. The goal is to rearrange t in such a way that s appears at least once as a subsequence. Among all such valid rearrangements, we need to find the one that is lexicographically smallest.

codeforcescompetitive-programminggreedystringstwo-pointers
CF 2174B - Wishing Cards

We are building a sequence of numbers $b1, b2, ldots, bn$ representing how many wishing cards each friend will give, but each friend has an upper limit $ai$, and all $bi$ together cannot exceed a total budget $k$. Each $bi$ must stay within $0 le bi le ai$.

codeforcescompetitive-programmingdp
CF 2175A - Little Fairy's Painting

We are given a very long ribbon with $10^{18}$ cells, but only the first $n$ cells are already painted with specific colors. Each color is represented as an integer.

codeforcescompetitive-programmingimplementation
CF 2176B - Optimal Shifts

We are given a binary string consisting of 0s and 1s, with at least one 1. The goal is to transform this string into a string of all 1s. To achieve this, we can repeatedly choose a shift d and perform a cyclic right shift of the string by d.

codeforcescompetitive-programmingbitmasksgreedystrings
CF 2176F - Omega Numbers

We are given several arrays, and for each array we need to evaluate a sum over all unordered pairs of indices. For each pair of values $ai, aj$, we look at the number of distinct prime factors in their product and then raise that count to a fixed power $k$.

codeforcescompetitive-programmingbitmaskscombinatoricsdpmathnumber-theory
CF 2176E - Remove at the lowest cost

We are given an array of n elements. Each element has a value ai and a removal cost ci. The goal is to remove all elements except one, using a series of adjacent removals, paying the minimum total cost.

codeforcescompetitive-programmingdata-structuresdfs-and-similardpdsugreedyimplementationtrees
CF 2176D - Fibonacci Paths

We are given a directed graph with $n$ vertices, each labeled with a positive integer $av$, and $m$ edges. Our goal is to count all simple paths that include at least two vertices, where the sequence of numbers along the path forms a generalized Fibonacci sequence.

codeforcescompetitive-programmingdata-structuresdpgraphssortings
CF 2176C - Odd Process

We are given a multiset of coin values and asked to simulate a process that depends not only on which coins we pick, but also on the parity of the running sum inside a temporary bag.

codeforcescompetitive-programminggreedysortings
CF 2176A - Operations with Inversions

We are given an array of numbers, and we are allowed to repeatedly remove elements under a very specific condition. Each move chooses two indices $i < j$ such that the value at $i$ is strictly larger than the value at $j$, and then deletes the element at position $j$.

codeforcescompetitive-programminggreedyimplementationmath
CF 2178H - Create or Duplicate

Santa starts with exactly one present of each of three values, $a$, $b$, and $c$. Let the current counts of these present types be $xa$, $xb$, and $xc$. Initially all three counts are equal to $1$. Two operations are available.

codeforcescompetitive-programmingbitmasksgraphsnumber-theoryshortest-paths
CF 2178I - Numbers or Fireworks

We are given a set of cities on a Cartesian grid, each at distinct lattice points, and an integer $k$. The task is to compute a certain "explosiveness" measure over all proper subsets of cities.

codeforcescompetitive-programmingbitmaskscombinatoricsdpgraphs
CF 2178G - deCH OR Dations

We are given a circle with $2n$ points labeled from $1$ to $2n$. Santa draws $n$ chords connecting distinct pairs of points. Chords may intersect. For each prefix of chords $1$ through $ell$, we are asked whether the chords are tight-knit.

codeforcescompetitive-programmingbitmasksdata-structuresdphashingprobabilities
CF 2178E - Flatten or Concatenate

We are asked to determine the maximum element of a hidden array that was generated from an initial array containing a single power-of-two number.

codeforcescompetitive-programmingbinary-searchdivide-and-conquerinteractive
CF 2178F - Conquer or of Forest

We are given a rooted tree with vertices numbered from 1 to $n$. Each vertex is colored based on the size of its subtree: if the subtree size is even, the vertex is white; otherwise, it is black.

codeforcescompetitive-programmingcombinatoricsmathtrees
CF 2178D - Xmas or Hysteria

We are given a village of n elves, each with an initial health equal to its attack value. The elves engage in a Mass Hysteria event where each elf that has not attacked yet can choose another living elf to attack.

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementationmath
CF 2178B - Impost or Sus

We start with a string consisting only of s and u. We may repeatedly choose any position containing u and change it into s. We are not allowed to change an s back into u. The final string must satisfy two conditions. First, it must contain at least two occurrences of s.

codeforcescompetitive-programmingdpgreedyimplementationstrings
CF 2178C - First or Second

We have a line of children, each with an integer niceness value. Santa wants to assign each child to either a nice list or a naughty list, but he can only remove children from the front of the line.

codeforcescompetitive-programmingdpgreedyimplementation
CF 2178A - Yes or Yes

We are given a string consisting only of two symbols, where one behaves like a neutral value and the other behaves like an absorbing “true” value under an OR-like merge operation.

codeforcescompetitive-programminggreedystrings
CF 2179G - Blackslex and Penguin Migration

We are asked to reconstruct the positions of penguins on an $n times n$ grid after a migration, knowing only the Manhattan distances between pairs of penguins.

codeforcescompetitive-programmingbrute-forceinteractivemath
CF 2179H - Blackslex and Plants

We are given a line of plants indexed from 1 to n, all initially holding zero water. Each query specifies a segment $[l, r]$, and for every position $i$ in that segment we add a value that depends on how far $i$ is from $l$.

codeforcescompetitive-programmingbitmasksdata-structuresdpimplementationmath
CF 2179A - Blackslex and Password

We are asked to determine, for given integers $k$ and $x$, the smallest string length $n$ for which no valid password exists under specific rules. Each password uses only the first $k$ lowercase letters.

codeforcescompetitive-programmingmathstrings
CF 2179F - Blackslex and Another RGB Walking

We are asked to solve a two-part communication problem on a connected bipartite graph. In the first part, the agent colors vertices using three colors to encode directional information.

codeforcescompetitive-programmingcommunicationconstructive-algorithmsgraphsinteractivenumber-theorytrees
CF 2179E - Blackslex and Girls

We are asked to divide voters into districts according to a binary pattern while respecting minimum district sizes. Specifically, we have two parties, A and B, with a total of x and y voters, respectively.

codeforcescompetitive-programmingconstructive-algorithmsgeometrymath
CF 2179D - Blackslex and Penguin Civilization

We are asked to construct a permutation of all integers from $0$ to $2^n - 1$. The quality of a permutation is defined through a running process over prefixes: we maintain the bitwise AND of the prefix seen so far, and at each step we add the number of set bits in that AND…

codeforcescompetitive-programmingbitmasksconstructive-algorithmsgreedymath
CF 2179C - Blackslex and Number Theory

Working

codeforcescompetitive-programmingimplementationmathnumber-theorysortings
CF 2179B - Blackslex and Showering

We are given a sequence of floors that Blackslex needs to visit in order, and moving between floors takes time proportional to the absolute difference between consecutive floors. Blackslex can skip at most one floor in the sequence.

codeforcescompetitive-programmingdpgreedyimplementation
CF 2180H2 - Bug Is Feature (Conditional Version)

Each game starts from three numbers forming an arithmetic progression, so the state can always be described as $(a, a+d, a+2d)$ with $d 0$. The players repeatedly pick one coordinate and increase it, but the triple must remain an arithmetic progression after every move.

codeforcescompetitive-programminggames
CF 2180H1 - Bug Is Feature (Unconditional Version)

Working

codeforcescompetitive-programminggames
CF 2180F1 - Control Car (Easy Version)

The grid in this problem is best thought of as a lattice of junction points, not cells. Every intersection point on the grid is assigned one of four directions. From each such point, we draw a unit segment in its chosen direction.

codeforcescompetitive-programmingcombinatoricsdpprobabilities
CF 2180G - Balance

We maintain a sequence that starts empty and evolves through three kinds of operations. One operation deletes the middle element of the current sequence, where the middle is defined as the ceiling of half the current length.

codeforcescompetitive-programmingbitmaskscombinatoricsimplementationmath
CF 2180E - No Effect XOR

We have frogs on every integer position inside a contiguous segment $[l,r]$. After choosing a positive integer $x$, every frog moves from position $i$ to position $i oplus x$. XOR with a fixed value is a permutation of all non-negative integers.

codeforcescompetitive-programmingbitmasksdivide-and-conquerdpgreedymath
CF 2180F2 - Control Car (Hard Version)

We are asked to count the number of ways to assign directions to the corners of an $n times m$ grid so that a simulated car starting at the top-left cell eventually stops inside the grid.

codeforcescompetitive-programmingcombinatoricsdpmatricesprobabilities