#P1461. [USACO2.1] 海明码 Hamming Codes

    ID: 453 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>搜索USACO进制概率论,统计位运算,按位

[USACO2.1] 海明码 Hamming Codes

Description

Given n,b,dn,b,d, find nn binary codewords consisting of 0 and 1, each with bb bits, such that the Hamming distance between every pair of codewords is at least dd.

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 55:

0101 0101 0100
0010 0011 0100
 ^^^  ^^       

Input Format

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

Output Format

Output the lexicographically smallest solution (the nn codewords must also be printed in ascending order). Print a newline after every 1010 codewords.

You should first treat each codeword as a binary number, then convert it to a decimal number for output.

16 7 3
0 7 25 30 42 45 51 52 75 76
82 85 97 102 120 127

Hint

Constraints: For 100%100\% of the testdata, 1n641\le n \le 64, 1b81\le b \le 8, 1d71\le d \le 7.

Please note: the problem only requires the Hamming distance to be at least d\bm d, so it may also be greater than d\bm d.

USACO 2.1

Translation from NOCOW

Translated by ChatGPT 5