brain

tamnd's digital brain — notes, problems, research

41650 notes

CF 1482C - Basic Diplomacy

We have m days. On each day, a specific set of friends is available, and we must choose exactly one available friend for that day. The assignment must satisfy a fairness condition. Let limit = ceil(m / 2). No friend may be chosen more than limit times across all days.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedyimplementation
CF 1482E - Skyline Photo

I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.

codeforcescompetitive-programmingdata-structuresdivide-and-conquerdp
CF 1482D - Playlist

We are asked to simulate a playlist with songs labeled by genres, where Arkady listens to songs in order, cycling back to the beginning when reaching the end.

codeforcescompetitive-programmingdata-structuresdsuimplementationshortest-paths
CF 1482B - Restore Modulo

I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.

codeforcescompetitive-programmingimplementationmath
CF 1482A - Prison Break

We are given a prison represented as a rectangular grid of size a × b. Each cell is isolated by walls on all four sides except the perimeter, which leads to freedom.

codeforcescompetitive-programmingmath
CF 1485F - Copy or Prefix Sum

I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.

codeforcescompetitive-programmingcombinatoricsdata-structuresdpsortings
CF 1485E - Move and Swap

We are given a rooted tree where every root-to-leaf path has the same length. Each non-root vertex has a value, while the root has no value attached. Two tokens start together at the root.

codeforcescompetitive-programmingdfs-and-similardpgreedytrees
CF 1485D - Multiples and Power Differences

We are given a two-dimensional grid of positive integers, where each cell contains a small number between 1 and 16.

codeforcescompetitive-programmingconstructive-algorithmsgraphsmathnumber-theory
CF 1485C - Floor and Mod

I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.

codeforcescompetitive-programmingbinary-searchbrute-forcemathnumber-theory
CF 1485B - Replace and Keep Sorted

We are given a strictly increasing array a of length n with elements from 1 to k, and multiple queries asking about subarrays. For each query, defined by indices l and r, we need to count how many arrays b exist that are "k-similar" to the subarray a[l..r].

codeforcescompetitive-programmingdpimplementationmath
CF 1485A - Add and Divide

We are asked to reduce a positive integer a to zero using two operations: divide a by another positive integer b using integer division, or increment b by one. Each operation counts as one step, and the goal is to minimize the total number of steps.

codeforcescompetitive-programmingbrute-forcegreedymathnumber-theory
CF 1486F - Pairs of Paths

We are given a tree with n vertices, meaning a connected graph with n-1 edges and no cycles. Along with the tree, we are given m paths, each specified by its two endpoints u and v.

codeforcescompetitive-programmingcombinatoricsdata-structuresdfs-and-similardptrees
CF 1486E - Paired Payment

I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.

codeforcescompetitive-programmingbinary-searchbrute-forceconstructive-algorithmsdpflowsgraphsshortest-paths
CF 1486D - Max Median

We are asked to find the largest possible median among all contiguous subarrays of a given array with length at least $k$.

codeforcescompetitive-programmingbinary-searchdata-structuresdp
CF 1486C2 - Guessing the Greatest (hard version)

We are given a hidden array of distinct values, and we can only interact with it through queries. Each query asks for a subsegment and returns the position of the second largest value inside that subsegment (but the index is reported in the original array).

codeforcescompetitive-programmingbinary-searchinteractive
CF 1486C1 - Guessing the Greatest (easy version)

I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.

codeforcescompetitive-programmingbinary-searchinteractive
CF 1486A - Shifting Stacks

We are given a sequence of stacks, each with some number of blocks. The task is to decide if we can redistribute blocks, moving them only to the right, to make the stack heights strictly increasing.

codeforcescompetitive-programminggreedyimplementation
CF 1486B - Eastern Exhibition

We are given several independent test cases. In each test case there is a set of points on a 2D grid, representing houses.

codeforcescompetitive-programmingbinary-searchgeometryshortest-pathssortings
CF 1487G - String Counting

I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.

codeforcescompetitive-programmingcombinatoricsdpfftmath
CF 1487C - Minimum Ties

We are asked to design the results of a round-robin football tournament so that every team ends up with the same number of points. There are $n$ teams, and each pair plays exactly once.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdfs-and-similargraphsgreedyimplementationmath
CF 1487F - Ones

We are asked to build a number equal to a given large integer using only building blocks that are themselves made entirely of digit ‘1’. Each building block is an integer like 1, 11, 111, 1111 and so on, and we are allowed to add or subtract these blocks.

codeforcescompetitive-programmingdpgreedyshortest-paths
CF 1487E - Cheap Dinner

We have four layers of items. The first layer contains first courses, the second layer contains second courses, the third layer contains drinks, and the fourth layer contains desserts. Every item has a cost. Between every pair of adjacent layers, some combinations are forbidden.

codeforcescompetitive-programmingbrute-forcedata-structuresgraphsgreedyimplementationsortingstwo-pointers
CF 1487D - Pythagorean Triples

We are looking for integer triples $(a, b, c)$ such that $1 le a le b le c le n$. Two conditions must hold at the same time.

codeforcescompetitive-programmingbinary-searchbrute-forcemathnumber-theory
CF 1487B - Cat Cycle

I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.

codeforcescompetitive-programmingmathnumber-theory
CF 1487A - Arena

We are given a collection of heroes, each with an initial strength or level. They fight pairwise, and whenever two heroes with different levels meet, the stronger one wins and grows stronger. If their levels are equal, the fight is a draw and nobody gains anything.

codeforcescompetitive-programmingimplementationsortings
CF 1488I - Demonic Invasion

The task describes a graph of islands connected by bidirectional bridges, where a disaster spreads outward from island 1 one layer per day.

codeforcescompetitive-programming*specialflows
CF 1488J - Flower Shop

We are managing a flower shop with n types of flowers, each with a fixed price. The shop starts empty, and a sequence of m operations is performed, either adding flowers to inventory, removing them, or asking for a count of distinct bouquets.

codeforcescompetitive-programming*specialdata-structuresfftmath
CF 1488H - Build From Suffixes

We are asked to construct strings of length $n$ using only the letters "a", "b", "c", and "d". For each position $i$ from $1$ to $n-1$, we are given a constraint $ai$.

codeforcescompetitive-programming*specialcombinatoricsdata-structures
CF 1488G - Painting Numbers

We are given a set of n distinct integers, each from 1 to n. The task is to assign each number a color, red or blue, such that exactly k numbers are red. The cost of a coloring is defined by counting all pairs (x, y) where x is blue, y is red, and y is divisible by x.

codeforcescompetitive-programming*specialdata-structuresgreedynumber-theory
CF 1488F - Dogecoin

Ann wants to maximize profit by mining and selling Dogecoin over a period of days. She earns exactly one coin per day she mines, and the price of a coin varies each day according to a given list.

codeforcescompetitive-programming*specialbinary-searchdata-structures
CF 1488E - Palindromic Doubles

I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.

codeforcescompetitive-programming*specialdata-structuresdp
CF 1488D - Problemsolving Marathon

We are asked to construct a non-decreasing sequence of integers over a fixed number of days, where each day represents how many problems Polycarp solves.

codeforcescompetitive-programming*specialbinary-searchgreedy
CF 1488B - RBS Deletion

We are given a string of parentheses that is guaranteed to form a regular bracket sequence. Our goal is to repeatedly remove parts of the string according to two operation types until the string becomes empty.

codeforcescompetitive-programming*specialgreedy
CF 1488C - Two Policemen

I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.

codeforcescompetitive-programming*specialbinary-searchbrute-forcemath
CF 1488A - From Zero To Y

We start from zero and want to reach a target value using two kinds of increments. One increment is very small and uniform: we can always add 1 to the current value.

codeforcescompetitive-programming*specialmath
CF 1490G - Old Floppy Drive

We have a circular array of integers, representing a disk in an old floppy drive. Each integer can be positive or negative.

codeforcescompetitive-programmingbinary-searchdata-structuresmath
CF 1490F - Equalize the Array

We are given an array of integers and are allowed to delete elements. After deletions, the remaining elements must satisfy a strong regularity condition: there must exist a value $C$ such that every number that appears in the final array appears exactly $C$ times, or not at all.

codeforcescompetitive-programmingbinary-searchdata-structuresgreedymathsortings
CF 1490E - Accidental Victory

I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.

codeforcescompetitive-programmingbinary-searchdata-structuresgreedy
CF 1490B - Balanced Remainders

We are given an array whose length is always divisible by three. For every number, only its remainder modulo 3 matters. A single move increases one array element by 1.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsmath
CF 1490D - Permutation Transformation

We are given a permutation of length $n$, which is an array containing every integer from 1 to $n$ exactly once. The task is to view this permutation as a way to construct a binary tree: the root is the largest element, the elements to the left of it form the left subtree…

codeforcescompetitive-programmingdfs-and-similardivide-and-conquerimplementation
CF 1490A - Dense Array

We are given several small arrays of positive integers. For each array, we are allowed to insert new numbers anywhere, including between existing elements.

codeforcescompetitive-programminggreedymath
CF 1491E - Fib-tree

We are given a tree with $n$ vertices, and we want to determine whether it is a Fib-tree. A Fib-tree is a tree whose size equals some Fibonacci number $Fk$, and it either consists of a single vertex or can be split into two smaller Fib-trees by removing exactly one edge.

codeforcescompetitive-programmingbrute-forcedfs-and-similardivide-and-conquernumber-theorytrees
CF 1491D - Zookeeper and The Infinite Zoo

We are asked to determine reachability in an infinite directed graph. Each vertex is a positive integer, and there is a directed edge from vertex $u$ to vertex $u+v$ if and only if the bitwise AND of $u$ and $v$ equals $v$.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsdpgreedymath
CF 1491A - K-th Largest Value

We are working with a binary array where every position contains either 0 or 1. The array changes over time through two types of operations. One operation flips a single position from 0 to 1 or from 1 to 0.

codeforcescompetitive-programmingbrute-forcegreedyimplementation
CF 1492E - Almost Fault-Tolerant Database

I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdfs-and-similargreedyimplementation
CF 1492D - Genius's Gambit

We are asked to construct two binary numbers, x and y, that have the same total number of ones and zeros: exactly b ones and a zeros each. Additionally, the difference x - y, interpreted in binary, must have exactly k ones.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsgreedymath
CF 1492C - Maximum width

We are given two strings, s of length n and t of length m, and we need to find a subsequence of s that exactly matches t. This subsequence is called beautiful if each character in t appears in order in s.

codeforcescompetitive-programmingbinary-searchdata-structuresdpgreedytwo-pointers
CF 1492B - Card Deck

We are given a deck of n distinct cards numbered from 1 to n, arranged from bottom to top. The task is to construct a new deck with the highest possible "order," which is calculated as a weighted sum of card values, where the top cards contribute more heavily.

codeforcescompetitive-programmingdata-structuresgreedymath
CF 1492A - Three swimmers

We have three swimmers who repeatedly swim across a pool and return, each at their own fixed period. The first swimmer takes a minutes to complete a round trip, the second b minutes, and the third c minutes.

codeforcescompetitive-programmingmath
CF 1493F - Enchanted Matrix

We are given an unknown $n times m$ matrix. The only information we initially know is its dimensions. The task is to count all pairs $(r, c)$ such that $r$ divides $n$, $c$ divides $m$, and if we partition the matrix into blocks of size $r times c$, all blocks are identical.

codeforcescompetitive-programmingbitmasksinteractivenumber-theory
CF 1493A - Anti-knapsack

We are asked to pick as many numbers as possible from the range 1 to $n$ without creating any subset that sums exactly to $k$. Each test case provides the values $n$ and $k$, and the output requires both the count of selected numbers and the list itself.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1493B - Planet Lapituletti

I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.

codeforcescompetitive-programmingbrute-forceimplementation
CF 1493E - Enormous XOR

We are given two non-negative integers, l and r, represented as binary strings of equal length. The task is to consider all contiguous ranges [x, y] where l ≤ x ≤ y ≤ r and compute the bitwise XOR of all integers in that range. Let g(x, y) denote this XOR.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsgreedymathstringstwo-pointers
CF 1493D - GCD of an Array

We are given an array of integers, and we need to handle a sequence of queries where each query multiplies a specific element of the array by a given factor. After each query, we must compute the greatest common divisor (GCD) of the entire array modulo $10^9+7$.

codeforcescompetitive-programmingbrute-forcedata-structureshashingimplementationmathnumber-theorysortingstwo-pointers
CF 1493C - K-beautiful Strings

We are asked to transform a given string into a "beautiful" string. A beautiful string of length $n$ with respect to a number $k$ is one where the number of occurrences of each letter is divisible by $k$.

codeforcescompetitive-programmingbinary-searchbrute-forceconstructive-algorithmsgreedystrings
CF 1494F - Delete The Edges

We are given a connected undirected graph with n vertices and m edges. The task is to remove all edges by walking along them. Initially, walking along an edge destroys it. At most once, we can activate a mode shift.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsdfs-and-similargraphsimplementation
CF 1494E - A-Z Graph

I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresgraphshashing
CF 1494D - Dogeforces

We are asked to reconstruct a company hierarchy from partial salary information. Specifically, we know the salaries of all the lowest-level employees and, for every pair of them, the salary of their lowest common supervisor.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresdfs-and-similardivide-and-conquerdsugreedysortingstrees
CF 1494C - 1D Sokoban

We are asked to maximize the number of boxes placed on special positions along a one-dimensional infinite number line. You start at position 0 and can move left or right, pushing boxes in the direction you move.

codeforcescompetitive-programmingbinary-searchdpgreedyimplementationtwo-pointers
CF 1494B - Berland Crossword

I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.

codeforcescompetitive-programmingbitmasksbrute-forcegreedyimplementation
CF 1494A - ABC String

We are given a string over three symbols: A, B, and C. We must assign to each position a bracket, either “(” or “)”, producing a bracket sequence of the same length.

codeforcescompetitive-programmingbitmasksbrute-forceimplementation
CF 1495E - Qingshan and Daniel

We are simulating a deterministic process on a circle of n robots. Each robot belongs to one of two teams and starts with some number of “actions” (cards).

codeforcescompetitive-programmingbrute-forcedata-structuresgreedyimplementation
CF 1495F - Squares

I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresdpgraphstrees
CF 1495A - Diamond Miner

We are given two sets of points in a plane. One set contains miners, and all of them lie strictly on the vertical axis, so each miner has coordinates of the form $(0, y)$.

codeforcescompetitive-programminggeometrygreedymathsortings
CF 1495C - Garden of the Sun

We are given a grid where some cells already contain 'X' and the remaining cells contain '.'. The original story describes lightning destroying sunflowers. From the graph perspective, the cells marked 'X' are already selected vertices. We are allowed to change any '.

codeforcescompetitive-programmingconstructive-algorithmsgraphs
CF 1495D - BFS Trees

We are asked to count, for every pair of vertices $i, j$ in an undirected connected graph, the number of spanning trees that simultaneously behave as BFS trees rooted at both $i$ and $j$. A BFS tree rooted at $s$ preserves the shortest distances from $s$ to every other vertex.

codeforcescompetitive-programmingcombinatoricsdfs-and-similargraphsmathshortest-pathstrees
CF 1495B - Let's Go Hiking

We are given a permutation laid out on a line of positions. Two players control two markers, one starting from an index chosen by Qingshan and the other chosen by Daniel after seeing the first choice.

codeforcescompetitive-programminggamesgreedy
CF 1496A - Split it!

We are given a string s and a number k. The task is to decide whether we can split s into 2k+1 consecutive parts with a very specific symmetry constraint. The first k+1 pieces are arbitrary non-empty strings a1, a2, ..., a(k+1).

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgreedystrings
CF 1496B - Max and Mex

We are given a multiset of distinct non-negative integers and need to simulate a process where, up to k times, we add the element (mex + max + 1) // 2 to the multiset. The mex of a set is the smallest non-negative integer not present, and max is the largest element.

codeforcescompetitive-programmingmath
CF 1497E2 - Square-Free Division (hard version)

We are given an array of positive integers, and we are asked to split it into the fewest possible contiguous segments such that within any segment, no pair of numbers multiplies to a perfect square.

codeforcescompetitive-programmingdata-structuresdpgreedymathnumber-theorytwo-pointers
CF 1497D - Genius

We are given a set of problems, each associated with a complexity, a tag, and a score. The complexity of the $i$-th problem is $ci = 2^i$, which grows exponentially. You start with IQ $0$ and can select any problem first.

codeforcescompetitive-programmingbitmasksdpgraphsnumber-theory
CF 1497A - Meximization

We are given an array of nonnegative integers and we want to reorder it to maximize the sum of MEX values over all prefixes. A prefix is any initial segment of the array. The MEX of a set is the smallest nonnegative integer not present in that set.

codeforcescompetitive-programmingbrute-forcedata-structuresgreedysortings
CF 1497E1 - Square-Free Division (easy version)

We are given several independent test cases. Each test case provides an array of positive integers, and we want to split this array into the smallest possible number of contiguous parts.

codeforcescompetitive-programmingdata-structuresdpgreedymathnumber-theorytwo-pointers
CF 1497C2 - k-LCM (hard version)

We are given two integers for each test case: a target sum and a required count of positive integers. The task is to split the sum into exactly that many positive parts. The additional constraint is not about the sum but about the least common multiple of all chosen parts.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1497C1 - k-LCM (easy version)

The problem asks for three positive integers that sum to a given number $n$ and whose least common multiple does not exceed half of $n$. The input gives a number of test cases, each specifying a single integer $n$.

codeforcescompetitive-programmingconstructive-algorithmsmath
CF 1497B - M-arrays

We are given a multiset of numbers and a modulus $m$. The task is to rearrange all numbers into as few sequences as possible, where each sequence must satisfy a local compatibility rule: whenever two consecutive elements appear in the same sequence, their sum must be divisible…

codeforcescompetitive-programmingconstructive-algorithmsgreedymath
CF 1498F - Christmas Game

We are asked to analyze a two-player game on a tree. Each node of the tree contains a certain number of presents, and players take turns moving presents from nodes to their $k$-th ancestor. The player who cannot make a move loses.

codeforcescompetitive-programmingbitmasksdata-structuresdfs-and-similardpgamesmathtrees
CF 1498D - Bananas in a Microwave

We are simulating a process that builds up a number starting from zero. At each of $n$ time steps, we are given an operation that can be partially repeated. Each operation comes with a limit $yi$, and we choose how many times to apply it, from zero up to that limit.

codeforcescompetitive-programmingdfs-and-similardpgraphsimplementation
CF 1498E - Two Houses

We are given a city with $n$ houses, where for each pair of houses there is exactly one directed road connecting them, either from the first to the second or vice versa. The input does not specify the directions of these roads.

codeforcescompetitive-programmingbrute-forcegraphsgreedyinteractivesortings
CF 1498B - Box Fitting

I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.

codeforcescompetitive-programmingbinary-searchbitmasksdata-structuresgreedy
CF 1498C - Planar Reflections

We have n planes arranged in a line. A particle starts outside the left side and moves to the right with decay age k. Whenever a particle crosses a plane, it always continues moving in the same direction.

codeforcescompetitive-programmingbrute-forcedata-structuresdp
CF 1498A - GCD Sum

The problem asks us to find, for a given integer $n$, the smallest integer $x$ greater than or equal to $n$ such that the greatest common divisor of $x$ and the sum of its digits is greater than one.

codeforcescompetitive-programmingbrute-forcemath
CF 1499A - Domino on Windowsill

We are given a board of size $2 times n$, where the first $k1$ cells of the top row and $k2$ cells of the bottom row are white, and the rest are black. We are also given a number of white dominoes $w$ and black dominoes $b$.

codeforcescompetitive-programmingcombinatoricsconstructive-algorithmsmath
CF 1500A - Going Home

We are given an array of integers representing a gift from a friend to Nastya. She wants to find four distinct indices in the array such that the sum of the elements at the first two indices equals the sum of the elements at the other two indices.

codeforcescompetitive-programmingbrute-forcehashingimplementationmath
CF 1500F - Cupboards Jumps

We are asked to reconstruct a sequence of cupboard heights based on partial information. Specifically, Krosh remembers the difference between the tallest and shortest cupboard for every consecutive triple.

codeforcescompetitive-programmingdp
CF 1500E - Subset Trick

The task revolves around reasoning about subset sums in a set of distinct positive integers. You are given an initial set $S$ and a series of operations that either add or remove elements.

codeforcescompetitive-programmingbinary-searchdata-structures
CF 1500C - Matrix Sorting

We are given two matrices, $A$ and $B$, of size $n times m$. Each matrix consists of integers between $1$ and $n$. The task is to determine whether we can transform matrix $A$ into matrix $B$ using a sequence of stable column sorts.

codeforcescompetitive-programmingbitmasksbrute-forceconstructive-algorithmsgreedytwo-pointers
CF 1500D - Tiles for Bathroom

We are given an $n times n$ grid representing a tile stand, where each cell contains a tile of a certain color. Kostya wants to know, for each possible subsquare size $k$, how many $k times k$ subsquares contain at most $q$ distinct colors.

codeforcescompetitive-programmingdata-structuressortingstwo-pointers
CF 1500B - Two chandeliers

We have two cyclic sequences of colors. The first chandelier repeats an array a of length n, and the second chandelier repeats an array b of length m. On day d, the first chandelier shows position (d - 1) mod n, while the second shows position (d - 1) mod m.

codeforcescompetitive-programmingbinary-searchbrute-forcechinese-remainder-theoremmathnumber-theory
CF 1501A - Alexey and Train

We are given the planned schedule of a train. For each station i, the schedule says the train is supposed to arrive at time a[i] and depart at time b[i]. Bad weather causes delays while travelling between stations. For each segment, we know an extra delay tm[i].

codeforcescompetitive-programmingimplementation
CF 1501B - Napoleon Cake

We build the cake layer by layer. After placing the i-th layer, we pour a[i] units of cream onto the top. That cream spreads downward and covers the top a[i] layers currently present. If there are fewer than a[i] layers, every existing layer becomes covered.

codeforcescompetitive-programmingdpimplementationsortings
CF 1503C - Travelling Salesman Problem

Thank you for the detailed input. I can see exactly what’s going wrong. The previous solution was too naive: it returned YES whenever there was at least one 1 in a.

codeforcescompetitive-programmingbinary-searchdata-structuresdpgreedyshortest-pathssortingstwo-pointers
CF 1503E - 2-Coloring

We are asked to count the number of "stupid colorings" for an $n times m$ grid, where each cell is either blue or yellow.

codeforcescompetitive-programmingcombinatoricsdpmath
CF 1503F - Balance the Cards

This problem is famous for having a very short implementation compared to the amount of structure hidden inside it. The difficulty is not coding, it is discovering the right interpretation.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresdivide-and-conquergeometrygraphsimplementation
CF 1503B - 3-Coloring

Alice and Bob are filling an $n times n$ grid. On every turn Alice first announces a color from ${1,2,3}$. Bob must then choose an empty cell and place a token of a different color. Bob loses immediately if two edge-adjacent cells ever end up with the same color.

codeforcescompetitive-programmingconstructive-algorithmsgamesinteractive
CF 1503D - Flip the Cards

Producing the complete editorial you requested would require a very long response, well beyond the amount that can fit in a single answer while maintaining the level of detail you specified.

codeforcescompetitive-programming2-satconstructive-algorithmsdata-structuresgreedysortingstwo-pointers
CF 1503A - Balance the Bits

We are asked to construct two sequences of brackets, a and b, of the same length as a given binary string s. Each position in s dictates a relationship between a and b: if s[i] is 1, then a[i] and b[i] must be equal, and if s[i] is 0, then a[i] and b[i] must be different.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1504B - Flip the Bits

The runtime error here is caused by the input format mismatch. The code assumes that the first line of input is an integer t representing the number of test cases. However, the input is: The first line is a string, not an integer.

codeforcescompetitive-programmingconstructive-algorithmsgreedyimplementationmath
CF 1504A - Déjà Vu

We are given several strings. For each string, we must insert exactly one character 'a' at some position. The new string must have length The input contains up to 10^4 test cases, and the sum of all string lengths is at most 3·10^5.

codeforcescompetitive-programmingconstructive-algorithmsstrings
CF 1505F - Math

The statement is given as a picture, but the task itself is extremely small. We receive a single integer a, whose value lies between -100 and 100.

codeforcescompetitive-programming*specialmath