tyristik's blog

By tyristik, history, 4 hours ago, In English

How to solve today's C problem if alphabet is not $$$26$$$ characters but rather $$$O(n)$$$? I could only come up with simple offline $$$O(q \sqrt n)$$$ solution using basic MO algorithm. Any ideas?

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

»
3 hours ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

How do you solve it in $$$\sqrt{n}$$$ per query?

  • »
    »
    2 hours ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Mo's algorithm: you can maintain answer for segment $$$(l, r)$$$ and recalculate it in $$$O(1)$$$ when moving borders. That's basics of MO.