- 博客(16)
- 资源 (9)
- 收藏
- 关注
原创 逻辑运算
按位与:按照二进制数运算 与:按照 零false 非零true 做true&false = false 运算 // 5=(0000 0101) 2=(00000010) // 5&&2=true&&true=true=1 5&2=0000 0000=0 二进制位做运算,每一位0&1=0,0|1=1 // 逻辑运算符优先级小于 >,所以应加括号 #include using name
2016-12-04 20:21:11
259
原创 MST (Kruskal Prim)
kruskal 需要对边集排序,所以只存储边的信息 #define E 100 #define V 100 #include #include using namespace std; struct edge{ int from=-1; int to=-1; int w=0; }; edge edg[E]; int vnum, edgenum; int cnt = 0; void add(
2016-12-01 09:25:23
323
原创 ifstream中使用eof最后一个字符输出两次
eof遇到的小问题 eof函数只有在读入不成功后才会置为true 比如 输入序列abbcad,当第一次读入d后,eof仍为false;只有当下一次读入,未读进去数据后,eof置为true,此时临时变量仍为上次的值,所以会出现两个d 网上解释原文: 因为当读入d时,流对象还并不知道是否已到达文件末尾,此时eof()仍然返回false。紧接着下次循环,执行到in >> a时,流对象读入文件
2016-11-24 11:09:10
1763
原创 tarjan模糊理解
子树之间的查询就在子树范围内(栈内)查询 如果退栈,则查询的另一个节点一定不在进入的新栈中,同时两个节点间的路径一定经过退的最大栈节点 退栈同时更新祖先值(最大祖先) 经历过的最大祖先则是lca,(若经过,则一定在这个祖先的两个不同子树间,则lca=这个节点) 并查集将所有子节点用同一个最深的子节点代表,只需更新最深层,退栈则最深层更改,中间结点和最深层均有相同的ancestor;若查询在
2016-11-19 12:13:11
233
原创 String_Search_RabinKarp
Introduction To Algorithms Chap 32-2 //比较模同余时注意可能为负数等价类,将负数转为正数再比较 #include #include using namespace std; #define d 128 #define q 13 int RabinKarp(char s[], char pat[]) { long long m = strlen(pat),
2016-11-12 18:02:40
342
原创 KMP(DFA)
reference:http://algs4.cs.princeton.edu/53substring/ 构建有限状态自动机,dfa[i][j]:当模式串中j位置元素和主串元素i匹配时,下一次j的位置 // 数组指针(行指针,指向数组的指针) int (*a)[4] 指向长度为4的一维数组的指针,指针指向的元素为长度为4的一维数组 //使用数组指针可以传递二维数组,动态申请二维数组(可
2016-11-05 17:42:27
478
原创 POJ1961(KMP-Next数组)
不要想复杂 数组下标设为1开始 证明算法正确性:if + only if 充分+必要 输出格式,空行空格 特殊情况:全相等 数组作为参数传入函数 若指针传入,只传入第一个地址,不传长度,可用[]运算符,但不能strlen求长度。需单独传入长度length;或拷贝传入 char a[] 思路: p[x]表示x长度的前缀的最短循环节的长度 aabaab,p[1]=0,p[2]=1
2016-10-29 20:52:12
259
原创 算法第四版3-2Binary Search Trees With C++ Implementation
http://algs4.cs.princeton.edu/32bst/ /* Oct/6/2016 binary search tree method: 1.total() calculate the size of tree 2.size() calculate the size of subtree 3.get(key) retu
2016-10-06 19:57:18
461
原创 Binary Search Tree With C++ Implementation(OOP)
We examine a symbol-table implementation that combines the flexibility of insertion in linked lists with the efficiency of search in an ordered array. Specifically, using two links per node leads to a
2016-10-06 19:48:57
537
原创 POJ3614
//弃去废/已读数据:eg valid,全局的循环指示变量 i //" //priority_queue, greater > //include functional库中 greater模板类使优先队列从小到大排列 #include #include #include #include #include using namespace std; struct cow {
2016-09-20 22:50:08
284
原创 2009_Round_1C_C
//bribe the prisoners //http://blog.csdn.net/lizo_is_me/article/details/43735509 //compute the sub item first , then left_cost+right_cost+item(i->j)-1 =>cost of bribe i->j //dp+iterate //bribe the
2016-09-20 17:14:11
318
SafetyNets: Verifiable Execution of Deep Neural Networks on an Untrusted Cloud
2017-12-17
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人