Блог пользователя Epilogue

Автор Epilogue, история, 11 месяцев назад, По-английски

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

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор Epilogue, история, 14 месяцев назад, По-английски

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.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +10
  • Проголосовать: не нравится