#P9178. Maximum Hamming Distance for Array Elements

    ID: 22334 Type: Default 1000ms 256MiB

Maximum Hamming Distance for Array Elements

Maximum Hamming Distance for Array Elements

Given an array of n non-negative integers where each integer is less than 2m2^m, your task is to compute, for every element, the maximum Hamming distance between it and any other element in the array. The Hamming distance between two non-negative integers is defined as the number of positions where their mm-bit binary representations (with leading zeros if necessary) differ.

Formally, for each ii (1 ≤ i ≤ n), compute:
$$\max_{1\leq j\leq n} \text{hamming}(a_i,a_j)$$

inputFormat

The first line contains two integers nn and mm.

The second line contains nn non-negative integers a1,a2,,ana_1, a_2, \dots, a_n, each less than 2m2^m.

outputFormat

Output nn integers separated by spaces, where the ii-th integer is the maximum Hamming distance between aia_i and any element in the array (including itself).

sample

3 3
5 4 0
2 2 2