很裸的一道dijk算法题,因为顶点数太多无法用邻接矩阵表示,所以要用临界表来表示
AC代码
#include#include #include #include #include #include using namespace std;using namespace std;const int maxn=2*50000;#define inf 99999999struct node{ int v; int u; int w; int next;}V[maxn];int head[maxn];int d[maxn];int n,m,s,t;int tol;int done[maxn];typedef pair pii; priority_queue ,greater >q;void init(){ tol=0; memset(head,-1,sizeof(head));}void dijk(){ memset(done,0,sizeof(done)); for(int i=0;i<=n;i++) d[i]=inf; d[s]=0; q.push(make_pair(d[s],s)); while(!q.empty()) { pii u=q.top(); q.pop(); int x=u.second; if(done[x]) continue; done[x]=1; for(int e=head[x];e!=-1;e=V[e].next) { int v=V[e].v; int w=V[e].w; if(d[x]+w