Question link:
Question link: Portal
The question is very important ..
The number of paths from the start point to the end point as required. For any two points A and B, the condition that A can go from A to B is that there is A path from B to the end of the length less than any one A to the end of the road, that is, the minimum short circuit from B to the end is smaller than that from A to the end. Why? Think about it. now we need to find A path in the path from B to the end to ensure that its length is smaller than the shortest path from A to the end (think about it and try any two words ), therefore, when the short circuit from B to the end meets the above conditions, the first condition is met. (Because if the shortest path from B to the end cannot be smaller than any path from A to the end, the other path will not be satisfied ..)
Then there is the number of dfs search paths ..
#include #include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define ll long long#define maxn 1010#define pp pair
#define INF 0x3f3f3f3f#define max(x,y) ( ((x) > (y)) ? (x) : (y) )#define min(x,y) ( ((x) > (y)) ? (y) : (x) )using namespace std;vector < pp > eg[maxn];int n,m,dis[maxn],dp[1010];bool vis[1010];void spfa(){queue
Q;memset(vis,0,sizeof(vis));memset(dis,INF,sizeof(dis));dis[2]=0;Q.push(2);while(!Q.empty()){int u=Q.front();Q.pop();vis[u]=0;for(int i=0;i
dis[u]+w){dis[v]=dis[u]+w;if(!vis[v]){vis[v]=1;Q.push(v);}}}}}int dfs(int u){if(u==2)return 1;if(dp[u]>=0)return dp[u];dp[u]=0;for(int i=0;i