Undirected weighted edges, negatives allowed. Normalize endpoints, process by (weight,min,max), reject cycles/self-loops, return (total,edges) in acceptance order or nullopt disconnected. n=0 or 1 returns (0,[]) for valid edges. Negative n/invalid endpoints throw invalid_argument. Prototype connectivity traversals; final DSU compression/union-by-size. Preserve edges.
Public signatures:
Opt<std::pair<Int,Vec<std::tuple<Int,Int,Int>>>> prototype(const Int& n,const Vec<std::tuple<Int,Int,Int>>& edges);
Opt<std::pair<Int,Vec<std::tuple<Int,Int,Int>>>> solve(const Int& n,const Vec<std::tuple<Int,Int,Int>>& edges);Compile and run from this directory:
c++ -std=c++20 -O2 -Wall -Wextra -pedantic -pthread main.cpp -o practice
./practice --stage prototype
./practice --stage finalEdit exercise.hpp. Both stages start unfinished and must report failures until implemented. Keep main.cpp as the executable contract. The runner returns nonzero for a failed check, an unexpected exception, an invalid stage, or an empty suite. C++20 and only the standard library are required.
Complete the starter code, then run the checks.
Results and errors will appear here.
C++ runtime powered by Wasmer.