So I sat down to plunge myself into graphs.
The code below is 99% copy-paste of the code posted by @kuruma in the above post. Yet, it reports FIRESC.exe has stopped working as soon as I enter the inputs for the 1st test case. But the code in the above link works fine (obviously!).
I’ve compared the codes repeatedly and spent hours debugging and trying to figure out the cause of the mishap. But to no avail. Could anyone out there please help me out?