上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 30 下一页
摘要: 1.线性表的顺序表示 1 //线性表的顺序表示(c++) 2 #include <iostream> 3 using namespace std; 4 const int list_size = 100; 5 const int ex_size = 10; 6 typedef struct{ 7 i 阅读全文
posted @ 2017-09-05 22:43 Posase 阅读(254) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 网络流之最大流Dinic算法模版 3 */ 4 #include 5 #include 6 #include 7 using namespace std; 8 const int maxn = 205; 9 const int inf = 0x3f3f3f3f; 10 struct 11 { 12 int c,f;//c为边的容量,f为边的容量 1... 阅读全文
posted @ 2017-08-15 21:24 Posase 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 网络流的最大流问题 3 刚学习Dinic算法。模版题 4 */ 5 #include 6 #include 7 #include 8 using namespace std; 9 const int maxn = 205; 10 const int inf = 0x3f3f3f3f; 11 struct 12 { 13 int c,f; 14 }e... 阅读全文
posted @ 2017-08-15 21:20 Posase 阅读(189) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 归并排序模版 3 对n个数进行排序 4 时间复杂度:O(nlogn); 5 利用分治思想,对比左半边和右边边放入一个暂时的数组进行排序 6 */ 7 #include 8 using namespace std; 9 const int maxn = 1005; 10 int a[maxn], t[maxn]; 11 void merge(int a[], i... 阅读全文
posted @ 2017-08-14 11:58 Posase 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 快速幂模版 3 求x^t%mod 4 时间复杂度:O(logn) 5 注:递归可能爆栈 6 原理:x^t = (x^(t/2))^2 + x^(n%2); 7 */ 8 #include 9 using namespace std; 10 long long quick_pow(long long x, long long t, long long mod) 1... 阅读全文
posted @ 2017-08-14 11:53 Posase 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 匈牙利算法模版邻接表版 3 最大匹配问题 4 时间复杂度:O (nm) 5 */ 6 #include 7 #include 8 #include 9 using namespace std; 10 const int maxn = 505; 11 vector v[maxn];//x = v[i][j]表示i可以与x匹配 12 int vis[maxn],... 阅读全文
posted @ 2017-08-14 10:58 Posase 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 1 //匈牙利算法模版题 2 #include 3 #include 4 #include 5 using namespace std; 6 const int maxn = 505; 7 vector v[maxn]; 8 int vis[maxn],match[maxn]; 9 bool dfs(int t) 10 { 11 for(int i = 0; i ... 阅读全文
posted @ 2017-08-14 10:47 Posase 阅读(209) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 匈牙利算法模版题 3 邻接表实现,邻接矩阵超时 4 最大匹配问题 5 */ 6 #include 7 #include 8 #include 9 using namespace std; 10 const int maxn = 505; 11 vector v[maxn];//x = v[i][j]表示i可以与x进行匹配 12 int vis[maxn],... 阅读全文
posted @ 2017-08-14 10:46 Posase 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 1 //裸拓扑排序,注意先输出比较小的数,使用优先队列即可 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 const int maxn = 505; 9 vector v[maxn]; 10 priority_queue q; 11 int f[maxn]... 阅读全文
posted @ 2017-08-12 13:35 Posase 阅读(196) 评论(0) 推荐(0) 编辑
摘要: 1 //线段树入门,单点修改,区间查询 2 #include 3 const int maxn = 3*1e6+5; 4 struct node 5 { 6 int l,r; 7 node *pl, *pr; 8 int s; 9 }; 10 node t[maxn]; 11 int cnt = 0; 12 int mid(node *p) 13 { ... 阅读全文
posted @ 2017-08-09 23:10 Posase 阅读(117) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 30 下一页