图论
  • 板块学术版
  • 楼主Prolystic
  • 当前回复3
  • 已保存回复3
  • 发布时间2023/6/7 11:18
  • 上次更新2023/10/23 13:46:43
查看原帖
图论
695863
Prolystic楼主2023/6/7 11:18
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 105, MAXM = 1e5 + 5;
struct EDGE{
	int next;//起始点
	int to;//终止点
	int dist;//边权
}edge[MAXM];//边集
int head[MAXN], num_edge, n, m, u, v, d;//head是干嘛的?
void add_edge(int from, int to, int dist){
	edge[++num_edge].next = head[from];
	edge[num_edge].to = to;
	edge[num_edge].dist = dist; 
    //这三个是设置边的基本信息
	head[from] = num_edge;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m;
	while(m--){
		cin >> u >> v >> d;
		add_edge(u, v, d);
	}
	return 0;
}

head[MAXN] 是干啥的?本人啃信奥**通好久没看明白,求大佬指教!

2023/6/7 11:18
加载中...