PivotOJ

Diskurs

시간 제한: 2000ms메모리 제한: 1024MB출처: COCI 2022-2023BOJ 27909

문제

You are given nn non negative integers a1,a2,,ana_1, a_2, \dots , a_n less than 2m2^m. For each of them you are to find the maximum possible hamming distance between it and some other element of the array aa.

The hamming distance of two non negative integers is defined as the number of positions in the binary representation of these numbers in which they differ (we add leading zeros if necessary).

Formally, for each ii calculate: max1jnhamming(ai,aj)\max_{1 \le j \le n}hamming(a_i, a_j)

입력

The first line contains two integers nn and mm (1 ≤ n ≤ 2^m, 1 ≤ m ≤ 20).

The second line contains nn numbers aia_i (0 &le; a_i < 2^m)

출력

Output nn numbers seperated with spaces, where the ii-th number is the maximum hamming distance between aia_i and some other number in aa.

힌트

Clarification of the third example: The numbers 33, 44, 66, 1010 can be represented as 00110011, 01000100, 01100110, 10101010, in binary. Numbers 33 and 44 differ at 33 places, same as numbers 44 and 1010. On the other hand, the number 66 differs in at most 22 places with all other numbers.

예제

예제 1

입력
4 4
9 12 9 11
출력
2 3 2 3

예제 2

입력
4 4
5 7 3 9
출력
2 3 2 3

예제 3

입력
4 4
3 4 6 10
출력
3 3 2 3
코드를 제출하려면 로그인하세요.