brain
tamnd's digital brain — notes, problems, research
43815 notes
Each layer can have only one of four stable configurations that matter to the game. A completely intact layer is III. A layer with two blocks is either II. or .II, and these two cases have identical game behavior, so we can treat them as one state.
We have a simple undirected graph on at most 13 vertices. We choose a subset of its edges, while keeping the whole vertex set, and ask whether the resulting spanning graph is a cactus. A cactus is connected, and no edge may belong to two different simple cycles.
We have a weighted set of vertices and a list of indexed edges. Initially there are no graph edges, so every vertex is its own connected component.
The graph has one vertex for every distinct non-empty substring of the input string s. From a substring t of length L, an edge goes to every distinct substring of t of length L-1.
We are given a recommended microwave cooking time in MM:SS form and a percentage p. Chris is allowed to choose any integer number of seconds whose distance from the recommended time is at most p percent of that recommended time.
The students have distinct ages, so an arrangement of the class is simply a permutation of the numbers (1,ldots,s). Henry's maximum number of circled students is the length of the longest increasing subsequence of that permutation.
We have a coin system containing n distinct denominations, including denomination 1. Andrew must pay separately for every amount in the consecutive interval [l, r]. For each amount, he wants the minimum possible number of coins whose values sum exactly to that amount.
The roads form a tree, so between any two places there is exactly one route. An employee assigned to go from a to b uses every edge on that unique path on every day from s through t. Paul pays once for an edge on a given day, regardless of how many employees use that edge.
We have a transportation network with up to 400 cities. Every city has an associated switching cost. A package can travel between cities using one of four transport modes: AIR, SEA, RAIL, or TRUCK. Each route segment is undirected and belongs to exactly one transport mode.
The CD contains t tracks numbered from 1 through t, arranged cyclically. Anya specifies a sequence of tracks that must be played in exactly that order. The first requested track is already cued, so no button press is needed for it.
We need to count arrays of length (N), where every element is one of (0,1,2), such that every three consecutive elements satisfy [ a{i-1}a{i+1}le ai^2. ] The answer is required modulo (10^9+7).
Think of every Pokemino as a point ((A,D)) in the plane, where attack is the horizontal coordinate and defense is the vertical coordinate.
We need to find every positive integer that is simultaneously a divisor of a and a multiple of b. The input gives the two integers a and b, with b <= a and both potentially as large as 10^12.
Each practice starts with a fixed number of brownies and a known number of students. Students arrive at the refreshment table in groups. Every student in a group takes exactly one brownie, but before that happens Dr.
We receive the switches one by one. Switch i has an integer label a[i], and if two switches with labels x and y are connected, that channel costs x XOR y.
We have a tree whose vertices are colored with two colors, represented by 0 and 1. We may either flip the color of one still-existing vertex, paying one operation, or choose a vertex and destroy the entire connected component of its current color containing that vertex, also…
We need to cut one cake into a small number of integer-weight pieces. The number of guests is not known in advance: it will be exactly (A), (B), or (C).
A positive integer has an odd number of positive divisors exactly when it is a perfect square. Every non-square has divisors that can be paired as d and n/d, while a square has one unpaired divisor, namely its square root. So the task can be restated as follows.
We need to transform a lowercase word using a Caesar cipher. The input first tells us whether to encode or decode. Encoding moves every letter forward by a fixed shift s, while decoding moves every letter backward by the same amount.
We have a tree with (N) cities. A terminal city is simply a leaf, a vertex whose degree is exactly one. The tree itself is hidden from us. We cannot inspect its edges directly.
We have an (ntimes n) board containing at most one chess piece in each cell. Every piece is either white or black and has a positive removal value. A white and a black piece may be removed together if both are currently exposed from the bottom-left direction.
For each query point (A), we have to choose two distinct original points (Pu) and (Pv). The three points must form a non-degenerate triangle with one angle equal to (90^circ). The output for that query is the number of such unordered pairs of original points.
We have a prime modulus (p) and an array (a1,ldots,an), where every array value is nonzero modulo (p). For two nonzero residues (a,b), we need the smallest positive exponent (u) such that (a^u) belongs to the cyclic subgroup generated by (b). Call that value (f(a,b)).
Asai Kei chooses a non-empty subsequence of a, while the director chooses a non-empty subsequence of b. A chosen sequence such as (2, 1, 2) is interpreted as a base-1000 number, so its value is 2 1000^2 + 1 1000 + 2.
We have all binary strings of length (N), representing the possible results of (N) tosses of the same possibly biased coin. Carla and Daniel must assign every chosen string to at most one of them, while some strings may remain unused.
The street is a graph with two rows and (N) columns. Each house is a vertex. Two houses are connected when their positions differ by at most one row and at most one column, so horizontal, vertical, and diagonal moves are all allowed.
We have an (N times N) matrix. Row (i) represents ornament (i), and column (j) represents shelf position (j). The value (a{i,j}) measures how confident Fulano is that ornament (i) originally occupied position (j).
We need to choose an integer distance (r) around every river so that the union of all preserved regions covers at least (P%) of the rectangular territory. Each river is an axis-aligned line segment.
The election result is represented by an array of vote counts, where the first position belongs to Carlos and every later position belongs to a candidate who registered after him. The winner is the candidate with the largest number of votes.
For every query, we have several Infernape placed on vertices of one fixed tree. An Infernape at vertex (vi) with power (ri) heats exactly the vertices whose tree distance from (vi) is at most (ri). A vertex is considered good if at least (k-1) of the (k) Infernape heat it.
There are (k) stacks, each containing one fragment of every one of the (n) stones. Since every stack contains every stone exactly once, each stack is a permutation of (1,ldots,n).
We need to assign a distinct nonempty binary codeword to each of (n) words. The code must be prefix-free, so the codewords form the leaves of a binary trie. There is one additional restriction: a codeword may never contain 00.
We have an array of up to (300000) integers, each using at most 60 bits, and a threshold (x). A subsequence is considered good when every pair of selected array elements has XOR at least (x).
Petya throws one ball every minute toward Vova. The distance between them is L, and every ball moves at speed X, so a ball needs L / X minutes to reach Vova. Vova does not shoot balls immediately. He starts shooting when a ball gets within distance D of him.
We have an array a of n animals. The value a[i] is the amount of time Doctor Aibolit needs to examine animal i. The doctor handles one animal at a time, so the animals form a single queue. For a chosen order, the first animal waits 0 time units.
We have a circular arena with (N) positions numbered from (0) to (N-1). Every position is either a rock, written as R, or a pond, written as P. The frog may start at any rock. After choosing a jump length (K), every jump moves the frog from position (i) to [ (i+K)bmod N.
We have three stacks. The dirty stack initially contains a permutation of 1..n. A type 1 operation removes between 1 and a plates from the top of the dirty stack and places them, without changing their internal order, on the intermediate stack.
We are given several independent soccer groups. Each group contains a set of uniquely named teams and a collection of already played matches. For every match, we know both teams and their final scores. From those results, we must build the complete standings table.
We have a row of n lanterns, exactly k of them are on, and 4 <= k <= n <= 100. We can ask the judge about any subset of lanterns. If that subset contains x lit lanterns, the judge does not reveal x. Instead, it returns the number of divisors of x that are composite.
A valid Type (N) song is exactly a binary de Bruijn cycle of order (N). Its period has length (2^N), and every binary string of length (N) appears exactly once during one period. The input gives (N), followed by two length-(N) strings (S) and (T).
We have a collection of n item types. Item i has a price given to exactly two decimal places, and when constructing a shopping spree we choose exactly k items in sequence.
For each query, we have two integers a and b. We look at every integer from 1 through b and count it if it is divisible by at least one integer from 2 through a. The answer is the size of that union of sets of multiples.
The game contains several item types. For each type, we know how many copies are required and the probability of obtaining that type on an attempt. We also know the total number of attempts available.
The problem uses a small custom keyboard containing all 26 lowercase letters. The letters are arranged in three rows: Two words are given for each test case. We must classify the pair into one of three categories.
We are given ordinary C++ arithmetic expressions whose operands are identifiers made only from English letters. The operators are binary +, -, , /, and %, and parentheses may change the evaluation order.
We have two groups of features. The first group contains (n) features and the second contains (m) features. Every feature has a positive weight, and some pairs are declared incompatible.
Each test case gives one non-negative integer representing a complete 128-bit IPv6 address. An IPv6 address has exactly eight 16-bit sections, so the first job is to write the integer as exactly 32 hexadecimal digits and split those digits into eight groups of four.
We have an undirected graph whose vertices are the Orz Pandas and whose edges are possible data links. Every edge has two positive values, a and b. For a chosen set of edges S, the communication requirement says that the chosen edges must form a connected spanning subgraph.
There are (n) boxes arranged from left to right. A type 1 operation chooses an interval ([l,r]), a digit (x), and an offset (c). For every position (p) in that interval, where (p=l+k-1), exactly one new paper strip is placed into box (p).
The program generates the standard recursive solution to the Tower of Hanoi problem. For a tower of n disks, it first moves the top n-1 disks from the source peg to the auxiliary peg, then moves disk n from the source to the destination, and finally moves the n-1 disks from…
We have (n) luminous bodies, each described by its distance from Earth and its angular position around Earth. The observatory can choose any radial interval of length (d), written as ([x,x+d]), and any angular interval of length (alpha), written as ([omega,omega+alpha]).
We have two DNA strings A and B, both of length n. The only characters that can appear are A, T, G, and C. We do not need to construct the common subsequence. We only need to decide whether its maximum possible length is at least 0.99n.
Each input line is an arithmetic expression built from fractions, addition, subtraction, and parentheses. A fraction appearing in the expression has a numerator from 0 through 100 and a positive denominator from 1 through 20.
We are given several pairs of points. Each pair determines an infinite straight subway line through those two points. The actual segment between the points is irrelevant because the subway line extends indefinitely.
We have an integer array C of length N. A candy sequence is any non-empty contiguous part of this array, and its value is the sum of its elements. The required answer is not the number of positions where a valid sequence occurs.
We need to choose one prime number and change every element of the array into that prime. Changing an element by one costs exactly one operation, so if the chosen prime is p, the total cost is f(p)= i=1 ∑ N ∣a i −p∣.
We have at most 2000 distinct points on a coordinate plane. A valid rectangle must use four of these points as its corners, its sides must be horizontal or vertical, and there must be no other given point anywhere inside the rectangle or on one of its four sides.
We maintain a collection of matryoshkas. Every doll has a positive integer weight and a unique identifier. A doll can contain several smaller dolls, but the total weight of everything directly or indirectly inside an outer doll must not exceed the outer doll's weight.
We need to decide whether one input line can be generated from the nonterminal M of the given grammar. The line contains digits, whitespace, and the punctuation characters :, The grammar describes three layers. T is either a digit sequence or a complete { M } expression.
We have an (n times n) directed grid. A disk can move only one cell down or one cell right, so every disk follows a monotone path from the upper-left corner to the lower-right corner.
The stamp is a fixed axis-aligned cross consisting of five cells: the center cell and its four orthogonally adjacent cells. A stamping turns those five paper cells black.
Each test case describes the medal counts of two countries, USA and Russia. The six integers are ordered as USA gold, silver, bronze, followed by Russia gold, silver, bronze. There are two independent ways to decide whether USA wins.
We have an array of $N$ songs. Song $i$ normally has volume $Hi$, and lowering its volume by one unit costs $Ai$ units of event success. The teachers need a period of exactly $M$ consecutive minutes during which the volume is constant.
We have two rows of (n) students. Student (i) in the first row has height (ai), and student (i) in the second row has height (bi). A team is formed by taking students from left to right, so the indices of chosen students must be strictly increasing.
The archived Codeforces contest lists problem B as «Большие часы и маленькая окружность», with a 2 second time limit and 512 MB of memory.
We need to choose a positive integer (x) such that (x^n) is divisible by (m), and among all such positive integers we need the smallest one. If no such (x) exists, we print ABSENT.
We need to count the positive integers from 1 through r that are coprime with n. Two numbers are coprime when their greatest common divisor is exactly 1. The input contains two integers, n and r, each at most 10^9.
We have a triangular cookie cutter whose side lengths are (a), (b), and (c), and a circular cookie cutter with radius (r).
We are given the side length n of a square. The square must contain every integer from 1 through n² exactly once, with every row, every column, and both main diagonals having the same sum. The required output is only that common sum, not the square itself.
There are (n) drivers and (n) Gazelle cars. Each driver receives exactly one car, and every car is assigned to exactly one driver, so an assignment is a permutation of the cars. A driver is called fixed if they receive their own car.
We have two independent minibuses. During the one-hour interval from 08:00 to 09:00, each minibus reaches the intersection exactly once, and its arrival time is uniformly distributed over the 3600 seconds of the hour. The traffic light starts with green at time 0.
We have a starting point on a road and a destination somewhere away from that road. The straight-line distance between the starting point and the destination is s, while the perpendicular distance from the destination to the road is h.
Each line in the notebook contains only a driver's surname. A driver writes the surname once when leaving the garage and once when returning. The notebook does not tell us which occurrence is a departure and which is a return.
We are given two prime numbers, (p) and (q), and need to decide whether [ (p+1)^q ] is a perfect square. The numbers can contain up to (1000) decimal digits, so they are far beyond ordinary machine integer types.
We have a collection of individual banknotes. Each banknote has a denomination, and every banknote can be used at most once. Given a fine amount p, we need to choose some of the available banknotes whose total value is as small as possible while still being at least p.
A route has a value k. If a passenger wants to travel through n stops, the fare is the n-th k-gonal number. For k = 4, these are square numbers, for k = 3 they are triangular numbers, and larger values of k describe regular polygonal figures with more sides.
We have n drivers, initially ordered by the positions they occupy in the log. The log is a single string of R, S, and P, but the boundaries between game rounds have been erased.
У нас есть n установленных программ, пронумерованных от 1 до n. Для каждой программы известно, какие другие программы обязаны оставаться установленными в…
The function foo(a, b) repeatedly subtracts a from b until the current value becomes non-positive. The final value is zero exactly when a divides b. The function then recursively replaces a by 2a and 2a+1, so starting from a=1 it can eventually reach every positive integer.
The wormholes form a directed graph. Each known transition goes from one wormhole to another and has one of two costs. A hypertransition costs one ant-hour, while a null transition costs zero. The ship starts at wormhole 1 and has to reach wormhole n.
We have (n) separate chains. The (i)-th chain contains (ai) rings. An operation opens one ring, removes it from its original chain, and then closes that ring around the ends of two chains. The opened ring therefore becomes a connector between two pieces.
We are given an addition written with words instead of digits, such as VOLVO+FIAT=MOTOR. Every distinct letter must be assigned a digit from 0 through 9. Two different letters must receive different digits, while every occurrence of the same letter receives the same digit.
We have two matchboxes, each initially containing exactly n matches. Every time Professor X needs a match, he chooses one of the two pockets uniformly at random and tries to take a match from that box.
We have an n × m rectangular grid of unit cells. Among these cells, k are marked as important. We need to count every axis-aligned rectangle of cells that contains all marked cells. There is one restriction: the chosen rectangle must not be the entire grid.
We have a collection of identical generators. The documentation says that exactly n generators produce k joules during m minutes. The required system must produce at least q joules during p minutes.
We start with n repair robots and m independent nanodamages. During one second, every existing robot chooses exactly one action. It either repairs one damage, or spends the second creating one new robot. A newly created robot becomes available from the following second.
We have three points in three-dimensional space. The first point is the position of our spacecraft and laser cannon, the second is the center of an enemy spherical spacecraft together with its radius, and the third is the point selected by the targeting system.
We have a single pile of n cookies. Two players remove cookies alternately, with Professor X moving first. A legal move removes p^k cookies, where p is prime and k is a nonnegative integer. Since k = 0 is allowed, removing exactly 1 cookie is always legal.
We have two strings, s1 and s2. The first string is the text that should have been copied, while the second is the text that was actually written. During copying, two kinds of mistakes are allowed: a character can be omitted, or a character can be replaced by another character.
We have an (n times n) grid. Some cells contain positive integers and the rest contain zero. Every row and every column must contain exactly two nonzero cells.
We have two circles in the Cartesian plane. Each circle is described by the integer coordinates of its center and its positive integer radius. The task is to determine how many points belong to both circles and to print those points with sufficient numerical precision.
The building is organized into entrances, floors, and apartments. Every entrance contains exactly n floors, and every floor contains exactly m apartments.
The task looks like an ordinary arithmetic problem, but the central difficulty is deliberately hidden in the statement. For test number (k), the author generated the answer as the last decimal digit of [ g(k)=nk+c, ] where (n) and (c) are fixed integers chosen by the author.
The input describes an undirected graph whose vertices are people and whose edges represent pairs of people who are "true friends". The company is guaranteed to be connected, meaning that for every pair of people there is a chain of true-friend relationships between them.
We have a rectangular grid of at most (100 times 100) cells. Some cells are walls and cannot be entered, while the remaining cells are traversable. One traversable cell contains the robot initially.
A snail starts at height 0 and climbs Mount Fuji, whose height is fixed at 3776 meters. During each day it climbs exactly n meters. If it has not reached the summit after that climb, the following night makes it slide down m meters.
We need to work with the increasing sequence of all positive integers whose prime factors belong to the fixed set {2, 3, 5, 7, 11}. Such numbers can be written exactly as [ 2^a3^b5^c7^d11^e, ] where all five exponents are nonnegative integers.
There are (n) students, and each student names one of (k) possible drinks. Andrew has exactly (lceil n/2rceil) packages. Each package contains two half-portions, so one package can satisfy at most two students, and both of those students must have requested the same drink.
We have a queue of (N) packages. Each package belongs to one of four groups, represented by the digits 6, 7, 8, and 9. Reading the groups from left to right gives the number whose value defines the beauty of the queue.
We have Grisha's string s, and a collection of letter cards represented by another string t. Every character of t corresponds to one physical card, so only the number of available copies of each letter matters.