brain

tamnd's digital brain — notes, problems, research

43815 notes

CF 178C2 - Smart Beaver and Resolving Collisions

We are simulating a hash table that supports inserting and deleting items, but insertion is not direct. Each item has a preferred starting position given by its hash value, and if that slot is occupied, the table probes forward in fixed jumps of size m modulo h until it finds…

codeforcescompetitive-programming
CF 178C1 - Smart Beaver and Resolving Collisions

We are simulating a hash table where each object is assigned a preferred position given by its hash value, but collisions are resolved using a fixed step size. When an object is inserted, we first try its hash position.

codeforcescompetitive-programming
CF 178B3 - Greedy Merchants

We are given an undirected connected graph where cities are nodes and roads are edges. For each merchant, we are also given a pair of cities: a warehouse city and a shop city. The merchant needs to ship goods from the warehouse to the shop using any path in the graph.

codeforcescompetitive-programming
Kvant Math Problem 784

The length of daylight at latitude $\varphi$ depends on the declination $\delta$ of the star.

kvantmathematicsolympiad
CF 178B2 - Greedy Merchants

We are given a connected undirected graph of cities linked by roads. Each merchant chooses two cities, one as a source (warehouse) and one as a destination (shop).

codeforcescompetitive-programming
CF 178B1 - Greedy Merchants

We are given an undirected connected graph representing cities and roads. Each road can be removed, and this may or may not break connectivity between two specific cities. Alongside the graph, we are given multiple merchants.

codeforcescompetitive-programming
CF 178A2 - Educational Game

We are given a sequence of non-negative integers representing some kind of “counters” along a line, indexed from 1 to n. The task is to reduce the first k elements of the sequence to zero, for every possible prefix length k (from 1 to n-1).

codeforcescompetitive-programminggreedy
Kvant Math Problem 783

Consider the first system of inequalities: $1 < x < 2$, $2 < x^2 < 3$, $3 < x^3 < 4$, and so on up to $n < x^n < n+1$.

kvantmathematicsolympiad
Kvant Math Problem 781

Consider triangle $ABC$ and a line parallel to $AC$ intersecting $AB$ at $D$ and $BC$ at $E$ such that $|AD| = |BE|$.

kvantmathematicsolympiad
Kvant Math Problem 779

We are asked to study sequences of positive numbers $x_0, x_1, x_2, \dots$ with $x_0 = 1$ and $x_0 \ge x_1 \ge x_2 \ge \dots$.

kvantmathematicsolympiad
Kvant Math Problem 778

Let the triangle be isosceles with $A_2A_3=a_1$ as the base and $A_1A_2=A_1A_3$.

kvantmathematicsolympiad
Kvant Math Problem 777

The given equation is cubic in two variables, $x$ and $y$:

kvantmathematicsolympiad
Kvant Math Problem 776

Consider a regular hexagon $ABCDEF$ with vertices labeled consecutively.

kvantmathematicsolympiad
Kvant Math Problem 775

Consider small values of $n$ to detect patterns.

kvantmathematicsolympiad
Kvant Math Problem 774

Condition (2) resembles a midpoint convexity-type inequality, but in the reversed direction: usually convexity gives $f\left(\frac{x+y}{2}\right)\le \frac{f(x)+f(y)}{2}$, whereas here we have $f\left(…

kvantmathematicsolympiad
Kvant Math Problem 773

Let the side lengths be

kvantmathematicsolympiad
Kvant Math Problem 772

We are asked to train 8 workers on 5 machines so that any 3 absences still allow operation of all machines.

kvantmathematicsolympiad
Kvant Math Problem 771

Let $O$ be the common point which is simultaneously the circumcenter of $\triangle ABC$ and the incenter of $\triangle ABK$.

kvantmathematicsolympiad
Kvant Math Problem 769

Let $I=L$ be the incenter.

kvantmathematicsolympiad
Kvant Math Problem 768

Consider small values of $n$ first.

kvantmathematicsolympiad
Kvant Math Problem 767

For the first statement, choose coordinates so that the bisecting line $l$ is the vertical line $x=0$.

kvantmathematicsolympiad
Kvant Math Problem 764

The task is purely existential.

kvantmathematicsolympiad
Kvant Math Problem 762

The two inequalities are

kvantmathematicsolympiad
Kvant Math Problem 761

The statement is affine in nature.

kvantmathematicsolympiad
Kvant Math Problem 759

Let the outer convex quadrilateral be $ABCD$, and let the inner quadrilateral have vertices $P,Q,R,T$.

kvantmathematicsolympiad
Kvant Math Problem 757

Let an arithmetic progression of reciprocals be

kvantmathematicsolympiad
Kvant Math Problem 755

Consider a tetrahedron with vertices $A$, $B$, $C$, and $D$, and a point $M$ inside it.

kvantmathematicsolympiad
Kvant Math Problem 753

The problem gives three numbers $a$, $b$, $c$ in the interval $(0, \frac{\pi}{2})$ satisfying

kvantmathematicsolympiad
Kvant Math Problem 751

Begin by examining small examples.

kvantmathematicsolympiad
Kvant Math Problem 750

The first statement is a classical rectangle theorem.

kvantmathematicsolympiad
Kvant Math Problem 748

Consider first the planar problem with parabolas.

kvantmathematicsolympiad
Kvant Math Problem 747

For the first part, write the numbers as $x_1,\dots,x_n$, let $M=\max x_i$ and $m=\min x_i$.

kvantmathematicsolympiad
Kvant Math Problem 745

For the first problem, let

kvantmathematicsolympiad
Kvant Math Problem 743

Part (1) is the classical two-color complete graph statement.

kvantmathematicsolympiad
Kvant Math Problem 742

Let the points be represented by vectors $x_1,\dots,x_n$ from the center of the circle or sphere.

kvantmathematicsolympiad
Kvant Math Problem 740

Consider a right circular cylindrical pot with radius $R$ and height $H$.

kvantmathematicsolympiad
Kvant Math Problem 738

Consider a polygon in the plane, labeled $A_1 A_2 \dots A_n$.

kvantmathematicsolympiad
Kvant Math Problem 737

Let the houses have populations $h_1,h_2,\ldots,h_n$, arranged in nonincreasing order.

kvantmathematicsolympiad
Kvant Math Problem 735

Consider first the case of covering a circle of diameter $1$ with strips of paper.

kvantmathematicsolympiad
Kvant Math Problem 733

We begin by examining small powers of $31$ modulo powers of $2$ to understand the first part of the problem.

kvantmathematicsolympiad
Kvant Math Problem 732

I cannot write a rigorous solution to Kvant problem M732 because the problem statement itself is not present in your message.

kvantmathematicsolympiad
Kvant Math Problem 730

The sequence $(a_n)$ is defined recursively by $a_1=0$ and $a_{2n}=a_{2n+1}=n-a_n$.

kvantmathematicsolympiad
Kvant Math Problem 728

Consider a parallelepiped with vertex $P$ at the origin, edges along vectors $\vec{a}$, $\vec{b}$, $\vec{c}$ leading to adjacent vertices $A = P + \vec{a}$, $B = P + \vec{b}$, $C = P + \vec{c}$.

kvantmathematicsolympiad
Kvant Math Problem 727

Since the perimeter is $2$, we have

kvantmathematicsolympiad
Kvant Math Problem 725

The sequence $r_n$ sums the $n$-th powers of the cosines of the angles $\pi/7$, $3\pi/7$, and $5\pi/7$.

kvantmathematicsolympiad
Kvant Math Problem 724

Consider two turtles moving at the same speed but in different directions.

kvantmathematicsolympiad
Kvant Math Problem 722

Consider the simplest nontrivial cases first.

kvantmathematicsolympiad
Kvant Math Problem 720

The function $f$ is defined recursively on nonnegative integers.

kvantmathematicsolympiad
Kvant Math Problem 719

Consider small values of $n$ to understand the property.

kvantmathematicsolympiad
Kvant Math Problem 717

Consider small values of $n$ and $r$ to detect a pattern.

kvantmathematicsolympiad
Kvant Math Problem 716

Let

kvantmathematicsolympiad
Kvant Math Problem 714

Consider small values of $N$ to build intuition.

kvantmathematicsolympiad
Kvant Math Problem 713

Let the finite set be $M$.

kvantmathematicsolympiad
Kvant Math Problem 711

Consider a convex quadrilateral $ABCD$ inscribed in a circle with diagonals $AC$ and $BD$ perpendicular at some point $P$.

kvantmathematicsolympiad
Kvant Math Problem 709

The rhombus tiles are the unit lozenges of the triangular lattice.

kvantmathematicsolympiad
Kvant Math Problem 707

Let the clubs be represented by sets of students.

kvantmathematicsolympiad
Kvant Math Problem 706

Consider two circles with centers $O_1$ and $O_2$ and radii $R_1$ and $R_2$.

kvantmathematicsolympiad
Kvant Math Problem 703

The first equation links three expressions of the form $t + \frac{1}{t}$ multiplied by constants 3, 4, and 5.

kvantmathematicsolympiad
Kvant Math Problem 701

Let the sides of the acute triangle $LMN$ be

kvantmathematicsolympiad
Kvant Math Problem 700

Consider the set of all terminating decimal fractions.

kvantmathematicsolympiad
Kvant Math Problem 698

Let the cyclic quadrilateral be $ABCD$, with side lengths

kvantmathematicsolympiad
Kvant Math Problem 696

Consider the problem for small $k \times k$ squares.

kvantmathematicsolympiad
Kvant Math Problem 695

Let the table have $m$ rows and $n$ columns.

kvantmathematicsolympiad
Kvant Math Problem 693

Consider small-scale analogues of the village communication problem.

kvantmathematicsolympiad
Kvant Math Problem 692

Consider triangle $ABC$ with arbitrary side lengths $AB=c$, $BC=a$, $CA=b$.

kvantmathematicsolympiad
Kvant Math Problem 690

For a convex polygon, the quantity $\dfrac{2S}{P}$ has a geometric meaning.

kvantmathematicsolympiad
Kvant Math Problem 688

Let

kvantmathematicsolympiad
Kvant Math Problem 686

Let

kvantmathematicsolympiad
Kvant Math Problem 685

Let the partition be

kvantmathematicsolympiad
Kvant Math Problem 683

Represent each circle by a vertex, and join two vertices when the corresponding circles touch.

kvantmathematicsolympiad
Kvant Math Problem 681

Let

kvantmathematicsolympiad
Kvant Math Problem 680

The game is equivalent to building a connected graph on $n$ vertices by adding edges one at a time.

kvantmathematicsolympiad
CF 177G2 - Fibonacci Strings

We are given a very large Fibonacci-like string, but we are never asked to construct it directly. Instead, we are asked to count how many times each query string appears as a substring inside that Fibonacci string.

codeforcescompetitive-programmingmatricesstrings
CF 177G1 - Fibonacci Strings

We are given a very large string that is not explicitly constructed in the input. Instead, it is defined recursively in the same way as Fibonacci words: the first string is "a", the second is "b", and every later string is obtained by concatenating the previous string with the…

codeforcescompetitive-programmingstrings
Kvant Math Problem 678

Consider small examples first.

kvantmathematicsolympiad
CF 177F2 - Script Generation

We are given a bipartite graph between men and women. Each allowed edge represents a possible marriage and carries a positive weight that measures how much the audience enjoys that couple.

codeforcescompetitive-programming
CF 177F1 - Script Generation

We are given a bipartite set of characters: $n$ men and $n$ women. Between them there are $k$ possible marriage pairs, and each pair has a positive value representing audience delight if that couple ends up together.

codeforcescompetitive-programming
CF 177E2 - Space Voyage

We are choosing a positive integer value $x$, which represents how many “presents per suitcase” the Smart Beaver packs. The total number of suitcases is fixed: for each planet $i$, he carries exactly $ai$ suitcases, so the total number of suitcases is the sum of all $ai$.

codeforcescompetitive-programmingbinary-search
CF 177E1 - Space Voyage

The voyage is defined by a fixed sequence of planets. At each planet, the Beaver carries a fixed number of suitcases, and each suitcase contains the same number of presents, denoted by a single unknown value $x$.

codeforcescompetitive-programmingbinary-search
CF 177D2 - Encrypting Messages

We are given a sequence of integers representing a message and another shorter sequence representing a key. Both sequences are over a fixed modular range from 0 to c minus 1, and every addition wraps around modulo c. Encryption is defined as a repeated sliding process.

codeforcescompetitive-programmingdata-structures
Kvant Math Problem 676

We begin by computing small powers of $1981$ and observing the sums of their digits.

kvantmathematicsolympiad
CF 177D1 - Encrypting Messages

We are given a sequence of integers that represents a message, and another shorter sequence that acts as a repeating “window update pattern”. The encryption process repeatedly slides this pattern across the message from left to right.

codeforcescompetitive-programmingbrute-force
CF 177C2 - Party

We are given a set of people where some pairs are connected by friendship relations and some pairs are in conflict because they dislike each other.

codeforcescompetitive-programmingbrute-forcedfs-and-similardsugraphs
CF 177C1 - Party

We are given a set of people, where some pairs are friends and some pairs dislike each other. Friendship forms an undirected graph, and dislike forms another set of forbidden edges. The task is to choose a subset of people such that two constraints hold simultaneously.

codeforcescompetitive-programmingdfs-and-similardsugraphs
CF 177B2 - Rectangular Game

We start with n pebbles. At any move, if we currently have x pebbles, we must arrange them into a equal rows of length b, where a 1 and x = a · b. After creating the rows, we keep exactly one row and discard all others. The number of pebbles becomes b.

codeforcescompetitive-programmingnumber-theory
CF 177B1 - Rectangular Game

The game starts with n pebbles. At every move, we must split the current number of pebbles into a equal rows of size b, where a 1 and a b = current. After creating the rows, we keep exactly one row and throw away all others. That means the next number in the sequence becomes b.

codeforcescompetitive-programmingnumber-theory
Kvant Math Problem 674

Consider an acute triangle $ABC$ with arbitrary points $A_1$ on $BC$, $B_1$ on $AC$, and $C_1$ on $AB$.

kvantmathematicsolympiad
CF 176C - Playing with Superglue

We have two chips on an $n times m$ grid. On each turn, the first player moves exactly one non-glued chip by one square in the four-neighbor grid. After that, the second player permanently glues one currently empty square. A chip is allowed to move onto a glued square.

codeforcescompetitive-programmingcombinatoricsconstructive-algorithms
CF 176B - Word Cut

Each operation chooses a non-empty prefix and a non-empty suffix of the current word and swaps their order. If the current word is written as xy, where both x and y are non-empty, the operation transforms it into yx. A useful way to view this operation is as a cyclic rotation.

codeforcescompetitive-programmingdp
Kvant Math Problem 673

Label the pucks $A$, $B$, and $C$, and denote their initial positions by the points $A_0$, $B_0$, and $C_0$ of a triangle in the plane.

kvantmathematicsolympiad
CF 176E - Archaeology

We are given a weighted tree. Villages correspond to vertices and roads correspond to weighted edges. At any moment, only some villages are "alive". Villages can be added and removed over time.

codeforcescompetitive-programmingdata-structuresdfs-and-similartrees
CF 176D - Hyper String

Codeforces 176D: Hyper String

codeforcescompetitive-programmingdp
Kvant Math Problem 671

Let the cyclic quadrilateral be $ABCD$ with diagonals $AC$ and $BD$.

kvantmathematicsolympiad
CF 176A - Trading Business

We have several planets. On each planet, every item type has three values: - The price to buy one unit on that planet. - The price at which that planet buys one unit from us. - The number of units available for purchase.

codeforcescompetitive-programminggreedysortings
CF 175B - Plane of Tanks: Pro

Codeforces 175B: Plane of Tanks: Pro

codeforcescompetitive-programmingimplementation
CF 175A - Robot Bicorn Attack

We are given a string of digits that was formed by writing the scores from three game rounds one after another, without any separators. Originally there were exactly three non-negative integers.

codeforcescompetitive-programmingbrute-forceimplementation
CF 175F - Gnomes of Might and Magic

I can’t provide the complete editorial and verified Python solution for this problem from the information available to me alone. This is a very old Codeforces 3000-rated problem, and the accepted solution is quite intricate.

codeforcescompetitive-programmingdata-structuresgraphsimplementationshortest-paths
Kvant Math Problem 669

Consider a cyclic quadrilateral $ABCD$ with circumcircle $\Gamma$.

kvantmathematicsolympiad
CF 175E - Power Defence

Codeforces 175E: Power Defence

codeforcescompetitive-programmingbrute-forcedpgeometrygreedy
CF 175D - Plane of Tanks: Duel

Two tanks start fighting at time 0. Both fire immediately, then continue firing every dt seconds. Each shot may fail to penetrate armor, and if it penetrates, the damage is chosen uniformly from an integer interval.

codeforcescompetitive-programmingbrute-forcedpmathprobabilities