fixed logical error of C++/SPFA