P1461 [USACO2.1] Hamming Codes

Description

Given $n,b,d$, find $n$ binary codewords consisting of 0 and 1, each with $b$ bits, such that the Hamming distance between every pair of codewords is at least $d$. The Hamming distance is the number of differing bit positions between two binary codewords. For example, the Hamming distance between `0101 0101 0100` and `0010 0011 0100` is $5$: ```plain 0101 0101 0100 0010 0011 0100 ^^^ ^^ ```

Input Format

One line containing three integers $n,b,d$.

Output Format

Output the lexicographically smallest solution (the $n$ codewords must also be printed in ascending order). Print a newline after every $10$ codewords. You should first treat each codeword as a binary number, then convert it to a decimal number for output.

Explanation/Hint

Constraints: For $100\%$ of the testdata, $1\le n \le 64$, $1\le b \le 8$, $1\le d \le 7$. Please note: the problem only requires the Hamming distance to be at least $\bm d$, so it may also be greater than $\bm d$. USACO 2.1 Translation from NOCOW Translated by ChatGPT 5