Блог пользователя Len

Автор Len, история, 9 лет назад, По-английски

Given array a of length 1 ≤ n ≤ 44, 0 ≤ ai ≤ 244. Calculate di = number of subsets that their xor has i '1' bits.
I think this is a meet-in-the-middle problem but I couldn't solve it, so I need help.

  • Проголосовать: нравится
  • +64
  • Проголосовать: не нравится

»
9 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +20 Проголосовать: не нравится

The set of ai generates a vector space. Let D be the dimension of this space.

  • There are 2D elements in this vector space. Brute force works in O(2D * poly(N)).

  • There is a system of N - D equations that defines this space. Bitmask DP works in O(2N - D * poly(N)).

  • »
    »
    9 лет назад, скрыть # ^ |
    Rev. 3  
    Проголосовать: нравится +43 Проголосовать: не нравится

    The same solution/approach from a bit different perspective (I think it's different enough to describe it):

    Imagine a grid with 0's and 1's, where the i-th row contains ai. Run Gauss Elimination, to get 1's in say first D cells of the main diagonal, and only 0's above and below those 1's. Also, only first D rows are non-zeros. (We can obtain that, but in Gauss we must swap rows and swap columns).

    Then run brute force if D is small, and otherwise run bitmask DP on last M-D columns, where the score of subset of taken rows should be equal to the numbers of 1's in the xor, increased by the number of rows taken, because each taken row has one 1 on the left, in forgotten main diagonal.

    btw. I think all blogs like this one should give the source of a problem, so others could implement and submit a solution, and to fight (a bit) with cheating and asking about problems from ongoing contests.

»
9 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

UPD: I'm so so sorry guys I completely misunderstood the problem please don't take this answer in consideration.

I'm not sure if this is correct but maybe we can do something like this:

DP[pos][bit][ok] which denotes the number of subsets that don't have an element whose index is bigger than pos and that has the bitth bit equal to ok and your moves will be either

DP[pos + 1][bit][ok] or dp[pos + 1][bit][ok ^ bitth bit of a[pos]].

Now I know that this probably isn't a right solution I'm just trying to provide a perspective that someone might use to achieve a correct solution.