brain

tamnd's digital brain — notes, problems, research

43815 notes

CF 105973A - Edgy Graph

We are given an undirected graph where each edge carries a positive integer weight. The task is to assign a value to every vertex so that for every edge, the larger of the two endpoint values is exactly equal to the edge’s weight.

codeforcescompetitive-programming
CF 105968L - Legendary Duty Scheduler

We are simulating a rotating duty assignment over a sequence of days. There is a fixed group of students, initially all present in an active pool. Over time, some students may be added to the pool and others may be removed, with these changes scheduled to happen on specific days.

codeforcescompetitive-programming
CF 105968J - Johannes Loves Games

We are working with a dynamic array of integers where two kinds of operations are supported. One operation changes the value at a single position, and the other asks for information about a contiguous segment of the array.

codeforcescompetitive-programming
CF 105968I - IME1000 project

The problem models a graph where traveling between cities is not only expensive in terms of edge weights, but also changes a secondary state called reputation. Each state of the system is described by a pair consisting of a node and a reputation value.

codeforcescompetitive-programming
CF 105968H - Heaviside Step Function

The task presents a single number written in text form rather than as a native integer type. The number may be extremely large, beyond what standard integer types in most programming languages can store, so it must be processed as a raw string.

codeforcescompetitive-programming
CF 105968G - Gruesome Polynomials

The task is about locating all real roots of a real-valued polynomial within a fixed interval, specifically from −30 to 30, with high precision.

codeforcescompetitive-programming
CF 105968E - Escaping Cokeman

We are working on a grid-based shortest path problem where movement happens through a rectangular map. Each cell is either free or blocked by walls, and there are special cells: a starting point, a destination exit, and a badge location.

codeforcescompetitive-programming
CF 105968D - Do The g, Man

We are working with an undirected graph. The task is to determine whether a very specific structure exists: a cycle of length four, and in addition to that cycle, a short “branch” of length two that starts from one vertex of the cycle but does not reuse the other vertices of…

codeforcescompetitive-programming
CF 105968A - Adding IQs

We are given a collection of integer values representing IQs of individuals. The task is to count or characterize subsets of these values based on their total sum, where the direct interpretation is that every subset contributes a combined IQ equal to the sum of its elements.

codeforcescompetitive-programming
CF 105968B - Braga's Problem

We are working with multiple queries over a range of integers, and for each query we need to compute the sum of all prime numbers that lie inside a given interval.

codeforcescompetitive-programming
CF 105962K - Rofofo's Test

We are given a machine model where memory is arranged as several cachelines, and each cacheline contains many 8-bit variables. Every variable holds a value from 0 to 255, and all arithmetic is performed modulo 256, so values wrap around after 255. Two operations are available.

codeforcescompetitive-programming
CF 105962J - Tigrinho

We are given a 3 by 3 board. Each cell is either a digit from 1 to 9 or a wildcard symbol. The board participates in a scoring system based on five special lines: the three rows and the two diagonals.

codeforcescompetitive-programming
CF 105962I - Aura Farming

We are given a set of problems, each described by two numbers. The first number is a threshold requirement: Beraldo can only solve that problem if his current aura is at least that value. The second number is a reward: if he solves the problem, his aura increases by that amount.

codeforcescompetitive-programming
CF 105962H - La Vaca Saturno Saturnino

We are given a sequence of snapshots of a queue. Each snapshot is a full ordered list of all students currently in the queue at some moment in time, and these snapshots are shown in chronological order.

codeforcescompetitive-programming
CF 105962G - GPT in Fury

The task is about detecting which words in a long transcript have been corrupted by a transformation process. You are given a single line containing thousands of space-separated words.

codeforcescompetitive-programming
CF 105962E - Esteche vs Yvens

We are given a single pile of stones and two players who alternate turns, starting with Yvens. On each turn, the current player must remove either one stone or two stones from the pile.

codeforcescompetitive-programming
CF 105962B - We're Competing

We are given a long string S with no spaces, which is a noisy transcription of some original text. The transcription process may have corrupted up to K individual characters, meaning at most K positions in the original text were replaced by different characters.

codeforcescompetitive-programming
CF 105962C - Hacking the Matrix

We are given an $N times N$ binary matrix. We are allowed to freely reorder rows and columns any number of times, independently. After these permutations, we want to find the largest possible “C-shaped” pattern consisting only of ones.

codeforcescompetitive-programming
CF 105962D - MA141

We are given four points in the plane in a fixed order, A, B, C, D. The task is to determine whether connecting them in that order, including the edge from D back to A, forms a geometric square. This is not a “set of four points” problem where we can reorder arbitrarily.

codeforcescompetitive-programming
CF 105950G - Godfather

We are given a rooted structure that evolves over a sequence of operations driven by a binary string. Initially, there are two “states” of the story, each represented by a numeric value: one main value and one auxiliary value.

codeforcescompetitive-programming
CF 105949L - abc

We are given a string composed only of the characters a, b, and c. The task is to look at every contiguous substring and assign it a score based on how uneven the character distribution is inside that substring.

codeforcescompetitive-programming
CF 105949K - Point Divide and Conquer

We are given a tree with labeled nodes and a fixed permutation that determines an order of processing. The construction builds a rooted tree by repeatedly selecting, from the currently remaining nodes, the one that appears earliest in the permutation among those still present.

codeforcescompetitive-programming
CF 105949J - Sichuan Provincial Contest

We are given a tree, and every node carries a single uppercase letter. A query asks us to count how many simple paths in this tree contain exactly five nodes, and if we read the letters along the path in order, they must form the fixed pattern “S C C P C”.

codeforcescompetitive-programming
CF 105949I - Essentially Different Suffixes

We are given several strings, and we conceptually take every suffix from every string. A suffix is any substring that starts at some position and continues to the end. For example, in a string like “abc”, its suffixes are “abc”, “bc”, and “c”.

codeforcescompetitive-programming
CF 105949E - Competition Graph

We are given a complete directed graph on $n$ labeled vertices where every pair of vertices has exactly one directed edge between them, forming a tournament. Among all such tournaments, we need to count how many contain at least one directed simple cycle of length exactly $k$.

codeforcescompetitive-programming
CF 105949G - Diophantine Equation

We are given a sequence of numbers that we can think of as defining a polynomial-like transformation over a modular field.

codeforcescompetitive-programming
CF 105949F - Inversion Pairs

We are given a binary sequence where every position is supposed to end up as either 0 or 1, but some positions are currently unknown. The unknown positions can be filled freely with 0 or 1.

codeforcescompetitive-programming
CF 105949A - Minimum Product

We are given a directed graph where every edge carries two small positive weights. A path from node 1 to node N accumulates these weights separately: one sum is formed by adding all first components along the path, and another sum is formed by adding all second components.

codeforcescompetitive-programming
CF 105949D - Tripartite Graph

We are given a permutation $q$ of length $n$. We need to count how many permutations $p$ of the same length satisfy two conditions. First, $p$ must be lexicographically larger than $q$.

codeforcescompetitive-programming
CF 105949B - Ternary

We are given a hidden “encryption system” that works digit by digit on base-3 numbers of length $n$. At each position $i$, there is a fixed permutation $fi$ of the digits ${0,1,2}$.

codeforcescompetitive-programming
CF 105948J - Ever Forever (II)

We are given a mutable string over lowercase letters. The core quantity we track is defined over a fixed ordered pair of characters, specifically pairs where the first character is 'e' and the second is 'f'.

codeforcescompetitive-programming
CF 105948I - 简单的数字运算 (II)

We are given a function defined on positive integers through their prime factorization. For a number $x$, we decompose it into prime powers $x = prod pi^{alphai}$.

codeforcescompetitive-programming
CF 105948H - 子序列、达标率与期望

We are given an array of positive integers of length up to 50. For every subset size $k$ from 2 up to $n$, we look at all subsequences of that size, chosen uniformly at random.

codeforcescompetitive-programming
CF 105948G - 迷宫 (II)

We are given a square grid whose side length is $2n$. Inside this grid, there is a fixed procedure described in a previous part of the problem (迷宫 I) that allows us to add edges between cells according to certain local rules.

codeforcescompetitive-programming
CF 105948E - Colonization Assessment for Terraforming

We are given a graph where each vertex represents a planet and each vertex has a numeric value called its habitability. The graph is undirected, and edges represent bidirectional travel routes between planets.

codeforcescompetitive-programming
CF 105948D - 简单树上问题

We are given a rooted tree with root fixed at node 1. Each node carries a non-negative integer value. The only operation allowed is to choose a node u and an integer x ≥ 0, then XOR every node in u’s subtree with a value equal to a fixed bit pattern depending on x…

codeforcescompetitive-programming
CF 105948C - 马拉车

We are given two collections: horses with stamina values and carts with weights. Each horse must be assigned exactly one cart, and each cart can be used at most once. If a horse with stamina $Ei$ pulls a cart with weight $Wj$, its movement contribution is $max(Ei - Wj, 0)$.

codeforcescompetitive-programming
CF 105948A - Executable Log

We are given a list of files, where each file has a name and a permission string. The permission string encodes whether the file can be read, written, or executed using the familiar three-character format.

codeforcescompetitive-programming
CF 105946M - Trapped

We are simulating a constrained survival process where time and oxygen are the same currency in different forms. Each second spent anywhere, digging or operating machinery, reduces the oxygen tank by one.

codeforcescompetitive-programming
CF 105946L - Summoner's Rift

We are given a square arena with side length $r$, and a set of $n$ points representing heroes placed inside it. A random infinite line is generated in two stages: first a random point inside the square is chosen, then a random direction is chosen uniformly over all angles in…

codeforcescompetitive-programming
CF 105946K - Polynomial Construction

We are asked to construct several different integer polynomials. Each polynomial must satisfy three structural constraints at the same time. First, it must be monic, so its highest-degree coefficient is exactly 1.

codeforcescompetitive-programming
CF 105946H - Illusion of Progress

We are given a connected, simple undirected graph with $n$ districts and $m$ existing roads. District 1 is the starting point for every citizen.

codeforcescompetitive-programming
CF 105946J - Knights and Knaves

We are given multiple independent scenarios involving three fixed participants: Alice, Bob, and Cindy. Each person is either a truth-teller or a liar.

codeforcescompetitive-programming
CF 105946G - Heavy Metal Pipe Jumpscare

We are given the first $N = 2 cdot 10^5$ terms of a sequence that is mostly generated by a fixed linear recurrence of order $k le 69$, but with occasional corruption. For the first $k$ positions, the values are arbitrary.

codeforcescompetitive-programming
CF 105946F - The Grand Heist

We are given a single block of gold with total mass $G$, and a group of $n$ people who contributed different amounts of effort.

codeforcescompetitive-programming
CF 105946E - Fanceptionception

Each cell of an n by n grid contains a fan that may or may not be active, and every active fan pushes wind only downward. A fan at position (i, j) with strength f influences a triangular region starting from itself and expanding as we go to lower rows.

codeforcescompetitive-programming
CF 105946C - Butler's Tea

Each test case describes a household where a group of servants must complete a set of chores. Every chore has a required amount of work, and every hour each servant contributes work depending on how they are assigned.

codeforcescompetitive-programming
CF 105946B - Absorption Game

We are given an array and many operations on subarrays. Each query asks for a value derived from a randomized “absorption” process, and updates replace a whole segment with a fixed pattern.

codeforcescompetitive-programming
CF 105946D - Daily Life of Data Visualization Engineers

The program described here takes an integer array and performs a simple filtering step before turning it into a vertical bar chart. All non-positive values are discarded, and the remaining values keep their original order.

codeforcescompetitive-programming
CF 105945J - Puzzle Competition

We are given a directed graph where each node represents a puzzle. Every node starts with zero “energy”, and each node has a threshold value. A node becomes unlocked as soon as the total energy it has accumulated reaches or exceeds its threshold.

codeforcescompetitive-programming
CF 105945I - Team Naming

We are given $n$ people, and each person has a “name” made of three integers, which we can think of as a length-3 vector. We want to choose three distinct people $i, j, k$.

codeforcescompetitive-programming
CF 105945K - Typewriter

We are given a string that we want to reproduce using a peculiar typewriter mechanism. Instead of directly writing characters into the output, the machine reads from a template tape and copies into an output tape.

codeforcescompetitive-programming
CF 105945H - Loose Subsequences

We are given a string and asked to count how many different non-empty subsequences we can form under a spacing restriction on positions.

codeforcescompetitive-programming
CF 105945F - Ranking Prediction

A contest has already ended, and the scoreboard is frozen. You know your own team’s final result completely: how many problems you solved and your total penalty time.

codeforcescompetitive-programming
CF 105945E - Grid Coloring

We are given a grid with exactly two rows and $n$ columns. Some cells already contain a color label, while the rest are empty. We must assign colors to the empty cells so that every cell is colored, and the precolored cells remain unchanged.

codeforcescompetitive-programming
CF 105945B - Integer Generator

We are given a multiset of integers, but duplicates do not exist initially. Each number is a 30-bit mask. We are allowed to repeatedly pick any two currently available numbers and apply exactly one of three bitwise operations between them, XOR, AND, or OR, and then insert the…

codeforcescompetitive-programming
CF 105945A - Matrix Game

We are given a binary matrix with up to a million rows but only up to ten columns. Each cell initially contains either zero or one. We are allowed to repeatedly flip entire rows or entire columns, where flipping means toggling every bit in that row or column.

codeforcescompetitive-programming
CF 105945D - Spell Generation

We are given a very simple device that can generate a string of a required length, but it has two ways of operating, each consuming time. The first operation is a single tap. Each tap takes one second and produces exactly one unit of output length.

codeforcescompetitive-programming
CF 105941L - Astral Decay

We are given a set of points on a 2D plane. We must pick three points, allowing reuse of the same point, and designate them as A, B, and C. From A, we form two vectors pointing to B and to C, and we want to minimize the dot product of those two vectors.

codeforcescompetitive-programming
CF 105941K - Ring Trick II

We are given a sequence of length $n$, where each element is an integer in the range $[0, m-1]$. The key operation allowed is a global cyclic shift: we choose a single integer $k$, and every element $ai$ is replaced by $(ai + k) bmod m$.

codeforcescompetitive-programming
CF 105941J - Ring Trick

We are given a string consisting only of uppercase English letters. We are allowed to apply a single global Caesar shift: pick an integer shift $k$, then every character is rotated forward by $k$ positions in the alphabet modulo 26.

codeforcescompetitive-programming
CF 105941I - 有的兄弟,有的

We are given a system of players, each initially belonging to some faction. During the hidden part of the process, players repeatedly fight.

codeforcescompetitive-programming
CF 105941H - 树论函数

We are given a rule that builds an infinite undirected graph over positive integers. Each integer is a node. For a node $n$, we define a value $f(n) = n(n+1)$.

codeforcescompetitive-programming
CF 105941G - 直径与最大独立集

We are asked to construct a tree on $n$ vertices so that two quantities become equal: the size of a maximum independent set and the diameter length of the tree. A maximum independent set is a largest possible set of vertices where no two chosen vertices share an edge.

codeforcescompetitive-programming
CF 105941E - 双生魔咒

We are given 2n strings made of lowercase letters. We must split them into two groups of equal size, think of one group as “prefix side” strings and the other as “suffix side” strings. After that, we pair the two groups arbitrarily in a one-to-one matching.

codeforcescompetitive-programming
CF 105941A - Toxel 与独一无二的序列

We are given several test cases. Each test case provides an array of length $n$, where every element is an integer between $1$ and $n$.

codeforcescompetitive-programming
CF 105941B - 随机栈 II

We are given a sequence of operations on a multiset that starts empty. Each operation is either inserting a value or removing one element chosen uniformly at random from the current multiset.

codeforcescompetitive-programming
CF 105941D - 2025

We are given a single integer representing a year, and we need to decide whether it satisfies a very specific numeric property. The year is valid if two conditions hold simultaneously.

codeforcescompetitive-programming
CF 105937N - Kessoku Band

We are given a permutation of numbers from 1 to n, meaning every integer in this range appears exactly once and is arranged in some order along a line. Each operation gives us a segment [l, r] of this line.

codeforcescompetitive-programming
CF 105937L - Gros-Phi

Each game describes a set of timed targets on a line. Every target is a pair consisting of a time moment and a position on the line. Starting at time zero, Awa can choose any initial position and then move along the line with a fixed maximum speed.

codeforcescompetitive-programming
CF 105937O - Discrete Logarithm

We are given three integers $a$, $c$, and a prime modulus $p$. The task is to construct a large integer $b$ such that a specific congruence holds between two expressions built from these values.

codeforcescompetitive-programming
CF 105937K - Seele Vollerei

We are working with a rooted tree whose structure is fixed, but whose root can change over time. Each node stores a weight, initially zero. On top of this tree, we are given a sequence of pre-defined path updates.

codeforcescompetitive-programming
CF 105937I - Ori

We are given a tree, meaning a connected acyclic graph. Each vertex represents a “core”, and edges represent allowed moves between cores. We are allowed to construct a walk on this tree, where revisiting vertices is permitted.

codeforcescompetitive-programming
CF 105937J - Bastion

We are given a simple polygon described by its vertices in counterclockwise order. The polygon is non-degenerate, so edges only meet at endpoints, no three consecutive vertices are collinear, and it forms a proper closed shape.

codeforcescompetitive-programming
CF 105937G - Primal Core Optimization: Attribute Balance

We are given a collection of $N$ points in a 3-dimensional integer space. Each point represents a partner with three attributes $(S, F, E)$. The goal is to apply operations so that all points become identical, meaning every partner ends with exactly the same triple.

codeforcescompetitive-programming
CF 105937E - Pythagorean Cup

We are given a line of $n$ cups. Each cup starts in one of three states: empty, half full, or full. A full cup immediately overflows and effectively becomes empty, so after initialization only empty and half-full cups matter.

codeforcescompetitive-programming
CF 105937H - 9-Nine

We are given two very small binary grids, each of size 3 by 3. Think of the first grid as configuration A and the second as configuration B. Every cell is either 0 or 1. We are allowed to perform three kinds of operations.

codeforcescompetitive-programming
CF 105937D - Symmetrical Isolation: The Battle of Black and White

We are given a rectangular board of size $N times M$. Each cell is either already black or white. We are allowed to paint additional white cells black, but we are never allowed to repaint a black cell back to white.

codeforcescompetitive-programming
CF 105937C - Quantum Mechanics

We are given a quantum system consisting of $n$ qubits, and instead of a classical state like a bitstring, the system is described as a complex-valued vector of size $2^n$. Each index of this vector corresponds to one basis state, i.e., one binary string of length $n$.

codeforcescompetitive-programming
CF 105937A - Card Master

We are given a single round of a very simple card game where exactly three cards are drawn. Each card has an integer value between 1 and 13. The score for the round is normally just the sum of the three values.

codeforcescompetitive-programming
CF 105931E - Матрица циклических сдвигов

We start with a one-dimensional array, but instead of working with it directly, we use it to generate an $n times n$ matrix where every row is just a cyclic shift of the original array.

codeforcescompetitive-programming
CF 105931D - Вычислительная машина

We are given two binary strings of equal length, which we can think of as two rows aligned vertically. On each query, we take a substring interval and are allowed to apply two local transformation rules inside that interval.

codeforcescompetitive-programming
CF 105931B - Манхэттенские перестановки

We are given a permutation of length $n$, meaning an arrangement of the numbers from $1$ to $n$ without repetition. For any position $i$, the contribution of that position is the distance between the value placed there and the index itself, taken in absolute value.

codeforcescompetitive-programming
CF 105931A - Новый университет

The university is enrolling up to n students in total. Every student must fall into one of two categories. If a student pays tuition, they contribute a fixed amount a to the university. If a student receives a scholarship, their funding comes from a sponsor.

codeforcescompetitive-programming
CF 105930M - Triangulation

We are given a circle with $n$ equally spaced points. Think of them as vertices placed around a round table in clockwise order, but their labels are unknown.

codeforcescompetitive-programming
CF 105930H - Minimum Spanning Tree

We are given a connected undirected weighted graph. On top of the existing edges, we are allowed to add up to k extra edges.

codeforcescompetitive-programming
CF 105930J - Useful Algorithm

We are given a permutation of size $n$ and a target value $k$. We imagine running a binary search algorithm on this permutation, treating it as if it were a sorted array even though it may be completely arbitrary.

codeforcescompetitive-programming
CF 105930A - Project Management

Each employee comes with two attributes: a rank value and a personal tolerance. The rank determines who they consider “higher” than themselves, and the tolerance specifies how many higher-ranked colleagues they are willing to tolerate in the same project team.

codeforcescompetitive-programming
CF 105930F - ACE String

We are given a string and we want to find a substring that has a very rigid internal structure. Inside such a substring, we must be able to choose a length p and a starting position for a middle block so that the substring can be conceptually split into five consecutive parts.

codeforcescompetitive-programming
CF 105930D - Distributed System

We are given a system with n worker nodes arranged in a circle, indexed from 0 to n-1. Each task does not go to a single node, but instead generates a contiguous sequence of sub-tasks. A task is described by two values: a and b.

codeforcescompetitive-programming
CF 105928M - Bridge IV

Two players are dealt full information about a bridge-like game. For every suit, each player already knows exactly how many tricks they would win if they became the declarer and chose that suit.

codeforcescompetitive-programming
CF 105928C - Knight

We are given a large rectangular chessboard and a single starting square. A piece called a knight can move in a generalized way: from any square it can jump either k steps in one axis and 1 step in the other, or the reverse, with all sign variations as long as the destination…

codeforcescompetitive-programming
CF 105928I - FST: First Search Traversal

We are given two sequences of length $n$, each of which is a permutation of the numbers from $1$ to $n$. We are asked whether it is possible to construct a rooted tree on these $n$ labeled nodes such that one of the permutations can be obtained as a valid depth-first search…

codeforcescompetitive-programming
CF 105928E - LCM Queries

We are maintaining a dynamic array where elements can change over time, and we must answer range queries about a multiplicative structure derived from those elements. Each query either updates a single position or asks about a segment of the array.

codeforcescompetitive-programming
CF 105925K - K Missing Elements

We are given a sequence that defines an ordering constraint between positions and another sequence that assigns a weight to each position.

codeforcescompetitive-programming
CF 105925E - Particle Energization

A particle starts at position 1 on an infinite number line. A fixed parameter $Y$ is given. The particle evolves in discrete steps.

codeforcescompetitive-programming
CF 105925J - Journey of the Particles

We are given a circular arrangement of N filters. Each filter has a threshold value, and particles move through these filters in a fixed direction. A particle starts at filter i with an initial phase equal to the threshold of that filter.

codeforcescompetitive-programming
CF 105925C - Matrix Logic Circuits

We are given a quantum circuit described as a sequence of reversible logic gates acting on an N-qubit system. Each gate is either a CNOT or a CCNOT.

codeforcescompetitive-programming
CF 105924K - 微信小游戏

We are given an $n times m$ grid where each column contains a vertical stack of colored blocks. There is also an extra “floating” block $d$, initially colorless.

codeforcescompetitive-programming
CF 105924H - 王国------迁移

We are given a system with two interacting sides: cities and groups of people. There are $n$ cities, each with a cost parameter $ci$, and $n$ groups of residents, where group $i$ contains $bi$ people.

codeforcescompetitive-programming