Directed integer weights may be negative. Return minimum costs with nullopt unreachable. n<=0, invalid source/endpoints, or source-reachable negative cycle throws invalid_argument. Unreachable negative cycles do not throw. Prototype paths plus reachable-cycle inspection; final V-1 relaxations and cycle pass. Preserve edges.
Public signatures:
Vec<Opt<Int>> prototype(const Int& n,const Vec<std::tuple<Int,Int,Int>>& edges,const Int& source);
Vec<Opt<Int>> solve(const Int& n,const Vec<std::tuple<Int,Int,Int>>& edges,const Int& source);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.