terserah's blog

By terserah, history, 7 years ago, In English

Hello, i am struggling to solve this problem from SPOJ. Can anybody give me some hints? Thanks in advance!

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

»
7 years ago, # |
  Vote: I like it +3 Vote: I do not like it

You could change the problem by preprocessing the tree and answering how many nodes in a subtree have a tag  ≤  k

  • »
    »
    7 years ago, # ^ |
    Rev. 2   Vote: I like it +3 Vote: I do not like it
    Spoiler
  • »
    »
    7 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    i think we can't preprocess the tree, because we have to answer the query online. CMIIW