brain

tamnd's digital brain — notes, problems, research

41641 notes

CF 104008E - Draw a triangle

We are given two distinct lattice points in the plane, and we must choose a third lattice point such that the triangle formed by all three points has strictly positive area while that area is as small as possible.

codeforcescompetitive-programming
CF 104008C - Array Concatenation

We start with an array and are allowed to repeatedly transform it exactly $m$ times. Each transformation replaces the current array with a new one formed in one of two ways: either we duplicate the array and append it to itself, or we take a reversed copy and place it in front…

codeforcescompetitive-programming
CF 104008A - Lily

We are given a one-dimensional strip of cells. Each cell is either empty or contains a lily, represented by a character string where L means a lily is already planted and . means the cell is empty soil.

codeforcescompetitive-programming
CF 104009I - Matrix

We are given a strictly convex polygon, and we imagine choosing a point inside it. For any fixed direction, we draw the maximal chord of the polygon that passes through this point and is parallel to that direction.

codeforcescompetitive-programming
CF 104009L - Transafagarasan

The problem statement for Codeforces 104009L - Transafagarasan is missing from your prompt, so I don’t have the actual rules, input format, or task definition needed to write a correct editorial.

codeforcescompetitive-programming
TAOCP 7.1.4 Exercise 77

Let $\mu_n(x_1,\ldots,x_{2n})$ be the Boolean function whose truth table encodes a monotone Boolean function in the sense of Section 7.

taocpmathematicsalgorithmsvolume-4math-hard
CF 104009K - Restricted Tree

I can’t write a correct editorial for this yet because the actual problem statement is missing. “Codeforces 104009K - Restricted Tree” is just a title here, but the key details are exactly what determine the solution: what “restricted” means, what operations or queries…

codeforcescompetitive-programming
CF 104009J - Metro

We are given a long row of seats indexed from 0 to N + 1, where the two boundary seats are permanently occupied. The interior seats start empty, but this configuration changes over time through events. There are two kinds of events.

codeforcescompetitive-programming
CF 104009G - Genetics

I don’t have the actual statement for Codeforces 104009G - Genetics, so I can’t reliably reconstruct the problem, constraints, or intended solution path without risking inventing details.

codeforcescompetitive-programming
CF 104009H - Lottery

I don’t have the statement for Codeforces 104009H - Lottery, so I can’t reliably reconstruct the problem, constraints, or solution without risking inventing details.

codeforcescompetitive-programming
CF 104009F - Engine

I can’t reliably write a correct Codeforces editorial for 104009F - Engine without the actual problem statement. Right now the prompt has empty sections for the statement/input/output, which usually means the content wasn’t included or was stripped.

codeforcescompetitive-programming
CF 104009D - Bipartite

We are given a sequence of edges of an undirected graph, presented in a fixed order. We are not allowed to reorder edges, but we can cut this sequence into consecutive blocks. Each block forms its own independent graph using exactly the edges inside it.

codeforcescompetitive-programming
CF 104009E - Coins

I’m missing the actual problem statement for Codeforces 104009E - Coins, so I can’t reliably reconstruct the intended solution, constraints, or edge cases.

codeforcescompetitive-programming
CF 104009A - Accountancy

The problem describes a very small “accounting system” where each record in the input represents a set of monetary transactions, and the task is to determine the final net balance after processing all of them in order.

codeforcescompetitive-programming
CF 104009B - AGaMe

I don’t have the actual problem statement for Codeforces 104009B - AGaMe in your message, and I can’t reliably reconstruct it from the title alone without risking inventing details.

codeforcescompetitive-programming
CF 104009C - Bar hopping

I can’t produce a correct full editorial for “Codeforces 104009C - Bar hopping” yet because the problem statement is missing from your prompt. Right now the input and output sections are empty, so there is no way to know what the algorithm is supposed to compute.

codeforcescompetitive-programming
CF 104010L - Shifting Roads

We are given a collection of straight road segments in the plane. Each road is just a line segment with real geometry: two endpoints in 2D, and the segment is the asphalt between them. From these segments we must choose exactly three.

codeforcescompetitive-programming
CF 104010K - Pick a Pair

We are given an even number of words, all of identical length, and we want to pair them up. A pair is considered valid for a chosen value $k$ if the two words share a common prefix of length at least $k$.

codeforcescompetitive-programming
CF 104010J - Square Running

We are dealing with a rectangular arena that contains a smaller rectangular grass field in its center. Around this grass field, there are multiple concentric rectangular “lanes”.

codeforcescompetitive-programming
CF 104010H - Pines

We are given a line of positions that will contain alternating objects: a pine, then a lamp, then a pine, then a lamp, and so on. Since there are n lamps, there are n + 1 pines placed at the pine positions.

codeforcescompetitive-programming
CF 104010I - Circus Performance

We are given a collection of acrobats, each described by two attributes: a height-like value $ai$ and a weight-like value $bi$. We need to arrange all acrobats in a line, producing a permutation of indices.

codeforcescompetitive-programming
CF 104010G - The Length of the Sequence

We are given a target value $S$, and we must construct a contiguous interval of integers $[l, r]$, where $0 le l le r le 10^{18}$. If we write all integers from $l$ to $r$ in decimal form and concatenate them without separators, we obtain a single long string.

codeforcescompetitive-programming
CF 104010F - Lazy to Win

We are given a sequence of problem scores laid out in a fixed order. Each position has a positive value, and solving a problem yields that many points.

codeforcescompetitive-programming
CF 104010E - Just Like Pickle

We are standing at position zero on an infinite number line and want to reach some target coordinate $x$, which can be positive, negative, or zero. In one move, we choose a non-negative integer $k$, and then jump either left or right by exactly $2^k$.

codeforcescompetitive-programming
CF 104010A - Rain Diary

We are given a strictly convex polygon, and we imagine choosing a point inside it. For any fixed direction, we draw the maximal chord of the polygon that passes through this point and is parallel to that direction.

codeforcescompetitive-programming
CF 104010B - Magnetic Games

We are given an $n times m$ grid. One unknown cell contains a magnet. Every other cell contains a compass that points toward the magnet using one of 8 discrete directions: four axis-aligned directions and four diagonals.

codeforcescompetitive-programming
CF 104010D - The Tree

We are working with an infinite complete binary tree where every node has a left child and a right child. Initially, every node is uncolored. We receive two kinds of operations.

codeforcescompetitive-programming
TAOCP 7.1.4 Exercise 76

Let $U={0,1,\dots,n-1}$ and let each subset $S\subseteq U$ be identified with its characteristic integer $s=\sum_{e\in S}2^e$.

taocpmathematicsalgorithmsvolume-4math-medium
CF 104010C - Campfire Riddle

We are given a group of $n$ people. Each person $i$ has an associated number $di$, which represents how many friends that person has. The friendship rule is unusually rigid: two distinct people $i$ and $j$ are friends if and only if they have the same value $di = dj$.

codeforcescompetitive-programming
CF 104011G - Grand Center

We are given a strictly convex polygon, and we imagine choosing a point inside it. For any fixed direction, we draw the maximal chord of the polygon that passes through this point and is parallel to that direction.

codeforcescompetitive-programming
CF 104011M - Multithreaded Program

We are given several threads, and each thread contains a fixed sequence of assignment operations. Each operation writes a value to a named variable, and these writes happen in a strict order inside each thread.

codeforcescompetitive-programming
CF 104011N - New White-Black Tree

We are given a collection of independent trees. For each tree, every vertex comes with two numbers that describe how many incident edges of two different colors it should have in a valid reconstruction.

codeforcescompetitive-programming
CF 104011L - Letters Q and F

We are given a final picture of an $n times m$ grid consisting of white and black cells. This picture was produced by repeatedly stamping two fixed, non-rotated, non-mirrored patterns, called the letters Q and F.

codeforcescompetitive-programming
CF 104011K - Kaleidoscopic Route

We are given an undirected graph with weighted edges, where the weight is called colorfulness. The task is to travel from city 1 to city n, but not just by any path.

codeforcescompetitive-programming
CF 104011J - Journey in Fog

We are working on a one-dimensional street of fixed length $L$. One endpoint is Julia’s home at position $0$, and the other endpoint is Jane’s home at position $L$.

codeforcescompetitive-programming
CF 104011I - Imprecise Permutation Sort

We are given a hidden permutation of size $n$, where the values are a rearrangement of the integers from 1 to $n$. We cannot see the array directly. Instead, we can interact with it using two operations.

codeforcescompetitive-programming
CF 104011F - First to Solve

Each contestant has a personal list of problems they are capable of solving. For contestant $i$, problem $j$ has a nonzero time $a{i,j}$ if it is solvable, otherwise it is unusable.

codeforcescompetitive-programming
CF 104011H - Halfway There

We are given a number $n$, and we consider all integers from $1$ up to $n-1$. From this range, we keep only those numbers that share no common divisor with $n$ except 1. In other words, we filter the range by a coprimality condition relative to $n$.

codeforcescompetitive-programming
CF 104011E - Extreme Problem

We are working on a small fixed integer grid of size 21 by 21, where both coordinates range from minus 10 to 10. The task is not to compute anything dynamically but to construct a function over this grid and output it in reverse Polish notation using a restricted set of…

codeforcescompetitive-programming
CF 104011B - Boris and Berta

Exercise 225 constructs a ZDD whose paths encode all simple paths between two fixed vertices $s$ and $t$. The construction proceeds by a controlled search over partial edge sets: each ZDD node represents a state of the partial path, and each decision corresponds to including…

codeforcescompetitive-programming
CF 104011D - Day Streak

We are given a sequence of timestamps when problems were solved, already sorted in increasing order. Each timestamp represents a moment in continuous time, but the platform converts these moments into discrete “days” using a floor division after shifting time by a chosen…

codeforcescompetitive-programming
CF 104011A - Anno Domini 2022

We are given two points on a simplified timeline where every year is labeled either in the AD system or in the BC system. Each input line describes a year like “AD 2022” or “5508 BC”.

codeforcescompetitive-programming
CF 104011C - Clean Up!

We are given a collection of file names, all consisting of lowercase letters. Charlie wants to delete all of them using a restricted version of the rm command.

codeforcescompetitive-programming
CF 104012K - K-Shaped Figures

Exercise 225 constructs a ZDD whose paths encode all simple paths between two fixed vertices $s$ and $t$. The construction proceeds by a controlled search over partial edge sets: each ZDD node represents a state of the partial path, and each decision corresponds to including…

codeforcescompetitive-programming
CF 104012N - New Time

We are given two moments in a day written on a 24-hour digital clock. The first is the current displayed time, and the second is the target correct time.

codeforcescompetitive-programming
CF 104012M - Mex and Cards

We are given a multiset of cards where each card has a value between 0 and n − 1. At any moment, we know how many copies exist of each value. We are allowed to partition all cards into any number of non-empty groups.

codeforcescompetitive-programming
CF 104012L - Limited Swaps

We are given a permutation of numbers from 1 to n, initially arranged on a line of cubes. We are also given a target permutation of the same numbers.

codeforcescompetitive-programming
CF 104012J - Joking?

We are asked to construct a set of dice for up to five players. Each player gets one die, and all dice have the same number of sides, denoted by k, with k at most 120.

codeforcescompetitive-programming
TAOCP 7.1.4 Exercise 75

Let $x_1\ldots x_{2^n}$ be a truth table of length $2^n$.

taocpmathematicsalgorithmsvolume-4math-medium
CF 104012I - IQ Game

We have a circular arrangement of $n$ sectors, each sector initially holding at most one envelope. After several rounds, only $k$ envelopes remain, and their exact positions on the circle are known in clockwise order.

codeforcescompetitive-programming
CF 104012G - Greatest Common Divisor

We are given an upper bound $n$, and we consider all ordered pairs $(x, y)$ where both values lie between 1 and $n$. For each such pair, we run a modified version of the Euclidean algorithm.

codeforcescompetitive-programming
CF 104012H - Hidden Digits

We are given a sequence of digits of length $n$. For each position $i$, we impose a condition on the number $x + i$: when written in decimal, it must contain the digit $di$ somewhere in its representation.

codeforcescompetitive-programming
CF 104012F - Focusing on Costs

We start with a calculator that only stores a single real number and repeatedly applies one of six unary functions to it: sine, cosine, tangent and their inverses. The initial value is fixed at zero.

codeforcescompetitive-programming
CF 104012E - Easily Distinguishable Triangles

We are given an $n times n$ grid where each cell is either already painted black, already white, or empty. Empty cells are candidates where Eva may optionally draw a special black triangle.

codeforcescompetitive-programming
CF 104012D - Dice Grid

We are given an $n times n$ grid where each cell has a fixed color value. A cube starts at the top-left cell and must be moved to the bottom-right cell.

codeforcescompetitive-programming
CF 104012B - Bricks in the Wall

We are given a rectangular grid representing a wall, where each cell is either blocked or free. On the free cells we are allowed to place up to two additional rectangular bricks.

codeforcescompetitive-programming
CF 104012C - Computer Network

We are given a set of computers, each equipped with a single outgoing wire. If a computer uses its wire directly, sending one bit takes a fixed amount of time equal to its own delay value. In addition to these wires, there is a hub with a limited number of ports.

codeforcescompetitive-programming
CF 104012A - Absolutely Flat

We are given four numbers representing the current lengths of the legs of a table. The table is stable only when all four legs end up having exactly the same length.

codeforcescompetitive-programming
CF 104013N - Nunchucks Shop

We are working with a set of binary “sticks”, each stick being a sequence of length n where every position is either quartz or onyx. A finished product, a nunchuck, is formed by choosing two sticks and joining them end to end.

codeforcescompetitive-programming
CF 104013L - Lost Permutation

We are given an unknown permutation π on n elements, but we are not allowed to see it directly. Instead, we can feed the system any permutation f, and we receive back a transformed permutation g defined by conjugation through π, meaning that every value is relabeled by π…

codeforcescompetitive-programming
CF 104013M - Mind the Gap

We are given a set of distinct integers representing cards held by different players. There is also an initial pile that starts with a single card of value 0.

codeforcescompetitive-programming
CF 104013I - Integer Square

We are given a single year in the range from 1995 to 2019. Each year has a fixed contest winner (or a pair of winners in one special case), and the task is to output exactly the winner string corresponding to the given year.

codeforcescompetitive-programming
CF 104013J - Joint Password Storage

We are given several passwords, each a short string of length at most 50 made of digits and English letters. For every password, we must construct a collection of strings, all of the same length as the password, such that if we take the bitwise XOR of ASCII codes column by…

codeforcescompetitive-programming
CF 104013K - Keys and Locks Boolean Logic

We are given a boolean formula built from variables a through h and the operators not, and, and or with standard precedence rules. The formula defines which subsets of variables are considered valid. Each variable corresponds to a band member who may or may not be present.

codeforcescompetitive-programming
CF 104013H - Heroes of Coin Flipping

We are dealing with a complete knockout tournament with $2^k$ participants, where every match is a fair coin flip between two players.

codeforcescompetitive-programming
CF 104013G - Grammar Path

We are given two separate structures that must interact: a context-free grammar in Chomsky Normal Form and a directed graph whose edges are labeled by lowercase letters.

codeforcescompetitive-programming
CF 104013A - Archivist

We are given a single year in the range from 1995 to 2019. Each year has a fixed contest winner (or a pair of winners in one special case), and the task is to output exactly the winner string corresponding to the given year.

codeforcescompetitive-programming
CF 104013E - Easy Compare-and-Set

We are given a collection of operations on a single integer variable that starts with value c. Each operation has the form “if the current value equals a, then replace it with b”, otherwise it does nothing.

codeforcescompetitive-programming
CF 104013F - Futures Market Trends

We are given a sequence of daily oil prices and we want to inspect every contiguous subarray of length at least three. For each such segment, we look at the sequence of day-to-day differences inside it.

codeforcescompetitive-programming
CF 104013C - Corrupted Sort

We are given a hidden array of length $n$, containing a permutation of numbers from $1$ to $n$. We cannot see the array directly. Our only way to interact with it is to pick two positions $i < j$ and ask the judge to compare the values at those positions.

codeforcescompetitive-programming
CF 104013D - Display

We are given a library of pixel fonts where each printable character is represented as a fixed bitmap of size $w times h$. Each bitmap is a grid of and ., where means the pixel is lit and . means it is dark.

codeforcescompetitive-programming
CF 104013B - Bicycle

A cyclist is choosing between two monthly bike rental plans, and we need to compute the total cost of each plan over a fixed month. Each day, the cyclist uses the bike for a total of T minutes.

codeforcescompetitive-programming
CF 104014G - Сапёр 1D

We are given a mine placement on a strip of length $N$, where each position in the top row either contains a mine or is empty.

codeforcescompetitive-programming
TAOCP 7.1.4 Exercise 74

Let $f(x_1,\dots,x_n)$ be a monotone Boolean function.

taocpmathematicsalgorithmsvolume-4math-medium
CF 104014J - My Grandfather

We are given a directed acyclic structure with $N$ glades (nodes) and $M$ directed paths (edges). Each path has two fixed weights: the number of mushrooms and the number of berries collected when traversing it. Importantly, these values do not change across days.

codeforcescompetitive-programming
CF 104014K - Old Barabarian Rap

I don’t have the actual problem statement for Codeforces 104014K - Old Barabarian Rap in your message (it’s empty in the prompt), so I can’t reliably reconstruct the intended task or produce a correct editorial.

codeforcescompetitive-programming
CF 104014H - Match of the Millennium

I can’t reliably write an editorial for “Codeforces 104014H - Match of the Millennium” because the actual problem statement (and even the contest archive context) isn’t included in your prompt.

codeforcescompetitive-programming
CF 104014I - Piecewise Linear Functions

I can write the full editorial in the required format, but I’m missing the actual problem statement for Codeforces 104014I - Piecewise Linear Functions.

codeforcescompetitive-programming
CF 104014F - Туристы, достопримечательности и телескопы

There is a row of cities, each city containing a known number of attractions. In every city, a telescope is installed. Each telescope has a non-negative integer power.

codeforcescompetitive-programming
CF 104014D - На планете Иворил...

We are given a text consisting of multiple words, and each word is supposed to follow a simple phonetic rule of a fictional language. A word is valid if it is either a “noun” or a “verb” under this language definition.

codeforcescompetitive-programming
CF 104014A - Большой удой

Let $F$ denote the family of 5757 SGB words represented on variables $a1,dots,z5$ as in (131), and let the associated ZDD be constructed in the standard ordered way with variables processed in lexicographic order.

codeforcescompetitive-programming
CF 104014E - История версий

We are given a final version number of a project, written as a positive integer $N$. The project evolves month by month according to a fixed rule: if the current version has $k$ digits, then after one month it increases by the number consisting of $k$ ones.

codeforcescompetitive-programming
CF 104014C - Вендомат

We are given a vending machine that contains a collection of snack packs, each with a name and a price expressed in rubles and kopeks. The buyer also has a fixed amount of money, also expressed in the same format.

codeforcescompetitive-programming
CF 104014B - Сделай 100

We are given a fixed sequence of digits 1 2 3 4 0 in that order, and we are allowed to insert arithmetic operators between them, optionally group parts using parentheses, and optionally concatenate adjacent digits to form multi-digit numbers.

codeforcescompetitive-programming
CF 104015M - The Sum of Good Numbers

We are given a long digit string s that was formed by taking an array of positive integers and concatenating them without separators. Each original array element is a positive integer that does not contain the digit zero.

codeforcescompetitive-programming
CF 104015I - Tree Painting

Let $F$ denote the family of 5757 SGB words represented on variables $a1,dots,z5$ as in (131), and let the associated ZDD be constructed in the standard ordered way with variables processed in lexicographic order.

codeforcescompetitive-programming
CF 104015L - RBS

We are given several strings, each consisting only of opening and closing brackets. We are allowed to reorder these strings arbitrarily and then concatenate them into one long sequence. While scanning this final sequence from left to right, every position defines a prefix.

codeforcescompetitive-programming
CF 104015K - Staircases

We are working on an $n times m$ grid where each cell is either usable or blocked, and the grid changes over time as we toggle individual cells. After each toggle, we must report how many distinct “staircase paths” exist in the current grid.

codeforcescompetitive-programming
TAOCP 7.1.4 Exercise 73

We are given a virtual address representation p = \pi(p)2^e + \sigma(p), \quad \pi(p)=p \gg e,\quad \sigma(p)=p \bmod 2^e, and we must show that a BDD node stored at address $p$ does not need to store...

taocpmathematicsalgorithmsvolume-4medium
CF 104015H - Colored Balls

We are given three piles of balls, each pile having a different color. In one move, we pick two balls of different colors, remove both, and replace them with a single ball of the third color.

codeforcescompetitive-programming
CF 104015J - Replacing Letters

We are given a string of lowercase English letters. The goal is to transform it into a string where characters never decrease when read from left to right, meaning each character is at least as large in alphabetical order as the previous one.

codeforcescompetitive-programming
CF 104015F - Coconuts

We are given a sequence of piles of coconuts, where each pile has some integer size. We are allowed to choose a single positive integer base value $x$, and then we only collect coconuts from those piles whose size is an exact positive power of $x$, meaning values of the form…

codeforcescompetitive-programming
CF 104015G - Training Session

We are given a collection of problems, where each problem is described by two attributes: a topic label and a difficulty value.

codeforcescompetitive-programming
CF 104015C - Groups

Let $F$ denote the family of 5757 SGB words represented on variables $a1,dots,z5$ as in (131), and let the associated ZDD be constructed in the standard ordered way with variables processed in lexicographic order.

codeforcescompetitive-programming
CF 104015E - Delete Two Elements

We are given an array of integers and we first compute its average value, which is the total sum divided by the number of elements. This average is not necessarily an integer, but it is a fixed rational value determined by the full array.

codeforcescompetitive-programming
CF 104015D - Rectangle Restoration

We are dealing with a rectangle with unknown side lengths, say $a$ and $b$, both strictly positive real numbers. We are not given the rectangle directly. Instead, we are told two aggregated pieces of information about its sides.

codeforcescompetitive-programming
CF 104015B - Computer Game

We are given a very small game board with exactly two rows and $n$ columns. A player starts at the top-left cell and wants to reach the bottom-right cell. Some cells are blocked by traps, and stepping onto a trap immediately makes the path invalid.

codeforcescompetitive-programming
CF 104015A - Candies

We are given a fixed number of candies and a school split into two groups of students: boys and girls. The principal must choose a positive integer amount of candies for each boy, and a different positive integer amount for each girl.

codeforcescompetitive-programming
CF 104017K - Gastronomic Event

I don’t have the actual statement for Codeforces 104017K - Gastronomic Event in your prompt (the input/output sections are empty), so I can’t reliably reconstruct the problem or produce a correct editorial without guessing.

codeforcescompetitive-programming
CF 104017G - Round Table

Let $F$ denote the family of 5757 SGB words represented on variables $a1,dots,z5$ as in (131), and let the associated ZDD be constructed in the standard ordered way with variables processed in lexicographic order.

codeforcescompetitive-programming