/* HDU 4076 haunted graveyard-spfa (negative weight loop) Question: There are N * m points, each point can go in four directions, and some points cannot go in the cemetery, some points are cave. When you reach this point, it will be transferred to another point. The time spent may be a positive number, a negative number, or 0. The starting point is (0, 0), and the destination is (N-1 m-1). The question ensures that the starting point and ending point are not the cemetery or the cave. If it is possible that it will never reach the end point, that is, the graph has a negative weight loop and outputs The never; otherwise, the output will take the least time or impossible; idea: if there is a negative weight, it is obvious that spfa is used. When the number of relaxation times for a certain point Times out, the number of vertices in the graph is N * m, which indicates there is a negative weight loop. However, you must note that the end point cannot be included when determining the negative weight loop, because the end point will not be relaxed when it first reaches the end point. */# Include <iostream> # include <cstring> # include <queue> using namespace STD; # define INF 0 xfffffffconst int n = 35; int map [N] [N], XX [N] [N], YY [N] [N], TT [N] [N], DIST [N] [N], vis [N] [N], CNT [N] [N]; int dir [4] [2] = {}, {0,-1 }}; int W, H, flag; struct node {int X, Y ;}; void spfa () {int I, j, ans; for (I = 0; I <W; ++ I) {for (j = 0; j