Let $k$ be a positive integer. Lexi has a dictionary $\mathbb{D}$ consisting of some $k$-letter strings containing only the letters $A$ and $B$. Lexi would like to write either the letter $A$ or the letter $B$ in each cell of a $k \times k$ grid so that each column contains a string from $\mathbb{D}$ when read from top-to-bottom and each row contains a string from $\mathbb{D}$ when read from left-to-right. What is the smallest integer $m$ such that if $\mathbb{D}$ contains at least $m$ different strings, then Lexi can fill her grid in this manner, no matter what strings are in $\mathbb{D}$?
Problem
Source: EGMO 2023/3
Tags: EGMO 2023, EGMO
17.04.2023 01:01
Replace $A$ with $0$ and $B$ with $1$. The answer is $m=2^{k-1}$. To show that $m=2^{k-1}-1$ does not work, take $\mathcal{D}$ containing all strings other than $00 \cdots 0$ starting with $0$. Then, the top row of the grid must contain a $1$, but no string in $\mathcal{D}$ starts with $1$, a contradiction. Let two strings be complementary if the corresponding digits in each position are opposite. Notice that $\mathcal{D}$ cannot contain either $00 \cdots 0$ or $11 \cdots 1$, otherwise we can fill the grid with either zeroes or ones. Since there are $2^{k-1}-1$ remaining complementary pairs and $2^{k-1}$ strings in $\mathcal{D}$, there must be a pair of complementary strings in $\mathcal{D}$. Let $s=a_1a_2 \cdots a_k$ be one of these strings. Fill the grid such that the cell in the $i^\text{th}$ row and $j^\text{th}$ column is congruent to $a_i+a_j \pmod 2$. This construction ensures that each row and each column is either $s$ or its complement, so we are done.
17.04.2023 09:48
We claim the answer is $m = 2^{k-1}$. First, we claim $m > 2^{k-1}-1$. Indeed, if $\mathbb{D}$ contained all strings beginning with $A$ with the exception of $AA \cdots AA$, then the first row is forced to contain only $A$'s which is not in $\mathbb{D}$. To show that $m=2^{k-1}$ always works, we split into two cases Case 1: Either $AA \cdots AA$ or $BB \cdots BB$ are in $\mathbb{D}$. We can just fill up the entire board with $A$'s or $B$'s lmao. Case 2: Neither $AA \cdots AA$ nor $BB \cdots BB$ are in $\mathbb{D}$. Indeed, by PHP this implies that there exists a string $x \in \mathbb{D}$ where $x^{-1} \in \mathbb{D}$ ($x^{-1}$ is the bitwise complement of $x$). Fill the first row with $x$, then fill each column with $x$ or $x^{-1}$ in a way that does not contradict the already filled first row. It is clear that all rows and columns will either read $x$ or $x^{-1}$ which are both in $\mathbb{D}$. $\blacksquare$
17.04.2023 13:54
17.04.2023 22:16
Let us prove that the smallest such $m$ is $2^{k-1}$. We start by showing no $m<2^{k-1}$ works. Indeed, if such a $m$ did work, then Lexi could choose $m$ strings of length $k$ starting with an $A$ (there are $2^{k-1}$ such strings), so that none of the strings is the string $AA\ldots A$. This way, if Lexi could fill her $k\cdot k$ grid, then every column would need to start with an $A$ on top. It follows that the first row contains only the letter $A$, so the string associated to this row is $AA\ldots A$, which does not belong to $\mathbb D$, contradiction. Now we prove that if $\mathbb D$ contains at least $m=2^{k-1}$ strings, then Lexi can always fill her grid. First, if $\mathbb D$ contains one of the string $AA\ldots A$ or $BB\ldots B$, then Lexi can respectively fill her grid only with $A$'s or $B$'s. So from now on suppose that none of these two strings are contained in $\mathbb D$. Then by PHP (by associating every string with his complementary), we get that there exists two complementary strings in $\mathbb D$ (in the sense that if the $i$th letter of one of the strings is an $A$, then it's a $B$ in the other one). Name these strings $s$ and $s'$, and fill the grid in the following manner : If the $i$th letter in string $s$ is an $A$, then she marks the $k$ cells in the $i$th row so that the string formed is exactly $s$. Similarly, if the $i$th letter in string $s$ in a $B$, then she marks the $k$ cells in the $i$th row so that the string formed is exactly $s'$. One can easily check this indeed works by symmetry arguments, so this finishes the proof. $\square$
17.04.2023 22:27
The answer is $m=2^{k-1}$. First, an example of $|\mathcal{D}|=2^{k-1}-1$ failing is to take every string with $A$ in its first position, except for $A\ldots A$, formed from $k$ copies of $A$, of which there are clearly $2^{k-1}-1$. Then no matter how we place strings in the rows of the grid, the first column will read $A\ldots A$, which is not in $\mathcal{D}$. Now we prove that $|\mathcal{D}|=2^{k-1}$ works. First, if $\mathcal{D}$ contains $A\ldots A$, then we can make the entire grid $A$'s, and likewise if it contains $B\ldots B$, we can make entire grid $B$'s. Hence suppose that $\mathcal{D}$ contains neither, so by Pigeonhole we must have two "complementary" strings in $\mathcal{D}$, which are formed by switching each character of the other. Suppose that one of these is $s=a_1\ldots a_k$. Then place $s$ in row $i$ if $a_i=A$ and its complement if $a_i=B$. It is clear that this will work. $\blacksquare$
18.04.2023 03:36
A somewhat bland and ad hoc problem imo. The answer is $m = 2^{k-1}.$ Replace $A,B$ with $0,1$ respectively. Note that if $\mathbb{D}$ contains a string $s$ and its bitwise complement $\sim s$ then it possible to fill the grid such that each row/column's word is either $s$ or $\sim s.$ We fill the first row with $s,$ first column with $s,$ then the remaining entries are determined and it is clear that this is a valid grid satisfying the conditions. Also note that if either the all $0$'s string or the all $1$'s string (of length $k$) is in $\mathbb{D}$ then the grid can trivially be filled with all $0$'s or $1$'s, and these two strings are complements. Combining these two facts shows that if $m \geq 2^{k-1}$ then the grid can be filled. For necessity we can take $\mathbb{D}$ the set of $2^{k-1} - 1$ strings that begin with a $0,$ excluding the all $0$'s string. Then no matter what string occupies the first row, some column's string must begin with a $1,$ which is impossible as no strings in $\mathbb{D}$ begin with a $1.$ Thus, $m = 2^{k-1}$ is necessary. $\blacksquare$
18.04.2023 04:58
Sol:- Replace $A,B$ with $1,0$.We prove that $m=2^{k-1}$. Step 1 Showing $2^{k-1}>m$ doesn't work. Proof:- Consider the strings starting with $1$ other than $1111...1$($k$ times $1$).They are $2^{k-1}$ in number so we pick any subset of them having cardinality $m$. They all have a $0$ somewhere in them so we require a string starting with $0$ to fill the grid but all the strings in this set starts with $1$ so it is not possible to fill the grid. Step 2 Showing $2^{k}=m$ works. Proof If we had $1111...1$($k$ times $1$) or $0000...0$($k$ times $0$) then we could fill the whole grid by just same string so lets exclude them. Call two strings opposite if their sum equals $1111...1$($k$ times $1$). We have now $2^{k-1}-1$ pairs of opposite strings. By pigeonhole principle since we have $2^k$ strings in total we must have atleast $1$ pair of opposite strings. Now consider the pair of opposite strings , one of the strings starts with $1$ we call it $t$ and the other one starts $0$ and we call its $s$.The following construction works. Fill the first row and first column with $t$.Let $r_0,r_1$ represent the rows starting with $0,1$ respectively and $c_0,c_1$ represent the columns starting with $0,1$ respectively. Fill $1$ in $r_1 \cap c_1$ and $r_0 \cap c_0$. Fill $0$ in $r_0 \cap c_1$ and $r_1 \cap c_0$. By using definition that $t+s=1111...1$($k$ times $1$) we can observe that the construction indeed works.So Done.
18.04.2023 06:36
The answer is $m=2^{k-1}.$ From now on, let A be 0 and B be 1. If there are $2^{k-1}$ words, then there is either a pair of complementary words, or one word is chosen from each pair. In the second case, one choice is to pick either $0\cdots 0$ or $1\cdots 1$, in which case we can just fill up that board with that number. We will then do the other case, where there is a pair of complimentary words. Consider complimentary words $W$ and $W'$. WLOG $W$ starts with 0. Then, fill the first row as well as the first column so that they both read as $W$. Then, for each cell other than the first row or first column: find the number $a$ in the first row that is in the same column as that cell, and find the number $b$ that is in the same row as that cell but in the first column, and fill that cell with $a$ XOR $b$. When this is done, as long as $W$ starts with 0, each row and column is either $W$ or $W'$, so we are done. If there are $2^{k-1}-1$ words, then take all words starting with 0 other than all zeroes. This is clearly a contradiction as the first row must contain at least one 1, but all words start with 0.
21.04.2023 20:09
We will prove that m=2^(k-1). First notice that if we grab 2^(k-1) - 1 words, then it is possible to have all words starting with exclusively with A or exclusively with B, while still not having the string with only A’s or B’s. This configuration will clearly fail. Now, with 2^(k-1), using pigeonhole principle, we can notice that, if we do not have the strings with only A’s or only B’s in our dictionary (if any of these strings is included, then the whole board can be filled with only A’s or B’s) then we can assure that there will be one pair of opposite strings. I define opposite strings as taking a string and replacing the A’s with B’s and vice-versa, that will be its opposite. With those 2 opposite strings, the board can be filled (to show why, one can simply number the rows and columns, and the result will follow). So we are done. Ps. I found this problem really cool and I was happy that I was able to solve it during the competition.
22.04.2023 04:11
Solution from Twitch Solves ISL: Answer: $|\mathbb{D}| \ge 2^{k-1}$ is sufficient to fill the grid. Counterexample where $|\mathbb{D}| = 2^{k-1}-1$. Let $\mathbb{D}$ be all the words that start with $A$ other than the all-$A$ string. There can't be any construction because the first row would contain a $B$, but no words in $\mathbb{D}$ start with $B$. Sufficiency proof when $|\mathbb{D}| \ge 2^{k-1}$. If $\mathbb{D}$ contains either the all-$A$ or all-$B$ string, we're done. Otherwise, pair the remaining $2^k-2$ possible strings into $2^{k-1}-1$ pairs where we pair two strings if they have no overlapping letters in the same position (i.e.\ they are opposites, like $ABBAA$ and $BAABB$). Because $|\mathbb{D}| > 2^{k-1}-1$, it follows $\mathbb{D}$ has a pair of such opposites in it. Then it's possible to fill the grid with just those two words, e.g.\ $ABBAA$ gives the grid \[ \begin{bmatrix} A & B & B & A & A \\ B & A & A & B & B \\ B & A & A & B & B \\ A & B & B & A & A \\ A & B & B & A & A \end{bmatrix}. \]
22.04.2023 20:48
Here is a more detailed rigorous proof on the part of why a board of the wanted kind exists when there are two "oppsosite" strings (the other part is described by many posts above). Let $S$ and $S'$ be two "opposite" strings and WLOG let $S$ start with an $A$. We claim the following construction works: Row $i$ of the table is equal to $S$ if and only if there is an $A$ on the $i$th position of $S$. Otherwise, row $i$ of the table is equal to $S'$. It is now enough to prove that every column of the table is equal to either $S$ or $S'$. To this, we will show that the strings corresponding to row $i$ and column $i$ coincide. Let $(i,j)$ be the box in row $i$ and column $j$. We consider a row $i$. WLOG let row $i$ be equal to $S$ (the other case is equivalent). Now $(i,j)=A \Longleftrightarrow$ there is an $A$ at position $j$ in $S \Longleftrightarrow $ column $j$ is equal to $S$ $\Longleftrightarrow (j,i)=A$. So for all $i,j$ we have $(i,j)=(j,i)$, so the table is symmetric with respect to one of its diagonals (more precisely, the one from the lower right to the upper left corner) and so column $i$ is the same as row $i$ which proved the board we constructed is valid.
11.05.2023 08:37
The answer is $m=2^{k-1}.$ We first prove this is the lower bound. If $m \leq 2^{k-1}-1,$ consider $\mathbb{D}$ containing all strings starting with $A$ except that of $AAA \ldots AA.$ This forces the top row to be $AAA \ldots AA,$ contradiction. We now prove this is the upper bound. If $AAA \ldots AA$ is included in $\mathbb{D},$ then just tile the entire grid with $A$'s. Similarly do so if $BBB \ldots BB$ is included in $\mathbb{D}.$ If neither of these strings are included, then by Pigeonhole principle, there must exist some string in $\mathbb{D}$ such that there is another string in $\mathbb{D}$ such that every character corresponds to this strings complement (since there are precisely $2^{k-1}-1$ strings starting with $A,$ excluding $AAA \ldots AA,$ and similarly with $B$). Without loss of generality, suppose this string is $s_1s_2 \dots s_k.$ Tile the grid in the following way: place $s_1s_2 \dots s_k$ in a row $i$ if $s_i=A$ and its complement otherwise. This generates a working construction using only these two strings.
02.09.2023 23:09
We claim the answer is $m=2^{k-1}$. We will first prove that $m=2^{k-1}$ is necessary. Consider all the strings that start with $A$ except the all-A string. Then, there are $2^{k-1}-1$ strings. All of these strings have at least one $B$ in them. Since we don't have strings starting with $B$ in our dictionary, she cannot fill the grid. This is because the top row has at least one $B$ in it and you cannot fill the corresponding column. Now we will prove that $m=2^{k-1}$ is sufficient. If the dictionary has the all-A string or the all-B string then the grid can be filled, so assume it doesn't have those. Every string has an inverse string formed by changing every letter in the string. There are $ \frac{2^k-2}{2}=2^{k-1}-1$ pairs of non-trivial strings, because we are excluding the all-A and all-B strings. By pigeonhole with $m=2^{k-1}$ strings we have a pair of inverses in our dictionary. We claim that with this pair of inverses, we can fill the entire grid. To see why, fill the first row and first column with the string starting with $A$. Consider the point $(x,y)$ in the grid: we will show it is the correct letter for row $y$ and column $x$. Case $1$: The $A$-string has $A$ at both position $x$ and position $y$. Then, $(x,y)=A$ and it is the correct letter. Case $2$: The $A$-string has $B$ at both position $x$ and $y$. Then, $(x,y)=A$ which works because at position $x$ and position $y$ the $B$-string has $A$. Case $3$: The $A$-string has $A$ at position $x$ and $B$ at position $y$. Then, the $B$-string has $B$ at position $x$ and the $A$-string has $B$ at position $y$ so $(x,y)=B$. Case $4$: $B$ at position $x$ , $A$ at position $y$ we can use the same argument Therefore for any point in the grid it is the correct one for both the row string and the column string, so we can fill in the grid with the two inverses. $\blacksquare$
17.10.2023 09:14
Solved with (more like by but lets ignore that) Rama1728 Note that for $2^{k-1}-1$, we consider the set of strings of length $k-1$, which are not all $A$'s. Just append an $A$ to the front of these strings, and we cannot construct a grid this way as in the first row, atleast one $B$ will appear but we cannot insert a string in that coumn as all strings star with $A$. Now for $2^{k-1}$ note that two complementary strings are present, thus letting one be say $S_1$ and $S_2$ where $S_1$ starts with $A$ and $S_2$ with $B$, we can just write out one of these strings in the first row, and then if $A$ appears, we write $S_1$ in the remainder of the column and if $B$ appears we write $S_2$ in the remainder of the column. Since $S_1$ and $S_2$ are complementary, we see that each row is infact either $S_1$ or $S_2$ and solved. Edit: Note that if the all $A$ or all $B$ string exist, then we can fill the board in all $A$'s or all $B$'s and we are done. If not, then we pair each string with its complement (there are $2^{k-1}$ such pairs), and thus by PHP, atleast one string and its complement exist, since one such pair isnt touched at all.
13.01.2024 19:01
how is this a P3 - observed from the fact that I am not supposed to solve P3's this fast the desired value is $\boxed{2^{k-1}}$ We can quickly show that it doesn't work for $2^{k-1}-1$, simply take all the strings that start with $A$, but aren't the string $AAA\dots A$ If we now wish to fill all the rows, than the very first column is the pure $A$- string, which is a contradiction. Now to show that it works for $2^{k-1}$ or bigger always: if we have the $AAA \dots A$ or $BBB \dots B$-string, then we can always fill it. If we don't, then we always have one string that also has it's negation in the desired set (here, the negation is just every $A$ flipped to a $B$ and vice versa). We claim that it is always possible to fill the grid using those strings. But this is quite clear One of the two strings starts with an $A$, the other with a $B$. Place one of the two strings in the first column, and now fill all the rows by the letter that has been set. It can easily be seen that the pattern from the first column is the same as the pattern in all the other columns, just either negated or not, but both of those strings are viable, therefore it always works
09.02.2024 07:30
This is one of the anti-problems of all time. The answer is $m = 2^{k-1}$ strings. Bound: Suppose that $\mathbb D$ consists of all $2^{k-1} - 1$ strings that start with $A$ and are not all $A$'s. Then, there must be a $B$ in the first column; on the other hand, there are no strings in $\mathbb D$ that start with $B$, contradiction. Construction: If there exists a string of all $A$'s or a string of all $B$'s, we're done. Otherwise, there are $2^{k-1}-1$ pairs of complement strings, so there must exist two strings that are complements of each other in $\mathbb D$. Say one of these strings is $s = \overline{c_1 c_2 \cdots c_k}$ where $c_1 = 1$. Then place $s$ in the $i$th row if $c_i = 1$ and $\overline s$ otherwise. This construction obviously works.
17.09.2024 15:41
Cute! The answer is $m=2^{k-1}$. For simplicity, replace $A$ with $0$ and $B$ with $1$ Necessity: Suppose that $|\mathbb D|\le 2^{k-1}-1$ and consider the set of strings $\mathbb D_k$ that begin with $0$ that doesn't contain the string which has all entries equal to $0$. Clearly, $|\mathbb D_k|=2^{k-1}-1$ so we can take $\mathbb D\subset \mathbb D_k$. Now we look at the first row. This row must have a $1$ in it but no string begins with a $1$. $\square$ Sufficiency: If $\mathbb D$ contains the string that has all entries equal to $0$ or $1$ Lexi can clearly fill the grid so suppose that it doesn't contain these strings. Now we have $2^{k-1}-1$ pairs of strings $(S,S')$ such that $S$ and $S'$ are complementary so by PHP we get that $\mathbb D$ must contain two complementary strings. We will now only focus on these complementary strings so call them $S_0$ and $S_1$. Suppose that $S_1$ begins with a $1$ and $S_0$ begins with a $0$. We can clearly place the strings on rows such that the first column becomes $S_1$. We claim that this suffices. For this, notice that the strings in the columns corresponding to the entries of $S_0$ having a $0$ in them are exactly $S_1$ and those corresponding to the entries of $S_0$ having a $1$ in them are the complementary of $S_1$, so they are $S_0$. $\square$
19.09.2024 01:24
Quote: Your post is too short; it must be at least 8 characters.
Attachments:

10.12.2024 12:13
The answer is $2^{k - 1}$. The bound is simple: take everything starting with $A$ that is not $AA \cdots A$. Now note that we can fill in the grid using $AA \cdots A$, $BB \cdots B$, or a string $s$ and its complement (see the following grid for an example). \[\setcounter{MaxMatrixCols}{20}\begin{bmatrix} A & B & B & B & B & A & A & A & B & B & B & B \\ B & A & A & A & A & B & B & B & A & A & A & A \\ B & A & A & A & A & B & B & B & A & A & A & A \\ B & A & A & A & A & B & B & B & A & A & A & A \\ B & A & A & A & A & B & B & B & A & A & A & A \\ A & B & B & B & B & A & A & A & B & B & B & B \\ A & B & B & B & B & A & A & A & B & B & B & B \\ A & B & B & B & B & A & A & A & B & B & B & B \\ B & A & A & A & A & B & B & B & A & A & A & A \\ B & A & A & A & A & B & B & B & A & A & A & A \\ B & A & A & A & A & B & B & B & A & A & A & A \\ B & A & A & A & A & B & B & B & A & A & A & A \end{bmatrix}\]We're done by Pigeonhole.
22.12.2024 22:00
We claim that the minimum is $2^{k-1}.$ For the bound, if we had $2^k-1$ elements a counterexample would be if $\mathbb D$ contained all words starting with $A$ except $AAAA\cdots A.$ In this case, the first column would all be $A$'s, which is not in the dictionary. Therefore, we require at least $2^k$ words. Now, we show that all dictionaries with $2^{k-1}$ elements work. If $\mathbb D$ has $AA\cdots A$ or $BB \cdots B,$ we can fill the whole grid with only that letter. Assume otherwise. Pair all the words with their complements. Then by the Pigeonhole Principle, at least one pair has both of its words in $\mathbb D.$ Then we can obviously create a construction with only these two words. To do this, let the two words be $X, Y.$ Let the first column be $X.$ Then if $X$ starts with characters $c_1, c_2, \cdots c_k,$ for each $c_i = c_1$ that row would be $X,$ while otherwise it will be $Y$. This construction clearly works by the argument that you can reflect the matrix over its main diagonal.