Implement prototype(n: int, edges: list[tuple[int, int, int]]) -> tuple[int, list[tuple[int, int, int]]] | None and solve with the same signature. Vertices are 0..n-1; integer-weighted edges are undirected and may be negative.
Normalize endpoints to (min(u,v), max(u,v), weight). Process candidates by (weight, min_endpoint, max_endpoint), rejecting cycles/self-loops. Return (total_cost, accepted_edges) in acceptance order. Return None if disconnected; n=0 or 1 returns (0,[]) for valid edges.
Example: (3, [(1,0,2),(1,2,3),(0,2,9)]) returns (5, [(0,1,2),(1,2,3)]).
Raise ValueError for negative n or invalid endpoints. Prototype: process sorted edges and use DFS/BFS over accepted edges to detect cycles. Final: replace those repeated traversals with DSU using path compression and union by size or rank. Preserve inputs, including on failure.
Complete the starter code, then run the checks.
Results and errors will appear here.