Problem 3973 · Hard

Distinct Gate Paths to LCA

In a rooted tree each node has red, blue and white gates; a card passes a gate of its colour and stays, or passes a white gate and flips. For each query, count the gate choices that bring Alice and Bob up to their lowest common ancestor, then XOR those counts.

Open the interactive visualisation