brain
tamnd's digital brain — notes, problems, research
43815 notes
We are asked to reconstruct a hidden binary string of length $n$, knowing that its first character is always '0'. We cannot read the string directly.
For input n = 1, k = 1: - Deck: 4 cards, one of each suit. - Sliding window k = 1 means Monocarp looks at the last card drawn (or zero for the first card) and guesses the least frequent suit.
We are asked to determine whether a given word could have been typed on a keyboard with a very specific malfunction: every other keystroke produces the letter twice instead of once.
We have a chemistry lab scenario where Monocarp can buy contracts that give him unlimited access to specific solutions of an acid. Each contract specifies the concentration of the solution, the cost to sign the contract, and the price he can sell it for.
We are given a sequence of videos, each with a download size, and a fixed disk capacity that limits how many megabytes can be stored at once. Each video takes time proportional to its size to download, and once downloaded it can be watched in exactly one minute.
We are dealing with a long sequence of independent random experiments: a deck contains exactly four suits, and each suit appears exactly (n) times, so the total length is (4n). The deck is shuffled uniformly at random, so every permutation is equally likely.
Each document is described by which developers should be able to open it. So every column of the input matrix is a subset of developers: those rows where the value is one form the “approved set” for that document.
We are given a directed graph where each edge has a capacity and a cost. We want to push flow from vertex 1 to vertex n, satisfying the usual flow conservation at all intermediate vertices: the total flow into a vertex equals the total flow out.
For any array segment, we process its elements from left to right and maintain a list of subsequences. When a new value arrives, we look for the first subsequence whose current last element has a positive bitwise AND with the new value.
Input: Expected: Actual: a long list of card distributions So the program is no longer failing with a crash, but producing completely irrelevant output.
We are given a list of pairs of positive integers, and for each pair, we want to explore a sequence of consecutive pairs formed by simultaneously incrementing both numbers.
We are given a grid with two rows and m columns representing a wall. Each cell is either black (B) or white (W). Monocarp wants to paint all black cells exactly once in a single continuous path that moves only between adjacent cells.
We are asked to type a string s of length n using a text editor that allows two operations: appending a single character or copying a contiguous substring that has already been typed and pasting it at the end.
The problem gives a triangle in the plane with positive area, specified by three points with integer coordinates.
We are looking at a tournament structured as a perfect binary tree. At the start there are $2^n$ teams, each assigned a distinct skill value from 1 to $2^n$.
We are given a rooted tree where every vertex stores an integer label. For each query, we are given two vertices, and we must look at two subtrees rooted at these vertices.
We are given a linear sequence of platforms, each with a fixed color, and a cost associated with activating all platforms of each color. Initially, all platforms are deactivated. You can only jump from a platform to the next one or skip one to the platform after that.
We are given an $n times n$ upper-triangular table of constraints on substrings of a binary string $s$ of length $n$. For every interval $[i, j]$, we are told whether that segment must be constant, must contain both 0 and 1, or is unconstrained.
We are given several towers, each containing a certain number of blocks. The goal is to maximize the number of blocks on the first tower by moving blocks from towers that have more blocks than others.
Input: Expected: Two different configurations (two different games), each printed as a pair of 18-card hands. Actual output: Two identical blocks: This means: - Your program does print two cases - But they are not correctly separated as distinct constructions in memory - Or…
We are given a permutation of integers from 1 to $n$, and we can swap any two elements to change the permutation. The goal is to perform the minimum number of swaps so that the resulting permutation has exactly one inversion.
We are given a permutation of size 3n, which is an array containing every integer from 1 to 3n exactly once in some order. We have two allowed operations: we can either sort the first 2n elements or sort the last 2n elements.
We are given a permutation, meaning a rearrangement of numbers from 1 to n. In one move, we pick any k elements, remove them from the array, sort just those chosen elements, and append them back to the end. The rest of the array keeps its relative order.
The problem asks us to find the largest integer x less than a given integer k such that the sum of x! and (x-1)! is divisible by k. In plain language, we want a number just below k where adding its factorial to the factorial of the previous number gives a multiple of k.
This is a Type B (prove inequality) problem, not Type C. The task is to prove that $$frac1{a^3(b+c)}+frac1{b^3(c+a)}+frac1{c^3(a+b)}ge frac32$$ for all positive $a,b,c$ satisfying $abc=1$.
We are dealing with a deterministic two-player card game played with a fixed 36-card deck. The deck is split between two players, and the game evolves by repeatedly placing cards onto a shared table under strict adjacency rules: a card can only be played if it either is a nine…
This is a Type B (prove inequality) problem, not Type C. The task is to prove that $$frac1{a^3(b+c)}+frac1{b^3(c+a)}+frac1{c^3(a+b)}ge frac32$$ for all positive $a,b,c$ satisfying $abc=1$.
We have a two-player card game using a 36-card deck, where each player gets 18 cards. The cards are numbered 6 through Ace in four suits. Alice moves first. On their turn, a player can play: - Any 9, at any time.
This is a Type B (prove inequality) problem, not Type C. The task is to prove that $$frac1{a^3(b+c)}+frac1{b^3(c+a)}+frac1{c^3(a+b)}ge frac32$$ for all positive $a,b,c$ satisfying $abc=1$.
We are given a line of scooters sorted by their initial distance to a destination point. Scooter $1$ starts closest, scooter $n$ farthest. Each scooter has a fixed nominal speed equal to its index, so higher-index scooters try to move faster.
We are given a multiset of “events”, where each event originally belongs to a specific day. The array is sorted, and each value tells us on which day a commit happened.
We are asked to model copying multiple files sequentially from one server to another, tracking progress in two ways: per-file and overall. Each file has a size in bytes, and we simulate copying byte by byte.
We are asked to simulate the progress of copying multiple files from one server to another. Each file has a size in bytes, and copying is sequential, one byte at a time.
This is a Type B (prove inequality) problem, not Type C. The task is to prove that $$frac1{a^3(b+c)}+frac1{b^3(c+a)}+frac1{c^3(a+b)}ge frac32$$ for all positive $a,b,c$ satisfying $abc=1$.
We are asked to work with sequences of non-negative integers of length $n$. Each sequence must satisfy two conditions: the sum of its elements equals $x$, and the bitwise OR of all its elements equals $y$.
We are given a string composed entirely of opening and closing parentheses, and we are asked to make it balanced by removing the fewest possible characters.
We are given a tree with $n$ vertices and $k$ butterflies initially located on distinct vertices. Each edge in the tree will be randomly directed, and butterflies can move along edges if the starting vertex has a butterfly and the target vertex is empty.
We are given two arrays, a and b, each of length n, with elements between 1 and n. We have to choose a third array c of the same length so that a constructed game is won by Koxia. The game proceeds in n rounds.
We start with an array of numbers placed on whiteboards. Then we are given a sequence of replacement values. Each replacement operation allows us to pick any one whiteboard and overwrite its current value with the new value from the operation.
This is a Type B (prove inequality) problem, not Type C. The task is to prove that $$frac1{a^3(b+c)}+frac1{b^3(c+a)}+frac1{c^3(a+b)}ge frac32$$ for all positive $a,b,c$ satisfying $abc=1$.
We are given an array of positive integers and we are allowed to choose a single positive shift value $x$. After shifting every element by the same amount, we want every pair of resulting numbers to be coprime. Equivalently, we transform the array into $bi = ai + x$.
We are given a tree with $n$ vertices, each labeled with a lowercase English letter. For any two vertices $v$ and $u$, define the string $s(v,u)$ as the sequence of letters along the unique path connecting them.
This is a Type B (prove inequality) problem, not Type C. The task is to prove that $$frac1{a^3(b+c)}+frac1{b^3(c+a)}+frac1{c^3(a+b)}ge frac32$$ for all positive $a,b,c$ satisfying $abc=1$.
We are given an n × m grid representing Hossam's ground. Each cell has a quality: perfect (.), medium (m), or bad (). Hossam wants to draw the letter 'H' by placing walls on some cells. The letter consists of two vertical lines and one horizontal line connecting them.
This is a Type B (prove inequality) problem, not Type C. The task is to prove that $$frac1{a^3(b+c)}+frac1{b^3(c+a)}+frac1{c^3(a+b)}ge frac32$$ for all positive $a,b,c$ satisfying $abc=1$.
This is a Type C (optimization) problem. The requirements are to establish an upper bound on the boundary length $L$ between horizontal and vertical dominoes and to exhibit a construction that achieves the maximal possible $L$.
We are given an array for each test case, and we are asked to focus only on pairs of positions in that array. From every ordered pair of distinct indices, we can compute the absolute difference between the two values.
Monocarp wants to increase his chess rating from x to y by playing a set of n opponents with fixed ratings. Each game affects only Monocarp's rating: if his current rating is at least the opponent's, he wins and gains 1; otherwise, he loses and drops 1.
This is a Type B (prove inequality) problem, not Type C. The task is to prove that $$frac1{a^3(b+c)}+frac1{b^3(c+a)}+frac1{c^3(a+b)}ge frac32$$ for all positive $a,b,c$ satisfying $abc=1$.
We are given a sequence of black-and-white pictures, each represented as an $n times m$ matrix of zeros and ones.
We are given a sequence of integers. We are allowed to pick a single real number $x$, and then every element $ai$ is transformed into its distance from $x$, namely $ The task is to determine whether there exists such a choice of $x$, and if it exists, output one valid value.
We are asked to build a strictly increasing sequence of length $k$, where every element lies between $1$ and $n$. Among all such sequences, we are not maximizing the values themselves but a derived quantity based on consecutive differences.
This is a Type B (prove inequality) problem, not Type C. The task is to prove that $$frac1{a^3(b+c)}+frac1{b^3(c+a)}+frac1{c^3(a+b)}ge frac32$$ for all positive $a,b,c$ satisfying $abc=1$.
We are asked to consider domino tilings of an $8times8$ board. Each domino occupies exactly two adjacent cells and has an orientation, horizontal or vertical.
Thank you for the clarification. Let’s carefully trace why the previous solution produced 2.0 instead of 1.0 for the input: Participant 1 is Genie. The mask of the only question is: So mask = 0b11010 = 26. The initial alive set is all participants: S = 0b11111 = 31.
Each test case gives a binary matrix with up to 17 columns and up to 2⋅10^5 rows. Each column represents a participant, and each row describes which participants would answer a particular question correctly. The questions are randomly permuted before being asked.
Now we finally see a real logical failure rather than a wrapper issue. The produced output: is structurally consistent but numerically wrong, which tells us the implementation is computing something uniform per position instead of position-dependent reachability.
We are given a grid of integers with n rows and m columns. Each row represents a cactus, and each column represents a torus.
We are given a deck of cards numbered from 1 to $n$, and we are asked to construct a permutation of these numbers such that a certain value is maximized. The value of a permutation is defined as the minimum sum of any contiguous subarray of length $k$.
We are given a sequence of operations that act on a set of pigs. Each pig has a Health Point value. The operations can either create a new pig with a certain health, reduce the health of all existing pigs by a fixed amount, or repeat all previous operations.
We are given a sequence of operations a magician performs. The magician has pigs, each with a certain Health Point (HP). The operations can create pigs, reduce the HP of all pigs, or repeat all previous operations.
We are given a collection of intervals on a huge number line and many queries, each asking about a fixed target interval $[l, r]$.
We have a tournament with players numbered from 1 to $n$, where each player has a "temperature" equal to their number. Battles happen in environments labeled 0 or 1. In environment 0, the lower-temperature player wins, and in environment 1, the higher-temperature player wins.
We have a rooted tree with root at node 1. Two chess pieces start at the root. Piece A must visit every node from a given set A, piece B must visit every node from another set B. The order is arbitrary. After all required visits are completed, both pieces must return to the root.
We have n binary rows, each of length m. A single operation chooses two rows and one column, then swaps the values in that column between those two rows. Because the swap happens inside the same column, the total number of 1s in the whole matrix never changes.
This is a Type B (prove inequality) problem, not Type C. The task is to prove that $$frac1{a^3(b+c)}+frac1{b^3(c+a)}+frac1{c^3(a+b)}ge frac32$$ for all positive $a,b,c$ satisfying $abc=1$.
We are given a binary string, a sequence of 0 and 1, and we want to insert either + or - between each pair of consecutive digits so that the absolute value of the resulting arithmetic expression is minimized.
We are given an array of integers and a peculiar operation that allows us to select any subsequence and adjust its elements in an alternating fashion: either adding 1 to numbers at odd positions and subtracting 1 from numbers at even positions, or the reverse.
We are asked to find the smallest integer $m ge n$ such that the bitwise AND of all numbers from $n$ to $m$ equals a given number $x$. Formally, we want $n & (n+1) & dots & m = x$.
This is a Type B (prove inequality) problem, not Type C. The task is to prove that $$frac1{a^3(b+c)}+frac1{b^3(c+a)}+frac1{c^3(a+b)}ge frac32$$ for all positive $a,b,c$ satisfying $abc=1$.
We are given a colony of spiders on Mars, each identified by the number of legs it has. Two spiders are considered friends if the greatest common divisor of their leg counts is greater than one.
This is a Type B (prove inequality) problem, not Type C. The task is to prove that $$frac1{a^3(b+c)}+frac1{b^3(c+a)}+frac1{c^3(a+b)}ge frac32$$ for all positive $a,b,c$ satisfying $abc=1$.
We are given an array of integers where each integer is specified by the set of its 1-bits rather than its numeric value. The task is to determine whether there exist two distinct subsequences of the array that produce the same bitwise OR.
The problem gives us a string of letters 'a' and 'b', which represents three capybara names concatenated together.
This is a Type B (prove inequality) problem, not Type C. The task is to prove that $$frac1{a^3(b+c)}+frac1{b^3(c+a)}+frac1{c^3(a+b)}ge frac32$$ for all positive $a,b,c$ satisfying $abc=1$.
We are asked to determine whether a player can reach exactly zero score after a sequence of game rounds, given a controller with two buttons labeled with arbitrary positive integers.
We are asked to count the number of permutations of the numbers from 1 to $n$ that satisfy a chain of inequalities described by a string of length $n-1$. Each character of the string is either < or .
Each researcher starts with a chemical labeled by an integer between $1$ and $n-1$. Every year they upgrade their current chemical: if someone currently holds value $a$, they replace it with a uniformly random integer from the interval $(a, n]$.
Codeforces 1776J: Italian Data Centers
The list shown by SwerChat is ordered by recency. The member who was online most recently appears first, the second most recent appears second, and so on. At 9:00, Beppa records an ordering a. At 22:00, she records another ordering b.
We are given a strictly convex polygon with labeled vertices in counterclockwise order. Each move consists of choosing one currently unused vertex.
We are given a connected undirected graph. Every edge must be assigned to a company. Suppose company c owns all edges colored c. The coloring must satisfy two conditions. The first condition says that no single company is allowed to own a connected spanning network.
We are given a binary string of length $2n-1$, where each position represents a bottle of wine, either white or red. From this fixed sequence, we need to assign $n$ critics to $n$ distinct segments of the array.
We are asked to simulate a person, Isona, crossing a set of parallel railway tracks from one platform to another, while avoiding trains. The crossing is straight and perpendicular to the railways.
We are asked to schedule a team of three people to solve a set of problems with three difficulty levels: easy, medium, and hard. Each problem has a fixed duration depending on its difficulty: easy takes 2 units of time, medium 3 units, and hard 4 units.
The task asks us to determine whether it is possible for the judge to have walked Boy, her dog, at least twice during a single day given a timeline of messages. Each walk takes exactly 120 minutes, cannot overlap another walk, and the judge never sends messages during a walk.
We are asked to place a set of LEGO Duplo bricks on a 1D line along the x-axis, with the constraint that each brick occupies a 2×2 square on the ground and has height 1.
We are playing a sequential game on a line of labeled sections, each section representing a distinct subject. Each day, one of two players chooses a contiguous interval of sections, constrained by a fixed length coming from a multiset of available “passes”.
The game begins with $1000$ heaps containing $1,2,3,\dots,1000$ matches respectively.
The problem gives us a weighted directed graph and asks us to make it "strongly reachable" from some node by optionally reversing edges. The cost of a reversal is the weight of the heaviest edge we choose to reverse, and our goal is to minimize this maximum.
We are given a sequence of non-negative integers and asked to examine every contiguous segment. For each segment, we compute two values: the bitwise XOR of all elements in the segment, and the maximum element in that same segment.
We are asked to select a subset of students from a school to form a quiz team. Each student has a smartness value, and each quiz topic requires at least one team member whose smartness is divisible by the topic number.
We are given a rooted tree with n nodes. Each node initially holds a value of either 0 or 1. The evolution of values in the tree is defined by a simple rule: at each integer time t 0, every non-leaf node updates its value to the XOR of the values of its children from the…
We are asked to compute a sum over all permutations of size $n$, where each permutation contributes the number of inversions in a specific array derived from it.
We are asked to transform an array of integers into a “good array,” which is defined as an array where no two consecutive elements share the same parity. Parity simply means whether a number is odd or even.
We are given a tree with n nodes, where each node has an integer value written on it. Bob can pick a root r for the tree, which establishes parent-child relationships. Then Alice picks a node v, and Bob can choose any subset of nodes from the subtree rooted at v.
We are asked to maximize the value of the root of a tree after performing at most $k$ operations. Each operation allows us to pick a vertex $v$ that has not been selected before, choose a number $x$ that divides all values in $v$'s subtree, and multiply every value in that…
We are given an array consisting only of 1s and -1s. The task is to perform exactly one operation: select two consecutive elements and flip their signs. After doing this, we want to maximize the sum of all array elements.
Two binary strings of equal length evolve over time, but only one of them changes. At every move, we pick a position uniformly among all indices and flip the bit of the first string at that position. The second string is fixed.
We are given a permutation p of the numbers 1...n. Another array a contains m distinct values that all appear in the permutation. For every value, we care only about its position inside the permutation. Let pos[x] be the index of value x in p.