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

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

We are given an array of length $$$N$$$ and $$$Q$$$ queries (offline) where each query is a value $$$K$$$, for each query we need to count number of pairs in array with XOR $$$K$$$.

If $$$N$$$ and $$$Q$$$ can both be upto $$$10^5$$$, is it possible to answer these queries better than traversing entire array for each query?

An analogous version to count pairs with given sum uses FFT to precompute frequency every possible sum, which seems very difficult to do for XOR operation.

We can assume values in array are upto $$$10^5$$$ too, but if a solution exists which works for larger numbers too, that's preferable.

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

»
9 месяцев назад, # |
  Проголосовать: нравится +10 Проголосовать: не нравится

well, technically, if value in array upto $$$10^5$$$, it just FWT.