The Question
Coding
Maintaining Even Cycle Weight Constraints
Given an undirected graph with $n$ nodes and a series of edges with binary weights (0 or 1), implement an algorithm to process edges one by one. An edge $(u, v)$ with weight $w$ should only be added if all resulting cycles in the graph have an even total weight sum. Return the total count of successfully added edges. Optimize for large $n$ and $E$ using a Disjoint Set Union (DSU) variant.
Java
DSU
Graph
XOR
April 3, 2026