标签:ret opera ace print str operator can turn int
#include<cstdio> #include<algorithm> #include<queue> #include<cstring> using namespace std; struct my{ int v; int next; int w; }; struct head{ int u; int w; bool operator<(const head &rhs)const{ return w>rhs.w; } }; const int maxn=1e5+10; const int nil=0x7f7f7f7f; my bian[maxn*10]; int adj[maxn],fa,n,m,d[maxn],dist[maxn]; bool done[maxn]; priority_queue<head>Q; void myinsert(int u,int v,int w){ bian[++fa].v=v; bian[fa].next=adj[u]; bian[fa].w=w; adj[u]=fa; } void dijistar(int s){ for (int i=1;i<=n;i++) d[i]=nil; while(!Q.empty()) Q.pop(); d[s]=0; head x; x.u=s; x.w=0; Q.push(x); while(!Q.empty()){ x=Q.top();Q.pop(); int u=x.u; if(done[u]) continue; done[u]=true; for (int i=adj[u];i;i=bian[i].next){ int v=bian[i].v; if(d[v]>d[u]+bian[i].w){ d[v]=d[u]+bian[i].w; x.u=v; x.w=d[v]; dist[v]=u; Q.push(x); } } } } int main(){ printf("%d",nil); int s,t; int u,v,w; scanf("%d%d%d%d",&n,&m,&s,&t); for (int i=1;i<=m;i++){ scanf("%d%d%d",&u,&v,&w); myinsert(u,v,w); myinsert(v,u,w); } dijistar(s); printf("%d\n",d[t]); return 0; }
标签:ret opera ace print str operator can turn int
原文地址:https://www.cnblogs.com/lmjer/p/9337753.html