hdu6181 Two Paths 次短路模板

广西模拟赛后开始艰辛的改代码风格


/* ***********************************************
Author        :BPM136
Created Time  :2017/8/28 21:55:06
File Name     :6181.cpp
************************************************ */

#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;

const int N = 100005;
const long long inf = 35000000000000000LL;

typedef pair lli;

struct edge {
	int y,next;
	long long w;
}e[N<<1];
int last[N],ne=0;;

long long dist[N],dist2[N];

int n,m;

void add(int x,int y,int w) {
	e[++ne].y=y; e[ne].w=w; e[ne].next=last[x]; last[x]=ne;
}

void SPFA() {
	for(int i=1;i<=n;i++) dist[i]=dist2[i]=inf;
	priority_queue< lli ,vector, greater > Q;
	Q.push(lli(0,1));
	dist[1]=0;
	while(!Q.empty()) {
		lli t=Q.top(); Q.pop();
		long long dis=t.first;
		int u=t.second;
		if(dis>dist2[u]) continue;
		for(int i=last[u];i!=0;i=e[i].next) {
			int v=e[i].y;
			long long dis2=dis+e[i].w;
			if(dis2

你可能感兴趣的:(模板,次短路)