dijkstra算法+邻接表+优先队列

#include

using namespace std;

const int maxn=1e4+5;
const int inf=(1<<20);
const int white=0;
const int gray=1;
const int black=2;

int n;
vector >adj[maxn];

void dijkstra()
{
    priority_queue >q;
    int book[maxn],d[maxn];
    for(int i=0;if=q.top();
        q.pop();
        int u=f.second;
        book[u]=1;
        for(int j=0;jd[u]+adj[u][j].second){
                d[v]=d[u]+adj[u][j].second;
                q.push(make_pair(d[v]*(-1),v));
            }
        }
    }
    for(int i=0;i>u>>k;
        for(int i=0;i>v>>c;
            adj[u].push_back(make_pair(v,c));
        }
    }
    dijkstra();
    return 0;
}

你可能感兴趣的:(弹药库)