← All problemsSign in

Tree Cut Xor

CodeChefRating 2548Open on judge ↗

You are given a tree with $N$ vertices. Initialize a variable $X = 0$. You would like to perform the following operation $N-1$ times: * Choose an edge $(u,v)$ that still hasn't been deleted. * Delete the edge $(u,v)$. * Let $\text{siz}(u)$ denote the size of the connected component that $u$ is contained in and $\text{siz}(v)$ denote the size of the connected component that $v$ is contained in. XO

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