Please read the new rule regarding the restriction on the use of AI tools. ×

vk705017's blog

By vk705017, history, 15 months ago, In English

(here is my code) i am getting wrong answer in pretest

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

| Write comment?
»
15 months ago, # |
Rev. 5   Vote: I like it +8 Vote: I do not like it

In terms of WA -> Your code will fail when the tree is one such as:

Case

You would treat this as 2 different components.

In addition, you will have to precompute the number of leaves as calculating it for each query ends up being too slow ( O(qn) )! Here is my submission which precalculates number of in each subtree: 210376139