Daily

Random

Practice set

Baltic Way 2025 · Problem 8

Combinatorics

A sequence of non-negative integers a1,…,ana_1,\ldots,a_n is called self-descriptive if

ak=∣{i∣ai≥k}∣a_k=\bigl|\{i\mid a_i\ge k\}\bigr|

for each k∈{1,…,n}k\in\{1,\ldots,n\}, i.e. aka_k equals the number of elements of the sequence that are greater than or equal to kk, for each k∈{1,…,n}k\in\{1,\ldots,n\}. For each positive integer nn, determine the number of self-descriptive sequences of length nn.

Change pool

When you’re ready

Review material becomes available with the next Daily.

Review

Topics

Pigeonhole and extremal arguments

Solutions

Solution

The answer is 2n2^n.

All elements of a self-descriptive sequence are integers between 00 and nn, inclusive, since they are sizes of sets with at most nn elements. A self-descriptive sequence is also non-increasing: all numbers that are at least k+1k+1 are also at least kk, so ak≥ak+1a_k\ge a_{k+1}.

Take any self-descriptive sequence a1,…,ana_1,\ldots,a_n and draw an n×nn\times n grid. Number the columns 1,…,n1,\ldots,n from left to right and the rows 1,…,n1,\ldots,n from bottom to top. In column kk, colour the bottom aka_k cells gray and leave the rest white (Figure 1).

Official solution diagram for Baltic Way 2025 Problem 8 (Figure 1).

Figure 1. Grid representing the self-descriptive sequence (5,3,2,1,1)(5,3,2,1,1). The grid is symmetric across the main diagonal.

Consider any column kk with exactly mm gray cells. Then ak=ma_k=m. Since ak=ma_k=m, exactly mm terms of the sequence are at least kk. As the sequence is non-increasing, these are the first mm terms. Thus the first mm columns have their bottom kk cells gray, while the remaining n−mn-m columns do not. Equivalently, row kk has exactly its leftmost mm cells gray. Since this holds for every kk, the grid is symmetric across the main diagonal.

Every self-descriptive sequence gives a unique grid with these properties. Conversely, every n×nn\times n grid symmetric across the main diagonal in which each column has all its gray cells below its white cells gives a unique sequence by taking aka_k to be the number of gray cells in column kk. Such a sequence is self-descriptive, because if row kk has exactly mm gray cells, then exactly mm terms of the sequence are at least kk. Hence self-descriptive sequences are in bijection with these grids.

Now draw the boundary between the gray and white cells and connect it to the top-left and bottom-right corners along the boundary of the grid (Figure 2). Since each row and column switches from gray to white at most once, this boundary is a down-right path from the top-left corner to the bottom-right corner. The grid is symmetric across the main diagonal, so the boundary is also symmetric. Thus choosing one half of the boundary determines the other half.

Official solution diagram for Baltic Way 2025 Problem 8 (Figure 2).

Figure 2. The boundary between the gray and white cells. By symmetry, only one half can be chosen freely.

Conversely, every right-down path from the top-left to the bottom-right that is symmetric across the main diagonal determines one of the admissible grids. It remains to count such paths. We may freely choose the half of the path from the top-left corner to the main diagonal. In an n×nn\times n grid this half consists of nn steps, each either right or down. Hence there are 2n2^n such paths, and therefore 2n2^n self-descriptive sequences of length nn.

Contest context

Results from Baltic Way 2025

11 teams

Mean score
4.1 / 5
Scores of 4 or 5
9 / 11
Estonia
5 / 5

Score distribution

02
10
20
30
40
59
All team scores
TeamScore
Germany5 / 5
Estonia5 / 5
Poland5 / 5
Lithuania5 / 5
Norway5 / 5
Latvia5 / 5
Finland5 / 5
Denmark5 / 5
Sweden5 / 5
Ukraine0 / 5
Iceland0 / 5