Need help with tree problem

Revision en1, by I_love_Vovuh_s_cat, 2018-12-13 19:26:07

Given a tree with n nodes, rooted at 1. You have q offline queries with the form of ui, vi and xi. You have to add xi to every node in the simple path from ui to vi. It is guaranteed than ui is an ancestor of vi. Then you have to print out the values of all the nodes. The limit is... well, too large for O(n^2). Could anyone give me an approach to this problem?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English I_love_Vovuh_s_cat 2018-12-13 19:26:07 394 Initial revision (published)