아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Diskurs

시간 제한2초메모리 제한1024 MB

요약
모든 값이 2^m 미만인 배열에서 각 원소마다 다른 원소와의 해밍 거리의 최댓값을 구한다.
난이도

보통10점 중 7점

유형
비트 연산, 동적 계획법
정답자
아직 제출이 없습니다

문제

You are given nn non negative integers a_1,a_2,…,a_na\_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: max⁡_1≤j≤nhamming(a_i,a_j)\max\_{1 \le j \le n}hamming(a\_i, a\_j)

입력

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

The second line contains nn numbers a_ia\_i (0≤a_i<2m0 ≤ a\_i < 2^m)

출력

Output nn numbers seperated with spaces, where the ii-th number is the maximum hamming distance between a_ia\_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.

예제3

  1. 예제 1

    입력
    4 4
    9 12 9 11
    
    예상 출력
    2 3 2 3
    
  2. 예제 2

    입력
    4 4
    5 7 3 9
    
    예상 출력
    2 3 2 3
    
  3. 예제 3

    입력
    4 4
    3 4 6 10
    
    예상 출력
    3 3 2 3