brain

tamnd's digital brain — notes, problems, research

41787 notes

CF 234G - Practice

We have n football players, numbered from 1 to n. Each practice consists of splitting all players into two non-empty teams.

codeforcescompetitive-programmingconstructive-algorithmsdivide-and-conquerimplementation
CF 234F - Fence

We are given a fence made of n vertical boards, each with a specified height. Vasya has two paint colors, red and green, each with a limited total area he can paint. Every board must be painted exactly one color, and the total painted area of each color cannot exceed its limit.

codeforcescompetitive-programmingdp
CF 234E - Champions' League

We are asked to simulate a simplified version of the UEFA Champions League group stage draw. There are n teams, with n divisible by four, each assigned a unique rating. The goal is to divide the teams into groups of four, following a structured "basket" draw procedure.

codeforcescompetitive-programmingimplementation
Kvant Math Problem 1140

Each intersection point is a crossing of two branches.

kvantmathematicsolympiad
CF 234D - Cinema

Vasya has a list of movies and a list of favorite actors. Each movie lists some of its cast, but some actor IDs may be missing (represented by 0).

codeforcescompetitive-programmingimplementation
CF 234A - Lefthanders and Righthanders

We are asked to seat an even number of students, each either left-handed or right-handed, at desks that hold exactly two students. Each desk has a left and a right position.

codeforcescompetitive-programmingimplementation
CF 232C - Doe Graphs

We are asked to compute shortest paths in a family of recursively defined graphs called Doe graphs. Each graph is defined by an order n. The base cases are trivial: D(0) is a single vertex and D(1) is two vertices connected by one edge.

codeforcescompetitive-programmingconstructive-algorithmsdivide-and-conquerdpgraphsshortest-paths
Kvant Math Problem 1139

For a convex polyhedron whose faces are all squares, every face angle equals $90^\circ$.

kvantmathematicsolympiad
CF 232A - Cycles

We are asked to construct an undirected graph with exactly k triangles, where a triangle is a set of three vertices all connected pairwise.

codeforcescompetitive-programmingbinary-searchconstructive-algorithmsgraphsgreedy
Kvant Math Problem 1138

The expression $n^2+n+3\sqrt n$ is not always an integer.

kvantmathematicsolympiad
CF 232E - Quick Tortoise

Codeforces 232E: Quick Tortoise

codeforcescompetitive-programmingbitmasksdivide-and-conquerdp
CF 232D - Fence

We have an array of plank heights. A fence piece is simply a contiguous segment. For a query segment $[l,r]$, we must count how many other segments of the same length match it. Matching has three requirements. The two segments must have equal length. They must be disjoint.

codeforcescompetitive-programmingbinary-searchdata-structuresstring-suffix-structures
Kvant Math Problem 1137

Consider first small polygons.

kvantmathematicsolympiad
Kvant Math Problem 1136

Testing small integer values for $A$, $M$, and $S$ helps to gain intuition about the inequality.

kvantmathematicsolympiad
Kvant Math Problem 1135

Let

kvantmathematicsolympiad
CF 232B - Table

Codeforces 232B: Table

codeforcescompetitive-programmingbitmaskscombinatoricsdpmath
Kvant Math Problem 1134

Consider a right triangle $ABC$ with right angle at $A$ and altitude $AD$.

kvantmathematicsolympiad
CF 231A - Team

Three friends evaluate each contest problem independently. For every problem, we are given three values, each either 0 or 1. A value of 1 means that friend is confident they know how to solve the problem. A value of 0 means they are not confident.

codeforcescompetitive-programmingbrute-forcegreedy
Kvant Math Problem 1133

Consider the sum

kvantmathematicsolympiad
CF 231E - Cactus

We are given a connected undirected graph that is guaranteed to be a vertex cactus. In a vertex cactus, every vertex belongs to at most one simple cycle. Cycles may touch the rest of the graph through articulation points, but two different cycles can never share a vertex.

codeforcescompetitive-programmingdata-structuresdfs-and-similardpgraphstrees
CF 231D - Magic Box

We are asked to compute the sum of numbers visible on a box from a given viewpoint in three-dimensional space. The box is axis-aligned, meaning all edges run along the X, Y, and Z axes. Its minimal corner is at the origin, and the opposite corner is at coordinates $(x1, y1, z1)$.

codeforcescompetitive-programmingbrute-forcegeometry
CF 231B - Magic, Wizardry and Wonders

We are asked to reconstruct an initial sequence of integers given the final result of a repeated transformation. Vasya has n cards, each containing an integer between 1 and l.

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 228A - Is your horseshoe on the other hoof?

Valera has exactly four horseshoes. Each horseshoe has a color represented by an integer. For the party, he wants all four horseshoes to have different colors. If some of his horseshoes share the same color, he must buy replacement horseshoes of new colors.

codeforcescompetitive-programmingimplementation
CF 228D - Zigzag

We maintain an array of up to $10^5$ numbers. Two kinds of operations arrive online. The first operation changes a single array element. The second operation asks for a weighted sum on a segment.

codeforcescompetitive-programmingdata-structures
CF 228E - The Road to Berland is Paved With Good Intentions

We have a graph with n cities connected by m undirected roads. Each road either has asphalt (1) or does not (0). The king can pick a city and the workers will toggle the asphalt status on every road incident to that city: asphalted roads become non-asphalted and vice versa.

codeforcescompetitive-programming2-satdfs-and-similardsugraphs
CF 228C - Fractal Detector

We are given an $n times m$ grid where each cell is either white (".") or black (""). Vasya claims to have painted a fractal on some sub-squares of this grid.

codeforcescompetitive-programmingdphashing
Kvant Math Problem 1132

Let

kvantmathematicsolympiad
CF 228B - Two Tables

We have two binary matrices. A shift (x, y) means that cell (i, j) of the first matrix is compared with cell (i + x, j + y) of the second matrix. For a fixed shift, the overlap factor is the sum of products of overlapping cells.

codeforcescompetitive-programmingbrute-forceimplementation
Kvant Math Problem 1131

Consider the case $n=1$ first.

kvantmathematicsolympiad
Kvant Math Problem 1130

Consider first a simple convex polygon, such as a triangle or a square.

kvantmathematicsolympiad
CF 225C - Barcode

Codeforces 225C: Barcode

codeforcescompetitive-programmingdpmatrices
Kvant Math Problem 1129

I cannot write a solution to Kvant problem M1129 because the actual problem statement is not present in the conversation.

kvantmathematicsolympiad
CF 225E - Unsolvable

Codeforces 225E: Unsolvable

codeforcescompetitive-programmingmathnumber-theory
CF 225D - Snake

Codeforces 225D: Snake

codeforcescompetitive-programmingbitmasksdfs-and-similargraphsimplementation
Kvant Math Problem 1128

Consider first the case of a $2 \times 2$ chessboard with two pieces.

kvantmathematicsolympiad
CF 225A - Dice Tower

Codeforces 225A: Dice Tower

codeforcescompetitive-programmingconstructive-algorithmsgreedy
CF 223C - Partial Sums

Codeforces 223C: Partial Sums

codeforcescompetitive-programmingcombinatoricsmathnumber-theory
Kvant Math Problem 1127

I notice that the problem statement itself is not yet provided.

kvantmathematicsolympiad
CF 223B - Two Strings

Codeforces 223B: Two Strings

codeforcescompetitive-programmingdata-structuresdpstrings
Kvant Math Problem 1126

The statement resembles a converse of a familiar fact about equal angles subtending the same segment.

kvantmathematicsolympiad
Kvant Math Problem 1125

I cannot write a solution to Kvant problem M1125 from the information provided, because the actual problem statement is missing.

kvantmathematicsolympiad
Kvant Math Problem 1124

Consider a trapezoid $ABCD$ with bases $AB$ and $CD$, where $AB$ is the shorter base.

kvantmathematicsolympiad
Kvant Math Problem 1123

Label the cells by coordinates $(i,j)$, where $i,j\in\mathbb N$ and $i,j\ge 1$.

kvantmathematicsolympiad
Kvant Math Problem 1122

Let

kvantmathematicsolympiad
Kvant Math Problem 1120

Consider the sequence defined by $a_0 = 0$ and $a_n = P(a_{n-1})$ for $n \ge 1$, where $P(x)$ is a polynomial with integer coefficients and $P(x) > 0$ for $x \ge 0$.

kvantmathematicsolympiad
Kvant Math Problem 1119

Consider first small values of $k$.

kvantmathematicsolympiad
Kvant Math Problem 1118

Expanding the left-hand side gives

kvantmathematicsolympiad
Kvant Math Problem 1117

Let the sides of the given triangle $ABC$ be

kvantmathematicsolympiad
Kvant Math Problem 1116

Consider a rectangle drawn on a square grid where the unit squares are the cells.

kvantmathematicsolympiad
Kvant Math Problem 1115

Consider the first problem.

kvantmathematicsolympiad
Kvant Math Problem 1114

Consider a tetrahedron with vertices $A$, $B$, $C$, $D$ and let $a = AB$ and $b = CD$ be two skew edges.

kvantmathematicsolympiad
Kvant Math Problem 1113

Model the situation as a graph on $21$ vertices, the cities.

kvantmathematicsolympiad
Kvant Math Problem 1112

Starting with the numbers $1$ and $2$ on the board, the rule allows us to produce $ab + a + b$ whenever $a$ and $b$ are present.

kvantmathematicsolympiad
Kvant Math Problem 1111

Consider triangle $ABC$ with acute angles and its circumcircle $\Gamma$.

kvantmathematicsolympiad
Kvant Math Problem 1110

Consider the first few natural numbers and compute the greatest common divisors of all distinct pairs.

kvantmathematicsolympiad
Kvant Math Problem 1109

Let the vertices of an inscribed equilateral triangle be

kvantmathematicsolympiad
Kvant Math Problem 1108

Consider small cases first.

kvantmathematicsolympiad
Kvant Math Problem 1107

The inequality is homogeneous in the ratios of the sides.

kvantmathematicsolympiad
Kvant Math Problem 1106

Consider a convex hexagon $ABCDEF$.

kvantmathematicsolympiad
CF 223E - Planar Graph

We are given a connected planar graph drawn on the plane with no bridges, articulation points, loops, or multiple edges. Each vertex has explicit coordinates, and every edge is a straight line between two vertices that intersects no other edge except at its endpoints.

codeforcescompetitive-programmingflowsgeometrygraphs
CF 223D - Spider

We are asked to find the shortest path a spider can take on a simple polygon from one vertex to another. The polygon can be concave, but it is guaranteed to have no self-intersections, and its vertices are given in counter-clockwise order.

codeforcescompetitive-programminggeometrygraphs
Kvant Math Problem 1105

The problem concerns unfolding a convex polyhedron along straight-line cuts so that its surface lies flat as a single polygon, with specified identifications of points on the boundary.

kvantmathematicsolympiad
CF 223A - Bracket Sequence

We are given a string consisting only of four bracket characters: (, ), [ and ]. The string is not necessarily balanced. Among all substrings of this string, we need to find one that forms a correct bracket sequence.

codeforcescompetitive-programmingdata-structuresexpression-parsingimplementation
Kvant Math Problem 1104

Let

kvantmathematicsolympiad
Kvant Math Problem 1103

Begin with the first part of the problem, which concerns tiling an infinite plane with $1\times 2$ dominoes after some non-overlapping dominoes are already placed.

kvantmathematicsolympiad
CF 222A - Shooshuns and Sequence

We are given a sequence of integers on a blackboard and a position k. A shooshun can perform one operation that appends the k-th element of the current sequence to the end and removes the first element.

codeforcescompetitive-programmingbrute-forceimplementation
Kvant Math Problem 1102

For $n=3$ it is natural to search among classical identities involving sums of three cubes.

kvantmathematicsolympiad
Kvant Math Problem 1100

Consider a finite set of logs lying on a straight riverbank, each forming an angle less than $45^\circ$ with the bank.

kvantmathematicsolympiad
Kvant Math Problem 1099

Consider small examples to gain intuition.

kvantmathematicsolympiad
Kvant Math Problem 1098

Consider the game for small values of $n$.

kvantmathematicsolympiad
Kvant Math Problem 1097

Consider small examples of isosceles triangles whose vertices have integer coordinates.

kvantmathematicsolympiad
Kvant Math Problem 1096

Let the circle have radius $R=\dfrac d2$.

kvantmathematicsolympiad
Kvant Math Problem 1095

The problem involves constructing a chord $MN$ of a circle with center $O$ seen from $A$ under a given angle $\alpha$, with additional geometric constraints.

kvantmathematicsolympiad
Kvant Math Problem 1094

The two inequalities are

kvantmathematicsolympiad
Kvant Math Problem 1093

Represent the configuration by numbers $a_1,\dots,a_n\in{0,1,2}$ arranged cyclically.

kvantmathematicsolympiad
Kvant Math Problem 1092

Consider a single fold of a convex polygon and a subsequent straight cut.

kvantmathematicsolympiad
Kvant Math Problem 1090

Testing small values helps build intuition about the inequality.

kvantmathematicsolympiad
Kvant Math Problem 1089

Let the inradius of triangle $AOB$ be $r_1$, of $BOC$ be $r_2$, of $COD$ be $r_3$, and of $DOA$ be $r_4$.

kvantmathematicsolympiad
Kvant Math Problem 1088

The condition is

kvantmathematicsolympiad
Kvant Math Problem 1087

Let $h_a,h_b,h_c$ be the altitudes of triangle $ABC$.

kvantmathematicsolympiad
Kvant Math Problem 1086

Consider the problem of reaching a target number from $0$ using only two operations: doubling the current number or adding $1$.

kvantmathematicsolympiad
Kvant Math Problem 1085

Consider the problem geometrically.

kvantmathematicsolympiad
Kvant Math Problem 1084

Let the two given circles be $\omega_1$ and $\omega_2$, intersecting at $A$ and $B$.

kvantmathematicsolympiad
Kvant Math Problem 1083

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

kvantmathematicsolympiad
Kvant Math Problem 1082

The given equality resembles the identity for the sum of squares of the sides of a quadrilateral.

kvantmathematicsolympiad
Kvant Math Problem 1081

Compute a few values:

kvantmathematicsolympiad
Kvant Math Problem 1080

Let

kvantmathematicsolympiad
Kvant Math Problem 1079

For $n=3$ the problem asks for a single triangle whose three side lengths are irrational and whose area is a nonzero rational number.

kvantmathematicsolympiad
Kvant Math Problem 1078

Assume that a function $f:\mathbb N_0\to\mathbb N_0$ satisfies

kvantmathematicsolympiad
Kvant Math Problem 1077

Let $X(\sigma)$ denote the number of fixed points of a permutation $\sigma$ of an $n$ element set.

kvantmathematicsolympiad
Kvant Math Problem 1075

Consider the problem in terms of digit patterns.

kvantmathematicsolympiad
Kvant Math Problem 1074

Let $m=2n+1$.

kvantmathematicsolympiad
Kvant Math Problem 1073

Consider a hexagon $A_1A_2A_3A_4A_5A_6$ with a point $O$ from which all sides are seen under an angle of $60^\circ$.

kvantmathematicsolympiad
Kvant Math Problem 1072

The expression $989 \cdot 1001 \cdot 1007 + 320$ appears to involve three numbers spaced by six units: $989$, $1001$, $1007$.

kvantmathematicsolympiad
Kvant Math Problem 1071

Consider smaller versions of the game to understand the parity dynamics.

kvantmathematicsolympiad
Kvant Math Problem 1070

Let the tetrahedron have vertices $A,B,C,D$.

kvantmathematicsolympiad
Kvant Math Problem 1069

Consider a small number of families, say three or four, each in a distinct apartment.

kvantmathematicsolympiad
Kvant Math Problem 1068

Consider an angle $AOB$ with points $A$ on one side and $B$ on the other.

kvantmathematicsolympiad
Kvant Math Problem 1067

Let

kvantmathematicsolympiad
Kvant Math Problem 1066

Consider six points in the plane with all pairwise distances at most $1$.

kvantmathematicsolympiad