#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <math.h>
#include <bitset>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include<functional>
#include<time.h>
#include<stdlib.h>
#include<time.h>
#include <climits>
using namespace std;
const int maxn = 1e6;
map<char, int >mp;
int a[100010][12];
struct Edge{
int to, next, w;
}edge[maxn];
int head[maxn];
int cnt;
void intit()
{
cnt = 0;
for (int i = 0; i < maxn; i++)
{
edge[i].next = -1;
head[i] = -1;
}
}
void add(int u, int v, int w)
{
edge[cnt].to = v;
edge[cnt].w = w;
edge[cnt].next = head[u];
head[u] = cnt++;
}
void add(int u, int v, int w)
{
edge[cnt].to = v;
edge[cnt].w = w;
edge[cnt].next = head[u];
head[u] = cnt++;
}
int main(){
return 0;
}
关于链式前向星,其实就是一个数组模拟链表的过程,既然我们已经学会了vector的邻接表的存图,为什么还要去学链式前向星?其实是邻接表的常数略大,容易在题目中被卡常。链式前向星最巧妙的部分其实就在加边的最后两列代码。转载bilibili 的up主视频,这应该是我看过最友好的解释了。
https://www.bilibili.com/video/BV1mJ411S7BB?from=search&seid=1970747121682435324
链式前向星是一种高效存储图结构的方法,相较于邻接表,其常数更小,能避免在竞赛编程中因常数过大导致超时。本文介绍了链式前向星的实现细节,包括加边操作的关键代码,并推荐了一个视频资源,帮助理解这一概念。
2924

被折叠的 条评论
为什么被折叠?



