brain
tamnd's digital brain — notes, problems, research
43815 notes
Let $A_1$ and $A_2$ be the sets of participants of the two trips, and let $B_i \subset A_i$ be the boys in the $i$-th trip.
Let
We are asked to find a sequence of node disarmaments for a circular system of size n where node 0 is special. Node 0 must appear twice: first at the start and last at the end. Every other node must appear exactly once.
Each monster type has one or more split rules. Applying a rule consumes one monster of that type and produces two things: First, some number of diamonds. Second, a multiset of new monsters.
Each value from 1 to n appears exactly once in both permutations. For a value v, let: - posP[v] be its position in the first permutation. - posQ[v] be its position in the second permutation.
We are asked to construct a tournament graph of n vertices with a specific connectivity property. A tournament graph is a directed graph where every pair of distinct vertices has exactly one directed edge between them.
We are asked to color every small cube inside a larger cube of size k × k × k using exactly two colors, black and white, with a specific local neighbor condition. Each small cube must have exactly two neighboring cubes of the same color.
The task describes a dancing room where every performance involves exactly one boy and exactly one girl. The participants start with no prior experience, and during each dance at least one of the two people must be dancing for the first time.
We are given three independent supplies of items, each representing flowers of a fixed color. From these supplies we can form bouquets in two fundamentally different ways.
We are given two sets of cards, one belonging to Jiro and one belonging to Ciel. Jiro’s cards come in two types, Attack and Defense, each with a strength value. Ciel’s cards are simpler: every one of her cards is an Attack card with a given strength.
We are given a tree with up to 100,000 nodes, and we must assign each node a letter from 'A' to 'Z'. These letters represent ranks, where 'A' is the strongest and 'Z' is the weakest.
We are given a line of people from position 1 to position n, and we must split this line into exactly k contiguous groups. Each group corresponds to a gondola ride and contains consecutive people in the queue.
We have a square board of size n by n, where n is always an odd number. Each cell contains an integer, which may be positive or negative.
We are asked to determine whether a robot moving on a 2D plane can reach a target point (a, b). The robot starts at the origin (0, 0) and follows a sequence of moves encoded in a string.
We are given a single integer written in decimal form, and we must decide whether it can be constructed by repeatedly placing one of three fixed building blocks next to each other: 1, 14, and 144.
We are maintaining a growing collection of open intervals on the number line. Each time a new interval is added, it becomes a node in an implicit directed graph.
We are given a binary string that we interpret as an integer, and from it we construct a fixed pairing between two ordered sets of size $2^n$.
We are given a sequence of trees with strictly increasing heights. Each tree can be cut down one unit at a time using a chainsaw. The chainsaw requires recharging after each cut, and the recharge cost depends on which trees have already been fully cut.
We are asked to maintain a dynamic set of intervals and answer reachability queries between them. Each interval is represented by two integers $(x, y)$ where $x < y$. Intervals are added one by one, and each new interval is guaranteed to be strictly longer than all previous ones.
We are given a single string and we repeatedly compress certain patterns inside it. The only pattern that matters is a substring that consists of two identical halves placed back to back, so a segment of the form X + X, where X is any non-empty string.
We are given a permutation of the numbers from 1 to n arranged in a line. Each position represents a “psycho” with a unique strength value, and the line evolves in discrete rounds. In one round, every psycho compares himself with the person immediately to his right.
We are asked to simulate the dispersal of ants on a two-dimensional integer grid. Initially, all n ants are placed at the origin (0, 0).
We are given a set of n vessels, each capable of holding up to v liters of water. Some vessels are connected by tubes that allow water to be transferred in integer amounts.
We have a two-dimensional integer grid representing a forest. Each cell can be empty or contain a tree. The Princess starts at a cell (vx, vy) and her Shadow starts at (sx, sy).
We are given a set of integers from 1 to n. Two players alternate turns, and each move consists of selecting a number that has not been eliminated yet.
We are given two integers, $x$ and $y$, and a target threshold $m$. A pair is considered m-perfect if at least one of the two numbers is greater than or equal to $m$.
The problem asks us to count how many numeric codes match a hint string that can contain fixed digits, wildcards, and letters representing digit equality constraints. Each character in the hint string represents a position in the safe code. A question mark ?
We are given a main string $s$ and several constraints, each constraint consists of a pattern string $p$ and a numeric interval $[l, r]$.
We are asked to count the number of distinct substrings of a string s that satisfy a set of occurrence-based rules.
The task is to analyze a binary image where 0 represents the background and 1 represents a sun or its rays. Each sun consists of a central ellipse (which may be rotated) and several rays extending outward as line segments from the ellipse’s boundary.
The input is a pixel grid made of two values, where one value represents empty background and the other represents ink belonging to drawn objects.
We are maintaining an array that changes over time through point updates and range updates, while also answering range queries.
We are given an array of integers, and we need to process a sequence of operations that modify the array or query it in a special way. There are three types of operations: direct assignment of a value to an element, range sums weighted by Fibonacci numbers, and range increments.
We are given a line of students, each initially holding a distinct labeled ball from 1 to n. The only operation allowed is choosing two different students and swapping the balls they currently hold.
We are given a line of students, each initially holding a distinct labeled ball. The only operation allowed is to pick two students and swap the balls they currently hold.
We are given a queue of n beavers, each numbered from 1 to n. Each beaver either knows who should be immediately in front of them, represented as a[i] (the number of that beaver), or does not know, represented as 0.
We are given a structure of people standing in a queue, but the queue is not fully known. Each person either clearly knows who stands immediately in front of them or does not know that information at all.
We have an array of integers and a sequence of operations. One operation changes a single position to a new value. Another operation adds the same number to every element in the array. The third operation asks for the current value at a specific position.
Each bottle has two properties. The value a[i] is the bottle's own brand. The value b[i] is the brand of bottles that this bottle can open. A bottle can be opened if there exists some other bottle whose opening capability matches its brand.
We are given an array of positive integers. Consider every distinct non-empty non-decreasing subsequence of the array. For each such subsequence $y = (y1,dots,yk)$, we count all positive integer sequences $x = (x1,dots,xk)$ satisfying $$xi le yi$$ for every position.
The participants are listed in final rank order. Participant i has rating a[i]. For a table of size m, if a participant currently occupies position p, his rating change is $$d = sum{text{participants before him}} aj (posj-1) - ai (p-1)(m-p)$$ In the original statement this…
The geometric description hides a much simpler combinatorial structure. Take a pair of points $(l,0)$ and $(r,0)$, with $l<r$. The left endpoint is marked by a lowercase letter and the right endpoint by the corresponding uppercase letter.
We are asked to place two perpendicular lines on a plane so that one of them makes a 45-degree angle with the x-axis, and the maximum Manhattan distance from a set of given points to either line is minimized. The input provides the coordinates of n points on the plane.
We are given two strings, a and c, and two integers, b and d. The string a is repeated b times to form a long string w, and the string c is repeated p times to form another string q.
The problem centers on Ilya’s bank account balance, which is a signed integer. Positive values indicate savings, and negative values indicate debt.
We are asked to construct a $2 times n times 2 times n$ square matrix from a given list of $4n$ integers such that a recursively defined "beauty" measure is maximized.
Codeforces 313E: Ilya and Two Numbers
We have a row of holes on a road, numbered from 1 to $n$. Each hole can be repaired by hiring one of $m$ companies.
We are given a string composed solely of the characters "." and "". The task is to answer multiple queries efficiently. Each query asks, within a substring from position l to r, how many times a character is immediately followed by an identical character.
Two archers shoot at a target alternately. SmallR shoots first and hits with probability $a/b$ on each shot. Zanoes hits with probability $c/d$ on each shot. As soon as someone lands the first hit of the match, the game ends and that player wins.
We are given a small chat log with up to 10 sentences. Each sentence is a string of letters, underscores, commas, periods, and spaces. Two people, Freda and Rainbow, are involved. According to prior experience, Freda always ends her sentences with the substring "lala.
We are given an array of integers, and we need to perform multiple operations on ranges of this array. Each operation specifies a contiguous segment of the array and a value to add to every element in that segment.
Vasya is participating in a programming round with several problems, each split into a Small and a Large input. Completing the Small input of a problem gives him a guaranteed number of points in a certain amount of time.
We are asked to construct a set of n points on the 2D plane such that the largest convex polygon that can be formed from these points has exactly m vertices. No three points may lie on a straight line.
We are given a set of points in the plane, each with distinct coordinates, and we are asked to connect them into a directed rooted binary tree with the additional geometric constraint that every edge must go downward in the plane.
Every interior grid line of the paper is divided into unit segments by the lattice points. A cut along a grid line marks all unit segments touched by the knife as already cut. The crucial observation is that the geometry of the paper never changes.
We are asked to maximize the net money SmallR can gain from an experiment on dogs, where she can change each dog’s sex at a given cost.
We are given an array of integers and a sequence of queries. Each query is either asking for the sum of a subarray or instructing us to cube every element in a subarray. The output consists of the answers to the sum queries, computed modulo 95542721.
We are given a set of points in a 2D plane. The original geometric task would normally be to compute the smallest Euclidean distance among all pairs of points.
We are asked to compute the expected number of collisions between runners on a circular track. Each runner starts at a distinct position along a track of length l and chooses to run either clockwise or counter-clockwise with equal probability.
We are given a memory layout split into several contiguous free segments, which we can think of as independent blocks of space. Each block has a fixed length, and we also have a collection of arrays we may want to place into this memory.
We are given a collection of segments on a very large number line. Each sheep corresponds to one segment, and two sheep become “connected” if their segments overlap in at least one point. After this preprocessing, we must arrange all sheep in a single linear order.
We are asked to count the number of obtuse triangles that can be drawn inside an equilateral triangular tennis racket frame. The racket’s three sides each have n equally spaced holes.
We are given a sequence of words in fixed order, and we want to select a consecutive block of them, starting at some position and ending later, such that this block can be printed on a rectangular banner.
We are asked to divide n students into teams of exactly three. Some students explicitly request to be on the same team with certain other students. These requests are mutual, so if student 2 wants to team with student 5, then student 5 also wants student 2.
We are given two fixed digits, and we are allowed to build length-n numbers using only those two digits. Any such number is considered “valid” in the first sense, because every position is constrained to a two-element alphabet instead of the full decimal set.
We are asked to determine the minimum positive integer $n$ such that the factorial $n!$ divided by a set of numbers $[a1, a2, dots, ak]$ produces an integer. In other words, the Empire has a strike strength $n!$, and each Republican strike is represented by $ai$.
We are given a square table of size n × n, initially all white, with a black border around the edges. Vasily the bear can perform exactly k painting moves.
We are given an array of distinct integers and asked to split it into three non-empty sets. The first set must have a product less than zero, the second set a product greater than zero, and the third set a product equal to zero.
We are given an array of distinct non-negative integers s of length n. The goal is to split each element s[i] into a pair of non-negative integers a[i] and b[i] such that a[i] + b[i] = s[i]. We want both a and b to be almost unique.
The task is to determine whether it is possible for Alice's total fish weight to strictly exceed Bob's, given only the types of fish each caught. Fish types are numbered from 1 to k in non-decreasing weight order, but the exact weights are unknown.
We are given a circle with $2n$ labeled points arranged in order around the boundary. Each point is used exactly once as an endpoint of a chord, so the chords form a perfect matching on these $2n$ positions. Each chord connects two boundary points.
We are asked to color an h × w grid using at most k colors, while satisfying as many adjacency constraints as possible. Each square in the grid must be assigned an integer color between 1 and k.
We are given two binary strings, and we can transform the first string using two operations that behave like a sliding window with a dynamically growing tail. The first operation appends a single bit determined by the parity of the current number of ones in the string.
We are given two digit strings of equal length, but some positions may contain unknown characters represented by ?. Each ? can independently be replaced by any digit from 0 to 9, and choices in different positions do not interact.
Yaroslav has a sequence of integers, and he wants to rearrange them so that no two consecutive elements are equal. The only allowed operation is swapping two neighboring elements, and he wants to know if it is possible to reach a configuration satisfying this condition.
Every person weighs either 50 kg or 100 kg. A boat starts on the left bank and can carry any non-empty group whose total weight does not exceed the boat limit. Somebody inside the boat must steer it, so every crossing contains at least one passenger.
We have a set of points on the number line. Each point has an identity, so when an update says "move point p by d", only that specific point changes position. There are two operations.
We are asked to count the number of ways to paint a rectangle of size n by m with black and white cells so that it forms a "cave." In practical terms, each row can either be all white or have exactly two black cells.
We are given a complete weighted directed graph with n vertices, represented as an adjacency matrix. Each entry a[i][j] is the weight of the edge from vertex i to vertex j. The graph is complete, so every pair of distinct vertices has an edge in both directions.
We are given a sequence of horizontal wires, each with some birds sitting on it. Wires are numbered from top to bottom, and on each wire, the birds are lined up from left to right. Shaass shoots birds one by one.
We have a row of n lights. Some positions are already on, and all other positions are off. A move consists of choosing an off light that has at least one adjacent light already on, then switching it on. We continue until every light becomes on.
We are given a tree with n cities connected by n-1 roads, where each road has a positive length. Every pair of cities has a unique path connecting them.
We have a kitchen floor of size n×m tiles, all initially white. A robot stands on a border tile at coordinates (xs, ys) and faces one of the four diagonal directions. Each time the robot moves to a tile, it paints it black. If it hits a wall, it reflects like a billiard ball.
We are given a collection of books, each with a thickness of either 1 or 2 units and a width representing how many pages it occupies horizontally. Shaass wants to arrange all books on a single bookshelf.
Codeforces 293B: Distinct Paths
We are asked to analyze a turn-based game between two players, Yaroslav and Andrey, who each have a binary string of length 2·n. They alternately pick positions from the combined index set {1, 2, …, 2·n}.
We are given a tree with n vertices, where each edge carries a non-negative weight. For any two vertices, the distance between them can be measured in two ways: the number of edges along the path connecting them, and the sum of edge weights along that path.
We are given a convex polygon whose vertices have integer coordinates. Consider every lattice point, meaning every point with integer coordinates, that lies inside the polygon or on its boundary.
The three original cubes had side lengths $a$, $b$, and $c$. Their total number of unit cubes was $$a^3+b^3+c^3.$$ Vitaly wanted to build one larger cube whose side length was $a+b+c$, which would require $$(a+b+c)^3$$ unit cubes.
We are given a connected undirected graph representing a computer network. The task is not to analyze arbitrary graph structure, but to determine whether the graph exactly matches one of three specific topologies. A bus topology is simply a path.
We are given a sequence of tasks that arrive at a corporation's SMS center. Each task consists of a time ti when it arrives and a number ci of text messages to send. The SMS center can send at most one message per second, and messages are queued in the order they arrive.
We are asked to maintain two arrays of integers, a and b, each of length n. The first array a is static: its values never change.
We have an undirected graph representing a computer network. The vertices are computers and the edges are cables. The cables are numbered from 1 to m in the order they appear in the input.
We are given a set of decimal digits. We must find every IP address consisting of four integers between 0 and 255 such that, after writing the four numbers next to each other without dots, the resulting string is a palindrome. The digit restriction is strict.
We are given a list of secretaries and, for each, either a Spyke session number or 0 if the secretary is idle. Each positive session number represents an ongoing call between exactly two people.
Each IP address is really a 32-bit integer written in dotted decimal form. A subnet mask is also a 32-bit value, but it must have a very specific shape: some number of leading 1 bits followed by some number of trailing 0 bits.
We are given a rooted tree with $n$ vertices, where each edge is labeled with a non-empty string. The root of the tree is vertex 1. Each non-root vertex $v$ has a parent $pv$ and a string $sv$ on the edge from $pv$ to $v$.
We are asked to simulate a parallel memory-writing process. There are n processors and n memory cells. Each processor can only write to its corresponding cell, but all processors can read any cell. Initially, all cells except the last one contain 1, and the last cell contains 0.
We are given a single command-line string written in the fictional Pindows operating system. A command line consists of lexemes, which are the tokens passed to a program. There are two ways a lexeme can appear. A normal lexeme is a maximal sequence of non-space characters.