#P9178. [COCI 2022/2023 #5] Diskurs

[COCI 2022/2023 #5] Diskurs

Problem Description

You are given nn non-negative integers a1,a2,ana_1, a_2, \cdots a_n, each of which is less than 2m2^m.

For each number, you need to find its maximum Hamming distance to the other elements in the array.

The Hamming distance between two non-negative integers is defined as the number of positions where their binary representations differ (adding leading zeros if necessary).

Formally, for each ii, compute:

$$\max\limits_{1\leq j\leq n} \operatorname{hamming}(a_i,a_j)$$

Input Format

The first line contains two integers nn and m (1n2m,1m20)m \ (1\leq n\leq 2^m,1\leq m\leq 20)
The second line contains nn numbers ai (0ai<2m)a_i \ (0 \leq a_i < 2^m)

Output Format

Output one line with nn integers. The ii-th integer represents the maximum Hamming distance between aia_i and the other elements in the array.

4 4
9 12 9 11

2 3 2 3
4 4
5 7 3 9
2 3 2 3

4 4
3 4 6 10

3 3 2 3

Hint

Subtask pts\text{pts} Constraints
00 Sample only
11 2020 m10m\leq 10
22 2525 m16m\leq 16
33 None

Translated by ChatGPT 5