我们知道,增广路EK算法的时间负责度是O(n*m^2),找最短增广路的时间复杂度是O(m*n),所以时间复杂度主要是在找增广路上。
这里介绍另一种Dinci算法,用BFS构造层次图,然后用DFS增广。
模板
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#d...
分类:
其他好文 时间:
2014-07-30 14:49:03
阅读次数:
364
记忆化搜索。。
对每个点能走的最远进行记录,如果走过,直接返回上一层。。
最后遍历找出最大值。。
#include
#include
#include
#include
using namespace std;
struct node{
int q,w;
}s[104][105];
int a,b;
int yy[105][105];
int map[4][2]={1,0,-1,0,0,...
分类:
其他好文 时间:
2014-07-30 12:23:03
阅读次数:
179
枚举所有相邻城市,作为起点,多次spfa,然后每次在想去的城市中找出spfa后的距离起点最短的花费时间
#include
#include
#include
using namespace std;
#define MAX 1005
#define INF 1<<30
int T,S,D;
struct Edge{
int to,time,next;
}edge[MAX*2...
分类:
其他好文 时间:
2014-07-30 12:19:03
阅读次数:
215
引言首先看一个C语言下结构体的小程序。#includestruct StudentInfo { char i; int j;};void main() { printf("%d\n",sizeof(struct StudentInfo)); }输出结果:8不解,以为是...
归并排序的链表法#includeusing namespace std;struct ListNode{ int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution{public:...
分类:
其他好文 时间:
2014-07-30 07:40:23
阅读次数:
174
树的解释
树是ADT里面很经典的数据结构了,应用太多了,相对于链表的线性访问时间,O(n)。树的大部分操作的平均运行时间都是为O(logN)。
- 树的概念
树有几种方式定义,一种是递归,若树不为空,则一棵树是由根(root)的节点r和0个或者多个非空树组成。N个节点的树,有N-1个边。没有儿子的节点称为叶子(leaf). 对于任意节点N(i),它的深度为从根节点到N(i)的唯一路径长度。如...
分类:
其他好文 时间:
2014-07-30 01:08:02
阅读次数:
253
教训:使用邻接表的时候一定要把邻接表的结构组定义的足够大,不能仅仅等于节点的个数,因为线段的数量往往远超过节点的数量。这个题目是拓扑排序练习,提高下理解。 1 #include 2 using namespace std; 3 struct TOPO 4 { 5 int from,to,ne...
分类:
其他好文 时间:
2014-07-30 00:49:12
阅读次数:
249
本篇先介绍 下Innodb表空间,文件相关的内存数据结构。1. 数据结构Innodb的tablespace和文件的关系,是一对多的关系,先来看三个结构体1. fil_system_struct: 表示Innodb的表空间内存cache,innodb一共包括两类tablespace,即 #defi.....
分类:
数据库 时间:
2014-07-30 00:45:12
阅读次数:
260
1.和软中断相关的数据结构:softing_vec数组(kernel/softirq.c)1 static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;NR_SOFTIRQS值为10,说明内核支持...
分类:
其他好文 时间:
2014-07-30 00:31:52
阅读次数:
568
费用流即最小费用最大流先贴上粉书上的模板:struct Edge{ int from,to,cap,flow,cost; Edge(int u,int v,int c,int f,int w): from(u),to(v),cap(c),flow(f),co...
分类:
其他好文 时间:
2014-07-30 00:27:02
阅读次数:
289