brain

tamnd's digital brain — notes, problems, research

43815 notes

CF 102868H - Yellow

The problem asks us to stop Yellow from travelling through a grid by closing as few doors as possible. The grid contains walls that are always blocked, hallways that are always open, and doors that can be either open or closed.

codeforcescompetitive-programming
CF 102868G - White

The task asks us to answer many range queries. For each interval of possible inputs, we need find the number x inside that interval whose generated id code is largest. The generated code is x phi(x), where phi(x) is obtained by replacing every digit of x with its complement to 9.

codeforcescompetitive-programming
CF 102868E - Orange

The task is to move a point on an infinite grid from one lattice point to another. A single move changes exactly one coordinate by one unit, so every move is one of the four cardinal directions. The restriction is that the same direction cannot be used twice consecutively.

codeforcescompetitive-programming
CF 102868A - Black

The reactor shows a hidden sequence of button presses. The sequence has length N, uses only the nine buttons A through I, and never presses the same button twice. During several repetitions, some flashes are missed, so each observation is only a subsequence of the real sequence.

codeforcescompetitive-programming
CF 102870B - Bracelets of Orz Pandas

We need count how much money can be earned by selling unique Orz Panda Bracelets of every possible length up to m. A bracelet has a circular arrangement of n positions around its side, with each position occupied by one rectangular block.

codeforcescompetitive-programming
CF 102870C - Closestools of Orz Pandas

We need simulate a row of n closestools, where pandas enter and leave over time. An entering panda chooses an empty closestool whose minimum distance to all currently occupied closestools is as large as possible.

codeforcescompetitive-programming
CF 102870J - Junction of Orz Pandas

I can write the editorial, but the problem statement content in your prompt is empty, so I do not have the full specification needed to produce a correct explanation, proof, algorithm, code, examples, and tests.

codeforcescompetitive-programming
CF 102870I - Irregular Shape of Orz Pandas

The problem gives the vertices of an irregular polygon in the order they appear around its boundary. Each vertex has integer coordinates. The task is to calculate the exact area enclosed by this polygon and print the result.

codeforcescompetitive-programming
CF 102870H - Hamming Code and Orz Pandas

The transmitted message is a Hamming encoded block. A block has 2^k bits, and the bits are indexed from 0 to 2^k - 1. The received block may have been modified by changing at most two bits.

codeforcescompetitive-programming
CF 102870G - Gery's Problem and Orz Pandas

The tree describes a network of vertices connected by edges. For a query containing two vertices u and v, we temporarily choose every vertex r as the root of the tree. In that rooted tree, we find the lowest common ancestor of u and v.

codeforcescompetitive-programming
CF 102870F - Flow of Orz Pandas

The problem models a water network with villages connected by bidirectional pipes. Each village consumes a fixed amount of water every day, and some villages contain unlimited water sources.

codeforcescompetitive-programming
CF 102870E - Encryption of Orz Pandas

The task is to simulate a special encryption process on an array. The array contains values that can be viewed bit by bit. One encryption round replaces every position with the XOR of all elements from the beginning of the array up to that position.

codeforcescompetitive-programming
CF 102870D - Data Structure Master and Orz Pandas

We have a rooted tree with node 1 as the root. During an infinite sequence of random operations, one node is chosen uniformly each time.

codeforcescompetitive-programming
CF 102870A - Accordion Artist And Orz Pandas

The task describes a row of adjacent buildings, where each building has a height and a width. Because the buildings touch each other, their front faces form one continuous skyline.

codeforcescompetitive-programming
CF 102873A - Catching the Impostor

The problem describes a group of n players where exactly one player is the hidden impostor. We are given observations of players who were seen completing tasks. A player who appears in the observation list cannot be the impostor.

codeforcescompetitive-programming
CF 102873F - Game on Grid

Error in message stream

codeforcescompetitive-programming
CF 102873B - Rabbit Game

We have a row of carrots, where each carrot has a size. Two rabbits begin at opposite ends of this row. A rabbit can continue moving inward only while every next carrot it reaches is at least as large as the carrot it just ate.

codeforcescompetitive-programming
CF 102873E - Count Substrings

We are given a string s containing lowercase English letters and another string t of length two. The goal is to count how many pairs of positions (L, R) produce a substring s[L..R] that contains t somewhere inside it as a contiguous part.

codeforcescompetitive-programming
CF 102873D - Sanda's Job

Hmm...something seems to have gone wrong.

codeforcescompetitive-programming
CF 102873C - Similar Arrays

Hmm...something seems to have gone wrong.

codeforcescompetitive-programming
CF 102875L - Leave from CPC

We have a collection of members. Each member can retire at one of the contests they participate in. A member has either one possible contest or two possible contests.

codeforcescompetitive-programming
CF 102875J - Just Multiplicative Inverse

The function in this problem is a recursive way to compute a modular inverse, but the requested value is not the inverse itself.

codeforcescompetitive-programming
CF 102875I - Intersections

The city is a rectangular grid of intersections. Every intersection has its own traffic signal pattern: it allows movement along rows for part of a repeating cycle and movement along columns for the rest. Moving along a road also consumes a fixed amount of time.

codeforcescompetitive-programming
CF 102875H - Happy Morse Code

The problem describes a small Morse-like cipher. A cipher book contains several letters, each assigned a unique binary string of length at most five.

codeforcescompetitive-programming
CF 102875E - Eliminate the Virus

We have an undirected network of at most 16 nodes. Every node starts infected. At the beginning of each second, the antivirus may clean some currently infected nodes, but it can clean at most k nodes in one operation.

codeforcescompetitive-programming
CF 102878C - Simple AniPop

We have a ring of objects, each with a positive value. A move removes one object that still exists. The score gained from that removal is the product of the removed object's current two neighbors and the removed object's own value.

codeforcescompetitive-programming
CF 102878A - IQ difference

The task is to find the single number in a list whose parity is different from all the others. The input describes a sequence of integers. Every value except one is either even or odd, while the remaining value has the opposite parity.

codeforcescompetitive-programming
CF 102878M - Camouflage

The camouflage is represented as a rectangular grid of black and white pixels. White pixels form separate spots, and a spot can be repainted only when it is completely surrounded by black pixels in the four orthogonal directions.

codeforcescompetitive-programming
CF 102878L - Long Long Wanna Buy

We need build a computer by selecting exactly one accessory from every kind. Each accessory has a price and a service life.

codeforcescompetitive-programming
CF 102878K - Number Puzzle

I can write the editorial, but the requested format is not compatible with this problem as stated. Codeforces 102878K - Number Puzzle is an interactive problem.

codeforcescompetitive-programming
CF 102878J - Teacher Long and Machine Learning

The task is to recover the coefficients of a fourth-degree polynomial from five observed values. The five observations correspond to the polynomial evaluated at x = 1, 2, 3, 4, and 5, but every observation may contain an error of at most one.

codeforcescompetitive-programming
CF 102878I - Nobody Knows Better Than Me

I can write the full editorial, but the problem statement section is empty and I could not reliably recover the actual statement for Codeforces 102878I - “Nobody Knows Better Than Me” from the information available.

codeforcescompetitive-programming
CF 102878H - Treasure Hunt

The game is played on a directed acyclic graph. A single turn starts at node 1 and finishes when we reach node n. Every time a turn visits a node, that node contributes its reward to the total score. Each directed edge can only be used a limited number of times across all turns.

codeforcescompetitive-programming
CF 102878G - Nim plus

The game is played with a single pile containing n paper balls. Long Long and Mao Mao do not share the same legal moves. Long Long has a set of numbers he is allowed to remove, and Mao Mao has another set.

codeforcescompetitive-programming
CF 102878F - SVM

Part 2 will contain: I’ll continue with Part 1 in the next message.

codeforcescompetitive-programming
CF 102878E - Eigen Substring

We are given a lowercase string s. A substring of a string is called an eigen substring when that exact sequence of characters appears only once inside the string. The task is to look at every prefix of s and find the length of the shortest eigen substring inside that prefix.

codeforcescompetitive-programming
CF 102878D - Life Game

The task simulates a cellular automaton on a rectangular grid. Each position contains either a living creature () or an empty cell (.). At every moment, every cell updates at the same time.

codeforcescompetitive-programming
CF 102878B - Residue Problem

The problem asks us to answer many independent queries. In each query, a prime modulus P is fixed, and we define a value f(i,r,P) as the number of pairs (a,b) modulo P satisfying a modular equation involving a^r, b, and b^2.

codeforcescompetitive-programming
CF 102881G - Baby Ehab and a GCD Problem, Of Course

We have an initially empty collection of numbered cubes. Each operation adds every cube whose number lies in a given inclusive interval [l, r]. After each operation, we need to print the greatest common divisor of all numbers that have appeared in the collection so far.

codeforcescompetitive-programming
CF 102881B - Anany in the Army

The problem gives three sticks with integer lengths and allows us to choose exactly one stick and extend it by any amount up to k. The new three lengths must form a triangle, and the task is to find the largest possible area of that triangle.

codeforcescompetitive-programming
CF 102881N - Baby !Ehab

I can write the editorial, but the requested format is very long and includes a full solution, test harness, and traces.

codeforcescompetitive-programming
CF 102881M - Baby Ehab's Whining Chance

The sequence starts with all integers from 1 up to n. Each integer is replaced by the sum of its decimal digits, and the task is to find the length of the longest subsequence whose digit sums are strictly increasing.

codeforcescompetitive-programming
CF 102881L - The Expected Square

The problem describes a random process on all possible n bit numbers. We begin with a value x = 0. On every move, a random n bit number r is chosen uniformly and XORed into x. The game stops the first time x becomes zero again after the initial state.

codeforcescompetitive-programming
CF 102881K - Plants Watering

The problem describes a row of plants. Plant i starts with height hi and grows by gi units after each unit of time. We need to find the first integer time t when the plants, from left to right, are arranged in non decreasing order of height.

codeforcescompetitive-programming
CF 102881J - ABC

The task is to rearrange a string made from the letters a, b, and c using swaps of two positions. There is a special restriction: the string contains at most one b. After rearrangement, every neighboring pair must either contain the same letter or contain the unique b.

codeforcescompetitive-programming
CF 102881I - Ehab The Baby Learned Graphs

We are given a connected undirected graph with up to 100 vertices. The input is its adjacency matrix, so every pair of vertices tells us whether the original graph contains that edge. We have to express this graph as the XOR of several trees on the same set of vertices.

codeforcescompetitive-programming
CF 102881H - Shortest Array

We are given a connected weighted graph and an array of positive values s. The task is to find the smallest indexed vertex x such that the value written at every vertex is exactly the shortest distance from x to that vertex.

codeforcescompetitive-programming
CF 102881A - Officer Anany Collecting String Subsequences

We need find the shortest contiguous part of a string that can be walked through from left to right and used to collect the letters A, B, C, ..., Z in order. The chosen part does not need to equal the alphabet directly.

codeforcescompetitive-programming
CF 102881F - Geometry?

I need the actual problem details to write a correct editorial, because the statement section is empty and “102881F - Geometry?” is not enough to identify the required algorithm reliably. Waiting for your answer

codeforcescompetitive-programming
CF 102881E - Baby Ehab's X(OR)

We have an array of positive integers. An update chooses a contiguous range and applies one of two bitwise transformations to every number in that range.

codeforcescompetitive-programming
CF 102881D - YSYS

We have a country represented by an undirected graph. A person starts at an unknown city on day 0 and can either remain in the same city or move through one road per day. The only information available is a chronological list of bomb explosions.

codeforcescompetitive-programming
CF 102881C - Sort?

I can write the editorial, but the problem statement you provided is missing the actual sorting algorithm image. For Codeforces 102881C, the entire solution depends on the pseudocode inside that image, because the task is to simulate the final state of the array after sort(1)…

codeforcescompetitive-programming
CF 102889E - 群体狂乱

The battlefield contains at most six minions. Each minion has an attack value and a health value. During one cast of the spell, every minion receives exactly one opportunity to act, but the order of those opportunities is random.

codeforcescompetitive-programming
CF 102889A - 极巨团体战

The battle team contains n Pokémon, and each player chooses one of two possible Pokémon. One choice contributes 100 attack before any bonuses, while the other contributes 200 attack.

codeforcescompetitive-programming
CF 102889H - 宝可梦与分支进化

There are n Pokémon species. Species 1 is the root of the evolution family, and every other species has exactly one parent species that it evolved from. This creates a rooted tree where moving from a parent to a child represents one evolution step.

codeforcescompetitive-programming
CF 102889G - 林克与宝箱咒语

I can write the editorial and solution, but the requested format is much larger than a single response can fit reliably here. I’ll provide it in parts so the full editorial remains complete rather than cutting off the algorithm, proof, code, and tests midway.

codeforcescompetitive-programming
CF 102889B - 国士无双

The hand contains 14 tiles because the player has already drawn a tile and has not discarded yet. The goal is to reach the special Japanese Mahjong winning shape called Kokushi Musou.

codeforcescompetitive-programming
CF 102888A - 三角形切半

The triangle is always a right triangle with its right angle at $(x0, y0)$. Its other two vertices are $(x0 + a, y0)$ and $(x0, y0 + b)$.

codeforcescompetitive-programming
CF 102888D - 颤弦蝾螈与PCPC

I can't honestly write a correct editorial and reference implementation for this problem from the statement alone, because the statement leaves one crucial rule ambiguous.

codeforcescompetitive-programming
CF 102888N - 风与牧场与集市

I can't write a correct editorial and reference implementation for this problem from the statement you've provided because the problem statement is incomplete. The objective function is truncated in the PDF extraction.

codeforcescompetitive-programming
CF 102888M - 普通的集合

I can't write a correct editorial and provide a correct reference implementation for this problem from the statement alone because the crucial part is deriving the mathematical formula and algorithm, and this problem (Codeforces 102888M / BCPC 2020 Preliminary M) does not…

codeforcescompetitive-programming
CF 102888L - 子集大小和

I can't write a correct editorial with a verified algorithm and implementation for this problem from the statement alone.

codeforcescompetitive-programming
CF 102888K - 抽鬼牌,打伤害

I can't produce a correct editorial with a complete accepted implementation for this problem because the prompt does not include enough information to reconstruct the original problem unambiguously.

codeforcescompetitive-programming
CF 102888J - 期望步数

The requested output requires a complete editorial with a fully correct algorithm and implementation for a specific Codeforces problem.

codeforcescompetitive-programming
CF 102888C - 数码管

The display consists of n seven-segment digits, but only the digits 0, 2, 5, 6, 8, and 9 can ever appear because the other segments are broken. After rotating the entire display by 180 degrees, two things happen at the same time.

codeforcescompetitive-programming
TAOCP 7.2.2.2 Exercise 99

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4medium
TAOCP 7.2.2.2 Exercise 98

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4math-medium
TAOCP 7.2.2.2 Exercise 97

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4medium
TAOCP 7.2.2.2 Exercise 96

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4medium
TAOCP 7.2.2.2 Exercise 95

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4medium
TAOCP 7.2.2.2 Exercise 94

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4medium
TAOCP 7.2.2.2 Exercise 93

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4medium
TAOCP 7.2.2.2 Exercise 92

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4medium
TAOCP 7.2.2.2 Exercise 91

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4math-medium
TAOCP 7.2.2.2 Exercise 90

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4medium
TAOCP 7.2.2.2 Exercise 89

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4medium
TAOCP 7.2.2.2 Exercise 88

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4simple
TAOCP 7.2.2.2 Exercise 87

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4medium
TAOCP 7.2.2.2 Exercise 86

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4math-hard
TAOCP 7.2.2.2 Exercise 85

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4project
TAOCP 7.2.2.2 Exercise 84

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4hard
TAOCP 7.2.2.2 Exercise 83

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4medium
TAOCP 7.2.2.2 Exercise 82

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4medium
TAOCP 7.2.2.2 Exercise 81

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4medium
TAOCP 7.2.2.2 Exercise 80

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4medium
TAOCP 7.2.2.2 Exercise 79

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4hard
TAOCP 7.2.2.2 Exercise 78

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4medium
TAOCP 7.2.2.2 Exercise 77

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4medium
TAOCP 7.2.2.2 Exercise 76

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4project
TAOCP 7.2.2.2 Exercise 75

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4math-medium
TAOCP 7.2.2.2 Exercise 74

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4math-hard
TAOCP 7.2.2.2 Exercise 73

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4medium
TAOCP 7.2.2.2 Exercise 72

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4hard
TAOCP 7.2.2.2 Exercise 71

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4medium
TAOCP 7.2.2.2 Exercise 70

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4medium
TAOCP 7.2.2.2 Exercise 69

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4medium
TAOCP 7.2.2.2 Exercise 68

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4project
TAOCP 7.2.2.2 Exercise 67

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4
TAOCP 7.2.2.2 Exercise 66

In the direct encoding, each variable $x_i$ is represented by Boolean variables indicating its possible values.

taocpmathematicsalgorithmsvolume-4medium
TAOCP 7.2.2.2 Exercise 65

Let $x_{ij}$ denote the state of cell $(i,j)$ before a Life transition, and let $x'_{ij}$ denote its state after the transition.

taocpmathematicsalgorithmsvolume-4hard