- 博客(4)
- 收藏
- 关注
原创 并查集
入门博客:超有爱的并查集 进阶博客:并查集算法优化变种 处理不相交集合的合并于查询问题 模板: #include<iostream> //并查集 #define N 100 using namespace std; int pre[N]; int n,m; int find(int x) //递归写法 { if(x!=pre[x]) pre[x]=find(pre...
2019-08-08 16:47:17
67
原创 KMP
添加链接描述 #include<iostream> #include<cstring> #define N 100 using namespace std; //最小循环节的长度 L=len-next[len]; //如果len%(len-next[len)==0,循环周期T=len/L; //需要补充的元素个数成为循环 L-next[len]%L; //next...
2019-08-01 20:29:17
62
原创 最小生成树,最短路模板
普里姆——Prim算法(稠密图) 算法思路: 先找a点,找出a点有连通点存入E,选出最小权值边的点作为为b点,找出与b点有连通的点存入E,再找出最小权值边的点,重复 ,直至构造成最小生成树。 模板 #include<iostream> #define N 100 #define MAX 65635 using namespace std; typedef struct { int ...
2019-06-02 10:14:30
175
原创 排序算法模板——手指记忆法
先读懂代码 ,然后多敲就完事了! 1.冒泡排序 原理:两两之间比较 //模板自己写 2.直接选择排序` 原理:两两之间比较,找最值下标 void SlectSort(int k[],int n) { for(int i=0;i<n-1;i++) { int min=k[i]; { for(int j=i+1;j<n;j++) { if(min>k[...
2019-05-24 20:09:27
200
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人