您当前的位置: 首页 > 

钟钟终

暂无认证

  • 2浏览

    0关注

    233博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

2/1 最短路径和链式前向星的结合应用

钟钟终 发布时间:2022-02-01 20:46:52 ,浏览量:2

首先写第三点,我觉得是最重要的,dijkstra算法的优化,从复杂度O(n方)复杂度降到 在这里插入图片描述 算是最佳的最短路径方法,非常稳定。下面是代码

#include 

using namespace std;
const int maxn=200005;
typedef long long ll;
const int inf=0x7fffffff;
struct node
{
    int to,dis,nxt;
}e[1000005];
int head[maxn],n,m,s,t,u,v,w,nxt,cnt;
ll dist[maxn],minn;
bool vis[maxn];
void add_edge(int from,int to,int dis)
{
    e[++cnt].to=to;
    e[cnt].dis=dis;
    e[cnt].nxt=head[from];
    head[from]=cnt;
}

struct node1
{
    int dis,pos;
    bool operator             
关注
打赏
1664378814
查看更多评论
0.0366s