ExtraStageLover's blog

By ExtraStageLover, history, 12 months ago, In English

Hi, I am trying to solve this problem. Given a tree with n nodes and m queries, each node have a value assign to it, for each query of the form (x, y, val), return the maximum value of (a(i) XOR val), a(i) is the value of the ith node and (i) must on the path from x to y.

My approach is using persistent trie, I solved it by implement with array for trie but when I tried using pointer its MLE. Does anybody what is wrong with my code, I think pointer is better since you may miscalculate the memory when using array.

My code: https://ideone.com/jWOuw7

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By ExtraStageLover, history, 15 months ago, In English

Hi!. I'm solving a problem. Given a tree with N nodes with colors and q queries. For each query given two integers (u, v), answer if the path(u, v) on the tree is dominant. A path is called dominant when the most frequently occuring element appears strictly more than pathlength / 2.

Are there any offline, online solutions for this? If you have any ideas please comment bellow.

Full text and comments »

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