Tree Problem . Can anybody explain the approach Please

Revision en1, by Roronoa__Zoro, 2024-07-25 14:58:25

Given $$$N$$$ cities connected by $$$N-1$$$ bidirectional roads i.e they form a tree . Cities with odd numbers are cities of Jack and even numbers cities belong to Bob. Each city has some initial popularity given by array Popularity. Now there are $$$Q$$$ tours taken by some tourists from city u to v taking the simple path.

As they travel from city u to v , the popularity of cities in between increases by x units. Let $$$P1$$$ and $$$P2$$$ be the sum of popularities of the cities of Jack and Bob after $$$Q$$$ tours . You need to print the absolute difference between P1 & P2.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Roronoa__Zoro 2024-07-25 15:52:05 34 Tiny change: 'P1 & P2**.' -> 'P1 & P2**.\n$N \le 10^{5}$\n$K \le 10^{6}$'
en1 English Roronoa__Zoro 2024-07-25 14:58:25 627 Initial revision (published)