链式前向星如何去重边自环
  • 板块灌水区
  • 楼主Hf_Poem
  • 当前回复10
  • 已保存回复10
  • 发布时间2024/10/22 08:10
  • 上次更新2024/10/22 13:40:29
查看原帖
链式前向星如何去重边自环
750476
Hf_Poem楼主2024/10/22 08:10

RT

#include<bits/stdc++.h>
#define IXcape cout<<endl;return 0
#define Venti cout<<"\nVenti!\n"
#define int long long
using namespace std;
const int V=2e4+10;
int n,m;
int h[V],e[V],ne[V],w[V],idx;

inline
void add(int a,int b,int c){
	e[idx]=b,ne[idx]=h[a],w[idx]=c,h[a]=idx++;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	memset(h,-1,sizeof h);
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int a,b,c;
		cin>>a>>b>>c;
		add(a,b,c);
	}
	
	IXcape;
}
/*

*/

我是这么写前向星的(((

2024/10/22 08:10
加载中...