Rezwan.Arefin01's blog

By Rezwan.Arefin01, history, 8 years ago, In English

In past few months, I solved 4-5 problems in live contests. Where the problem reduces to check if every number in a range occurs even number of times. I first mapped the values into arbitrary large random numbers and then used range XOR to determine if all them occurred even number of times.

After contest, I've heard that such solution using range XOR can be hacked using Gaussian Elimination. Can someone please explain me the process? I know Gaussian Elimination, but can't figure this out.

[I've heard that this problem — Check if all every number is a range has even frequency — can be solved by polynomial hashing too. Can someone explain that? Also is there any deterministic solution not using MO's algo?]

  • Vote: I like it
  • +35
  • Vote: I do not like it

»
8 years ago, # |
Rev. 2   Vote: I like it +12 Vote: I do not like it

For each position i you can calc binary string of length n. j'th bit will be 1 if there are odd number of positions with number j on prefix of length i and 0 otherwise. After that to check segment [l;r] you just need to check if stri - 1 = strj, and you can do it with polynomial hashing.