← All problemsSign in

Beautiful Sum

CodeChefRating 2072Open on judge ↗

You are given a rooted tree of $N$ nodes, where node $1$ is the root. The $i$-th edge has weight $w_i$ and connects nodes $u_i$ and $v_i$. You have to process $Q$ queries of two types: - $1 \, u \, x$ : For every edge in the subtree of node $u$, update its weight by applying the bitwise XOR with $x$, i.e., $w_i \gets w_i \oplus x$. - $2 \, u$ : Compute the sum of **beauty** for all possible unord

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start