Chef and Tree
Chef has a tree on N nodes. Each node v has an integer label Cv attached to it. Chef also has two other integers, A and B. He needs to run Q queries on the tree, each of which can be one of the following two types: - 1 u v w — add w to the labels of all vertices which lie on a simple path between nodes u and v. - 2 u v — find the number of vertices x on a simple path between u and v for which A*C
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start