force_awakens's blog

By force_awakens, history, 7 years ago, In English

We can solve the maximum (AND) subsequence of an array by checking the common bits in numbers in O(nlogn).But how can we find a susequence with maximum XOR?

Full text and comments »

  • Vote: I like it
  • -2
  • Vote: I do not like it

By force_awakens, history, 7 years ago, In English

hello everyone,

Recently i came across this problem http://www.spoj.com/problems/DQUERY/en/. I coded the offline solution, but i was wondering how to solve it using persisent segment trees.I kept an array last_occur[i] which stores the latest occurence of the number i. now given a range (l,r) we need to find number of distinct elements with last_occur[i] < l.I got stuck here, how do we solve this part?

Full text and comments »

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