版本比较
一些模板
正文
增加 23 行删除 27 行
104 行未改动全部展开105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135109110111112113114115116117118119120121122123124125126127128129130131132133134104 行未改动全部展开}```Dij:```cppint n,m,k;struct node { long long u,v,w; bool operator > (const node& a) const { return w > a.w; }};int len=0;priority_queue< node , vector < node > , greater < node > >q;node a[200010];bool vis[200010];long long ans[200010];void dig() { q.push({0,k,0}); while(!q.empty()) { node uu=q.top(); q.pop(); if(vis[uu.u])continue; vis[uu.u]=1; for(int i=1; i<=m; i++) { if(vis[a[i].v])continue ; if( ans[a[i].v]>ans[a[i].u]+a[i].w) { ans[a[i].v]=ans[a[i].u]+a[i].w; q.push(a[i]); } } }vector<pair<int,int> > g[1008617];vector<int> dis(1008617,2147483647);void dij(int u){ priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > pq; dis[u]=0; pq.push({0,u}); while(pq.size()) { pair<int,int> p=pq.top(); pq.pop(); int u=p.second; if(p.first>dis[u])continue; for(auto i:g[u]) { int v=i.first,w=i.second; if(dis[u]+w<dis[v]) { dis[v]=dis[u]+w; pq.push({dis[v],v}); } } }}```读写: