Let ℓ be a positive integer. We will show that (i) if n>ℓ2 then each happy configuration contains an empty ℓ×ℓ square, but (ii) if n⩽ℓ2 then there exists a happy configuration not containing such a square. These two statements together yield the answer.
(i). Assume that n>ℓ2. Consider any happy configuration. There exists a row R containing a rook in its leftmost square. Take ℓ consecutive rows with R being one of them. Their union U contains exactly ℓ rooks. Now remove the n−ℓ2⩾1 leftmost columns from U (thus at least one rook is also removed). The remaining part is an ℓ2×ℓ rectangle, so it can be split into ℓ squares of size ℓ×ℓ, and this part contains at most ℓ−1 rooks. Thus one of these squares is empty.
(ii). Now we assume that n⩽ℓ2. Firstly, we will construct a happy configuration with no empty ℓ×ℓ square for the case n=ℓ2. After that we will modify it to work for smaller values of n. Let us enumerate the rows from bottom to top as well as the columns from left to right by the numbers 0,1,…,ℓ2−1. Every square will be denoted, as usual, by the pair (r,c) of its row and column numbers. Now we put the rooks on all squares of the form (iℓ+j,jℓ+i) with i,j=0,1,…,ℓ−1 (the picture below represents this arrangement for ℓ=3). Since each number from 0 to ℓ2−1 has a unique representation of the form iℓ+j(0⩽i,j⩽ℓ−1), each row and each column contains exactly one rook.
!
Next, we show that each ℓ×ℓ square A on the board contains a rook. Consider such a square A, and consider ℓ consecutive rows the union of which contains A. Let the lowest of these rows have number pℓ+q with 0⩽p,q⩽ℓ−1 (notice that pℓ+q⩽ℓ2−ℓ). Then the rooks in this union are placed in the columns with numbers qℓ+p,(q+1)ℓ+p,…,(ℓ−1)ℓ+p, p+1,ℓ+(p+1),…,(q−1)ℓ+p+1, or, putting these numbers in increasing order,
p+1,ℓ+(p+1),…,(q−1)ℓ+(p+1),qℓ+p,(q+1)ℓ+p,…,(ℓ−1)ℓ+p
One readily checks that the first number in this list is at most ℓ−1 (if p=ℓ−1, then q=0, and the first listed number is qℓ+p=ℓ−1), the last one is at least (ℓ−1)ℓ, and the difference between any two consecutive numbers is at most ℓ. Thus, one of the ℓ consecutive columns intersecting A contains a number listed above, and the rook in this column is inside A, as required. The construction for n=ℓ2 is established.
It remains to construct a happy configuration of rooks not containing an empty ℓ×ℓ square for n<ℓ2. In order to achieve this, take the construction for an ℓ2×ℓ2 square described above and remove the ℓ2−n bottom rows together with the ℓ2−n rightmost columns. We will have a rook arrangement with no empty ℓ×ℓ square, but several rows and columns may happen to be empty. Clearly, the number of empty rows is equal to the number of empty columns, so one can find a bijection between them, and put a rook on any crossing of an empty row and an empty column corresponding to each other.
Comment. Part (i) allows several different proofs. E.g., in the last paragraph of the solution, it suffices to deal only with the case n=ℓ2+1. Notice now that among the four corner squares, at least one is empty. So the rooks in its row and in its column are distinct. Now, deleting this row and column we obtain an ℓ2×ℓ2 square with ℓ2−1 rooks in it. This square can be partitioned into ℓ2 squares of size ℓ×ℓ, so one of them is empty.