文章
40
粉丝
512
获赞
13
访问
372.9k
#include<bits/stdc++.h>
using namespace std;
int const MAXN=10001;
int const INF=INT_MAX;
struct Edge{
int to;
int len;
Edge(int t,int l):to(t),len(l){}
};
struct Point{
int num,dist;
Point(int n,int d):num(n),dist(d){}
bool operator< (const Point& p) const{
return dist>p.dist;
}
};
vector<Edge> graph[MAXN];
int dis[MAXN];
void Dijistra(int s){
priority_queue<Point> mq;
dis[s]=0;
mq.push(Point(s,dis[s]));
while(!mq.empty()){
int u=mq.top().num;
mq.pop();
for(int i=0;i<graph[u].size();i++){
int v=graph[u][i].to;
int l=graph[u][i].len;
if(dis[v]>dis[u]+l){
dis[v]=dis[u]+l;
mq.push(Point(v,dis[v]));
}
}
}
}
int main(){
int n,m,s;
cin>>n>>m>>s;
memset(graph,0,sizeof(graph));
fill(dis,dis+MAXN,INF);
...
登录后发布评论
暂无评论,来抢沙发