The first question: 1107
This question prompt on the table adjacent to and vector type I use the adjacency table is not the same, is inserted from a header, a footer from insertion, I 0 from the edge even when the order or the 1-n.
But this approach has timed out a point, so I even changed sides from 1 to n on the tips, the result was a two-point overtime.
Later I found out you can not even side, the implementation of SPFA each point to the team (which is space optimization), but still out.
Finally found a stupid mistake - not forfeit ring!
After forfeit the ring together on the AC.
AC Code: