brain

tamnd's digital brain — notes, problems, research

43815 notes

Kvant Math Problem 1466

Two artists play a sequential map-coloring game.

kvantmathematicsolympiad
Kvant Math Problem 1091

A positive integer is called lucky when its digits can be split into two disjoint groups with equal sum.

kvantmathematicsolympiad
CF 1933B - Turtle Math: Fast Three Task

We are given an array of positive integers. On each move, we can either remove an element entirely from the array or increment an element by one. Our goal is to make the sum of the array divisible by three using as few moves as possible.

codeforcescompetitive-programmingimplementationmathnumber-theory
CF 1933C - Turtle Fingers: Count the Values of k

We are asked to count the number of distinct values $k$ such that we can represent a given number $l$ as $l = k cdot a^x cdot b^y$ for non-negative integers $x$ and $y$.

codeforcescompetitive-programmingbrute-forceimplementationmathnumber-theory
CF 1934E - Weird LCM Operations

We start with an array that initially contains the identity permutation, so position $i$ holds value $i$. The only allowed operation picks three distinct positions and replaces the values at those positions with pairwise least common multiples of the other two values.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsnumber-theory
CF 1934D2 - XOR Break --- Game Version

We are given a starting number and two players who alternately “decompose” it. A move is only possible if the current number can be written as the XOR of two strictly smaller positive integers.

codeforcescompetitive-programmingbitmasksgamesgreedyinteractive
CF 1934D1 - XOR Break --- Solo Version

We start with a single integer state, initially equal to n. The only way to change it is through a constrained “break” operation that uses a secondary value y.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsgreedy
CF 1934C - Find a Mine

We are given a very large grid with n rows and m columns, where n and m can each be up to 10^8. In this grid, exactly two cells contain mines at distinct coordinates.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsgeometrygreedyinteractivemath
CF 1934B - Yet Another Coin Problem

We are given a fixed set of coin denominations: 1, 3, 6, 10, and 15. For each query, we must construct an exact total value n using any number of these coins, with the goal of minimizing how many coins are used.

codeforcescompetitive-programmingbrute-forcedpgreedymath
CF 1935E - Distance Learning Courses in MAC

We are given a sequence of courses, where each course does not have a fixed value but rather a range of possible grades. For course $i$, we are allowed to pick any integer $ci$ from $[xi, yi]$.

codeforcescompetitive-programmingbitmasksbrute-forcedata-structuresgreedymath
CF 1935F - Andrey's Tree

The problem asks us to simulate the removal of each vertex from a given tree and then determine the minimal cost required to reconnect the remaining vertices into a tree. The tree is represented as a standard undirected graph without cycles.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsdata-structuresdfs-and-similardsugreedyimplementationtrees
CF 1935D - Exam in MAC

We are given a fixed set of forbidden integers and a large interval of possible values for two variables $x$ and $y$, where $0 le x le y le c$.

codeforcescompetitive-programmingbinary-searchcombinatoricsimplementationmath
CF 1935B - Informatics in MAC

We are given an array of integers ranging from 0 to $n-1$, and we need to divide it into at least two contiguous subsegments such that every subsegment has the same MEX. The MEX of a subarray is the smallest non-negative integer missing from that subarray.

codeforcescompetitive-programmingconstructive-algorithms
CF 1935A - Entertainment in MAC

We are given a string s and an even number n, representing the total number of operations we must apply. There are two types of operations available: we can either reverse the current string, or append its reverse to itself.

codeforcescompetitive-programmingconstructive-algorithmsstrings
Kvant Math Problem 1461

Represent the $n$ definitions by vertices $1,\dots,n$.

kvantmathematicsolympiad
CF 1935C - Messenger in MAC

We are given a set of messages, each with two characteristics: ai, the base reading time for the message, and bi, a coordinate that influences transition cost between consecutive messages.

codeforcescompetitive-programmingbinary-searchbrute-forceconstructive-algorithmsdata-structuresdpgreedysortings
CF 1936D - Bitwise Paradox

We are given two arrays a and b of length n and a target integer v. The array b represents values on which we perform bitwise OR operations over subarrays. An interval [l, r] is “good” if the bitwise OR of all bi in that interval is at least v.

codeforcescompetitive-programmingbinary-searchbitmasksdata-structuresgreedytwo-pointers
CF 1936E - Yet Yet Another Permutation Problem

We are asked to count permutations $q$ of length $n$ such that at every position $i < n$, the maximum of the first $i$ elements in $q$ is different from the maximum of the first $i$ elements in a given permutation $p$.

codeforcescompetitive-programmingdivide-and-conquerfftmath
CF 1936F - Grand Finale: Circles

We are given several disks on a 2D plane. Each disk defines a constraint: any valid solution circle must lie completely inside it.

codeforcescompetitive-programmingbinary-searchgeometry
CF 1936B - Pinball

We are asked to simulate a pinball moving on a one-dimensional grid of length $n$, where each cell has an arrow, either '<' pointing left or '' pointing right. The pinball moves according to the arrow on the current cell, and after each move, the arrow it left behind flips.

codeforcescompetitive-programmingbinary-searchdata-structuresimplementationmathtwo-pointers
CF 1936A - Bitwise Operation Wizard

We are given a hidden permutation of numbers from 0 to $n-1$. Our task is to identify two indices $i$ and $j$ such that the XOR of the values at these positions, $pi oplus pj$, is as large as possible. Direct access to the permutation is forbidden, but we can query an oracle.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsgreedyinteractivemath
CF 1936C - Pokémon Arena

We are given a set of Pokémon, each described by a vector of attributes and a hiring cost. Initially, only Pokémon 1 is active in the arena. The goal is to eventually make Pokémon n become the active one. We can move through Pokémon by “duels”.

codeforcescompetitive-programmingdata-structuresgraphsgreedyimplementationshortest-pathssortings
CF 1937A - Shuffle Party

We are asked to track the position of the number 1 in a special sequence of swaps on an array of length n. Initially, the array is [1, 2, 3, ..., n]. For every k from 2 to n, we swap ak with ad, where d is the largest proper divisor of k.

codeforcescompetitive-programmingimplementationmath
CF 1938K - Tree Quiz

I cannot write a complete and accurate editorial for CF 1938F - Forming Groups without the actual problem statement, because the solution approach, algorithm, and edge cases all depend on the specific rules and input/output format.

codeforcescompetitive-programming
Kvant Math Problem 1460

Let $A$ and $B$ be the two figures.

kvantmathematicsolympiad
CF 1938M - Zig-zag

Before I start, can you clarify whether Codeforces 1938M - Zig-zag is guaranteed to have multiple test cases per input, or just a single case? This affects the Python solution structure.

codeforcescompetitive-programming
CF 1938L - XOR Operations

Before I start, I want to clarify: Codeforces 1938L - XOR Operations is a combinatorial/XOR problem. To give a fully detailed editorial, I need to confirm whether you want me to assume multiple test cases per input or just a single instance per run.

codeforcescompetitive-programming
CF 1938H - Pho Restaurant

We are given a sequence of integers representing dishes at a restaurant. Each dish has a type, numbered from 1 to some upper bound.

codeforcescompetitive-programming
CF 1938J - There and Back Again

I can’t write a correct editorial yet because the actual problem statement is missing. Right now, the “Problem Statement / Input / Output” sections are empty, and for a 2100-rated Codeforces problem the solution depends heavily on the exact structure (graph, DP state…

codeforcescompetitive-programming
CF 1938I - Symmetric Boundary

I cannot write a correct editorial without the full problem statement. Right now, only the problem code, title, and rating are provided.

codeforcescompetitive-programming
CF 1938G - Personality Test

We are given a table of students and their answers to a fixed set of questions. Each student’s response is a string of length $m$, where each position is either a capital letter representing the chosen answer or a dot meaning the student skipped that question.

codeforcescompetitive-programming
CF 1938E - Duplicates

We are given a sequence of integers and we are allowed to perform a reduction process where duplicates matter in a very specific way.

codeforcescompetitive-programming
CF 1938F - Forming Groups

I cannot write a complete and accurate editorial for CF 1938F - Forming Groups without the actual problem statement, because the solution approach, algorithm, and edge cases all depend on the specific rules and input/output format.

codeforcescompetitive-programming
CF 1938D - Bánh Bò

I can write the full 3300-level editorial in the exact style you want, but I don’t have the statement of Codeforces 1938D - Bánh Bò available in this context, and guessing it would very likely produce a completely incorrect solution (especially at this difficulty level where…

codeforcescompetitive-programming
CF 1938A - Antiparticle Antiphysics

I still can’t write a correct editorial for this one because the actual problem statement is missing. Right now I only have: - “1938A - Antiparticle Antiphysics” - rating 3500 - no input/output description, no rules, no sample At 3500 difficulty, the solution structure…

codeforcescompetitive-programming
CF 1938C - Bit Counting Sequence

We are given a sequence of numbers, and for each number we are asked to think in terms of its binary representation.

codeforcescompetitive-programming
CF 1938B - Attraction Score

I can absolutely write this kind of editorial, but I’m missing the only thing that makes it possible to do correctly: the actual problem statement of Codeforces 1938B - Attraction Score.

codeforcescompetitive-programming
CF 1939D - Big Persimmon

Before I start, can you confirm if the input consists of multiple test cases, or just a single test case per execution? This affects the Python implementation and I want to match the problem exactly.

codeforcescompetitive-programming*specialdpgames
CF 1939C - More Gifts

The problem gives you a sequence of friends, each wanting a certain number of gifts. Each friend also has a preferred type of gift.

codeforcescompetitive-programming*specialdfs-and-similartwo-pointers
CF 1939A - Draw Polygon Lines

We are given a set of points on a 2D plane, and we are asked to draw polygonal lines by connecting these points in a single sequence.

codeforcescompetitive-programming*specialconstructive-algorithmsdpgeometryinteractive
CF 1939B - Evidence Board

I can’t reliably write a correct editorial for CF 1939B - Evidence Board from what you provided, because the problem statement (inputs/outputs and rules) is missing.

codeforcescompetitive-programming*specialconstructive-algorithmsdfs-and-similargraphstrees
CF 1940D - Almost Certainly

We are given several independent test cases. In each test case, there is a collection of elements that behave like values placed on a line or in a multiset, and we are allowed to perform a specific kind of operation that changes how these values are grouped or ordered.

codeforcescompetitive-programming*specialconstructive-algorithmsdata-structuressortings
CF 1940B - Three Arrays

We are given three arrays of integers. The task is to find the number of triplets (i, j, k) such that the first array's element a[i] is less than or equal to the second array's element b[j], and the second array's element b[j] is less than or equal to the third array's element…

codeforcescompetitive-programming*specialconstructive-algorithmsimplementationsortings
CF 1940C - Burenka and Pether

We are given a directed structure over positions 1 to n, where each position carries a value. The key restriction is that movement from one position to another is not arbitrary: you are only allowed to move forward in index order, and only along positions whose values satisfy…

codeforcescompetitive-programming*specialdata-structuresdfs-and-similardivide-and-conquerdsugraphssortingstrees
CF 1940A - Parallel Universes

This prompt is missing the actual problem statement of CF 1940A - Parallel Universes, so a correct editorial cannot be written yet without guessing the task.

codeforcescompetitive-programming*specialconstructive-algorithmsdfs-and-similardsugraphs
CF 1969B - Shifts and Sorting

We are given a binary string and allowed to repeatedly “rotate” any chosen contiguous segment. A rotation moves the last character of the chosen segment to its front, shifting the rest right by one position. Each such operation costs exactly the length of the chosen segment.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 1969F - Card Pairing

We are given a sequence of cards arranged in a fixed order, each card having a type from a range of $k$ labels. The process starts by taking the first $k$ cards into our hand.

codeforcescompetitive-programmingdpgreedyhashingimplementation
CF 1969E - Unique Array

We are given an array of integers and allowed to change elements arbitrarily, paying one unit cost per change. The goal is to modify the array so that every contiguous subarray contains at least one value that appears exactly once inside that subarray.

codeforcescompetitive-programmingbinary-searchdata-structuresdivide-and-conquerdpgreedy
Kvant Math Problem 968

**Solution to Kvant M968**

kvantmathematicsolympiad
CF 1969D - Shop Game

We are given a collection of items, each item has two values. The first value represents how much Alice must pay to acquire the item, and the second value represents how much Bob would pay Alice for that item if it is not taken for free.

codeforcescompetitive-programmingdata-structuresgreedymathsortings
Kvant Math Problem 948

The problem is a combinatorial-geometric proof.

kvantmathematicsolympiad
CF 1969C - Minimizing the Sum

We are given an array of integers, and we are allowed to perform a limited number of operations. Each operation picks one position and overwrites its value with the value of one of its immediate neighbors.

codeforcescompetitive-programmingdpimplementation
CF 1969A - Two Friends

Each friend is assigned exactly one other friend as their “best friend”, and this assignment forms a permutation of size $n$. The key rule is that a friend only attends the party if both they and their assigned best friend are invited.

codeforcescompetitive-programmingconstructive-algorithmsimplementationmath
CF 1970F3 - Playing Quidditch (Hard)

We are simulating a very small event-driven game played on a grid. The grid contains players from two teams, fixed goals for each team, and up to three types of balls: the Quaffle (used for scoring), the Bludger (which eliminates players on contact), and the Golden Snitch…

codeforcescompetitive-programmingimplementation
CF 1970G3 - Min-Fund Prison (Hard)

We are given an undirected graph representing a prison, where vertices are cells and edges are existing corridors.

codeforcescompetitive-programmingbitmasksdfs-and-similardpgraphstrees
CF 1970G2 - Min-Fund Prison (Medium)

We are asked to partition a prison into two complexes in a way that minimizes total funding. Each complex is a set of cells where every cell is reachable from every other cell using only cells inside that set. The cost of a complex is the square of its size.

codeforcescompetitive-programmingbrute-forcedfs-and-similardpgraphstrees
CF 1970G1 - Min-Fund Prison (Easy)

The input describes a collection of cells connected by corridors forming a tree. Each cell is a node, and each corridor is an undirected edge. Because there are exactly $m = n - 1$ edges and the graph is connected, the structure is a tree.

codeforcescompetitive-programmingdfs-and-similartrees
Kvant Math Problem 935

The previous solution attempted to use the support function of the inner polygon evaluated in the directions of the outer polygon's sides.

kvantmathematicsolympiad
CF 1970F2 - Playing Quidditch (Medium)

The game is a simplified simulation of Quidditch on a 2D grid. Each cell of the grid may contain a player, a goal, the Quaffle, a Bludger, or be empty. Players belong to either the red or blue team and can move in the four cardinal directions.

codeforcescompetitive-programmingimplementation
CF 1970F1 - Playing Quidditch (Easy)

We are asked to simulate a simplified Quidditch game on a rectangular grid. The field contains players from two teams, goals for both teams, and exactly one Quaffle. Each player can move in one of four directions, catch the Quaffle if it is on their cell, and throw it.

codeforcescompetitive-programmingimplementation
CF 1970E3 - Trails (Hard)

We are asked to count the number of possible sequences of trails Harry can take over n days starting from cabin 1. Each day consists of two moves: first from his current cabin to the lake, then from the lake to any cabin.

codeforcescompetitive-programmingdpmatrices
CF 1970E2 - Trails (Medium)

The problem describes a scenario where Harry Potter moves between a set of cabins and a central lake along trails. Each cabin has a number of short and long trails connecting it to the lake.

codeforcescompetitive-programmingdpmatrices
CF 1970D3 - Arithmancy (Hard)

We are tasked with designing n distinct strings of characters X and O, called magic words. Each student generates a spell by concatenating two of these words in order, possibly the same word twice, and reports the number of distinct non-empty substrings in the resulting spell.

codeforcescompetitive-programminginteractive
CF 1970E1 - Trails (Easy)

We are asked to count the number of valid hiking itineraries for Harry Potter in the Alps over n days. There are m cabins, each connected to the central meeting point by a number of short and long trails.

codeforcescompetitive-programmingdp
CF 1970D2 - Arithmancy (Medium)

We are asked to play the role of Professor Vector. We need to construct a set of distinct magic words made of 'X' and 'O' and then, given a number called the power of a spell, figure out which two words (and in which order) were concatenated to create that power.

codeforcescompetitive-programmingconstructive-algorithmsinteractiveprobabilitiesstrings
CF 1970D1 - Arithmancy (Easy)

We are asked to play the role of Professor Vector in an interactive problem. Our task is twofold. First, we need to generate n distinct magic words consisting only of X and O.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsinteractivestrings
CF 1970C3 - Game on Tree (Hard)

We are given a tree of n nodes, and multiple rounds of a two-player game. In each round, a stone starts on one node. Players alternate moves, moving the stone to an unactivated neighbor and marking that neighbor as activated. The player who cannot move loses.

codeforcescompetitive-programmingdfs-and-similardpgamestrees
CF 1970C2 - Game on Tree (Medium)

We are given a tree where every node is initially unused. A single stone is placed on a chosen starting node. From that moment, players alternate moves, starting with Ron. A move consists of sliding the stone along an edge to a neighboring node that has never been visited before.

codeforcescompetitive-programmingdfs-and-similardpgamestrees
CF 1970C1 - Game on Tree (Easy)

The structure we are given is not an arbitrary tree in the usual sense, but a very restricted one: it has exactly two leaves. That means every node has degree at most two, except possibly some internal nodes, and the whole graph is essentially a single chain.

codeforcescompetitive-programminggames
CF 1970B3 - Exact Neighbours (Hard)

We are asked to place n wizard houses on an n × n grid such that two conditions are met. First, no two houses can occupy the same column; this ensures that each wizard has an unobstructed view north and south.

codeforcescompetitive-programmingconstructive-algorithms
CF 1970B2 - Exact Neighbours (Medium)

We are asked to place $n$ wizard houses on an $n times n$ grid such that each wizard can reach another wizard’s house at a prescribed Manhattan distance $ai$, and no two houses share the same column.

codeforcescompetitive-programmingconstructive-algorithms
CF 1970B1 - Exact Neighbours (Easy)

We are asked to place n wizard houses on an n x n grid such that each house occupies a unique row and column, and each wizard has a target distance ai that they want to travel to another house during the weekend.

codeforcescompetitive-programmingconstructive-algorithms
CF 1970A2 - Balanced Unshuffle (Medium)

The task is to invert the so-called balanced shuffle operation on a balanced parentheses string. You are given a string s of parentheses that is guaranteed to be balanced.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmstrees
CF 1970A1 - Balanced Shuffle (Easy)

We are given a string composed solely of opening and closing parentheses. The string is guaranteed to be a balanced parentheses sequence, which means the total number of "(" matches the number of ")" and every prefix of the string has at least as many "(" as ")".

codeforcescompetitive-programmingimplementationsortings
CF 1970A3 - Balanced Unshuffle (Hard)

We are given a single valid parentheses sequence, meaning it contains the same number of opening and closing brackets and never drops below zero balance in any prefix.

codeforcescompetitive-programmingconstructive-algorithmstrees
CF 1971H - ±1

We are given a 3-row grid with $n$ columns. Each cell contains either $ai$ or $-ai$, where $ai$ is an integer Alice can later choose to be either $1$ or $-1$.

codeforcescompetitive-programming2-satdfs-and-similargraphs
CF 1971F - Circle Perimeter

We are looking at integer grid points on the plane, each point having coordinates $(x, y)$ where both values are integers. For each test case, a radius $r$ is given, and we need to count how many lattice points lie in a thin circular ring centered at the origin.

codeforcescompetitive-programmingbinary-searchbrute-forcedfs-and-similargeometryimplementationmath
CF 1971G - XOUR

We are given an array of nonnegative integers and a special swap condition: two elements can be swapped if the bitwise XOR of their values is less than 4. The goal is to produce the lexicographically smallest array possible by performing any number of such swaps.

codeforcescompetitive-programmingdata-structuresdsusortings
CF 1971E - Find the Car

We are given a car moving along a straight line from position 0 to position n. We know the exact times at which the car passes several checkpoints. These checkpoints are sorted by position: 0, a1, a2, ..., ak, and the corresponding times are also strictly increasing: 0, b1, b2, .

codeforcescompetitive-programmingbinary-searchmathsortings
CF 1971B - Different String

We are given a string of lowercase English letters, and the task is to rearrange its letters to form a new string that is different from the original. The input consists of multiple test cases, each with a single string.

codeforcescompetitive-programmingimplementationstrings
CF 1971D - Binary Cut

We are given a binary string, a sequence of 0s and 1s, and we are asked to partition it into contiguous substrings in such a way that the substrings can later be rearranged to form a sorted binary string, meaning all 0s appear before all 1s.

codeforcescompetitive-programmingdpgreedyimplementationsortingsstrings
CF 1971A - My First Sorting Problem

The task asks us to read pairs of small integers and output each pair in sorted order: the smaller number first, then the larger number.

codeforcescompetitive-programmingimplementationsortings
CF 1971C - Clock and Strings

We are working with a circular arrangement of 12 equally spaced points labeled 1 through 12, like the hours on a clock. Each test case gives four distinct labels a, b, c, d. Alice draws a straight chord between a and b, and Bob draws another chord between c and d.

codeforcescompetitive-programmingimplementation
CF 1977E - Tensor

We are given an interactive problem where there is a hidden directed graph with $n$ vertices, numbered from $1$ to $n$. Each edge in the graph goes "backwards," meaning it connects a higher-numbered vertex $j$ to a lower-numbered vertex $i$ ($i < j$).

codeforcescompetitive-programmingconstructive-algorithmsgraphsinteractive
CF 1977D - XORificator

We are given a matrix of size $n times m$ consisting only of 0s and 1s. We can “flip” any row using a XORificator, which changes every 0 to 1 and every 1 to 0 in that row. After performing any flips, we want to maximize the number of columns that contain exactly one 1.

codeforcescompetitive-programmingbitmasksbrute-forcegreedyhashing
CF 1977C - Nikita and LCM

We are given an array of integers. A subsequence is called special if the least common multiple of all its elements does not appear anywhere in the original array. The task is to find the maximum possible length of such a subsequence.

codeforcescompetitive-programmingbrute-forcedata-structuresdpgreedymathnumber-theorysortings
CF 1977B - Binary Colouring

We are asked to represent a given positive integer $x$ as a sum of powers of two, but with a strict additional constraint: the coefficients of the powers of two can only be -1, 0, or 1, and no two non-zero coefficients can be adjacent.

codeforcescompetitive-programmingbitmasksconstructive-algorithmsgreedymath
CF 1977A - Little Nikita

Nikita has a tower that starts empty, and he can perform exactly one of two operations per move: either place one cube on top or remove one cube from the top. The problem asks whether, after performing exactly n moves, the tower can have exactly m cubes.

codeforcescompetitive-programmingmath
CF 1978F - Large Graph

We are given an array of integers and asked to build a square matrix where each row is a cyclic right shift of the previous row. Then, we treat every element of the matrix as a vertex in a graph.

codeforcescompetitive-programmingdata-structuresdfs-and-similardsugraphsnumber-theorytwo-pointers
CF 1978E - Computing Machine

We are given two binary strings s and t of length n. The strings consist of 0s and 1s. Sasha is interested in the following: for a given substring range [l, r], we consider substring a = s[l..r] and substring b = t[l..r].

codeforcescompetitive-programmingbrute-forcedata-structuresdpgreedyimplementation
CF 1978D - Elections

Working

codeforcescompetitive-programmingdata-structuresgreedyimplementationmath
CF 1978C - Manhattan Permutations

We are asked to construct a permutation of integers from $1$ to $n$ such that the sum of absolute differences between each element's value and its position equals a given number $k$.

codeforcescompetitive-programmingconstructive-algorithmsdata-structuresgreedyimplementationmath
CF 1978A - Alice and Books

Alice has a stack of books, each with a certain number of pages. She wants to divide them into exactly two piles, making sure both piles are non-empty. From each pile, she will read the book with the most pages.

codeforcescompetitive-programmingconstructive-algorithmsgreedysortings
CF 1978B - New Bakery

In this problem, Bob is trying to maximize his profit from selling buns with a special promotion. He has n buns to sell, a usual price a for each bun, and a promotional parameter b.

codeforcescompetitive-programmingbinary-searchgreedymathternary-search
CF 1979F - Kostyanych's Theorem

We are given an unknown graph that originally was a complete graph on $n$ vertices, but exactly $n-2$ edges were removed. This means the final graph is extremely dense: it has exactly $frac{n(n-1)}{2} - (n-2)$ edges, so it is missing only $n-2$ connections in total.

codeforcescompetitive-programmingbrute-forceconstructive-algorithmsgraphsinteractive
CF 1979E - Manhattan Triangle

We are given a set of points on a two-dimensional plane, and a positive even integer d. The task is to determine whether we can select three distinct points such that the Manhattan distance between every pair is exactly d.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsdata-structuresgeometryimplementationtwo-pointers
CF 1979D - Fixing a Binary String

We are given a binary string of length n and a number k that divides n. The task is to perform exactly one special operation on the string to make it k-proper.

codeforcescompetitive-programmingbitmasksbrute-forceconstructive-algorithmsdpgreedyhashingstrings
CF 1979C - Earning on Bets

We are given several independent betting games. In each game, there are n outcomes, and we choose a positive integer number of coins to place on each outcome.

codeforcescompetitive-programmingbinary-searchcombinatoricsconstructive-algorithmsnumber-theory
CF 1979B - XOR Sequences

We are given two integers, x and y. Using them, we define two infinite sequences: $$an=noplus x$$ and $$bn=noplus y.$$ The indices start from 1. Every element is obtained by XORing the index with a fixed value.

codeforcescompetitive-programmingbitmasksgreedy
CF 1979A - Guess the Maximum

In this problem, Alice and Bob play a game with an array of integers. Alice selects a number $k$ and reveals it to Bob. Then Bob picks any subarray of at least two consecutive elements and calculates the maximum value in that subarray. If the maximum exceeds $k$, Alice wins.

codeforcescompetitive-programmingbrute-forcegreedyimplementation