点击打开链接
两次求最短路(第二次把边反向求)
1、spfa
//poj 3268 Silver Cow Party
//SPFA
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
const int M = 100000 + 100;
const int N = 1000 + 100;
const int inf = 1<<25;
struct Graph {
int head[N], next[M], to[M], val[M], cnt, n;
void init(int num)
{
memset(head, -1, sizeof head );
for(int i=1; i<=n; ++i) d[i] = inf;
cnt = 0;
n = num;
......
阅读全文