![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构与算法实习
求你好好学习
帅气
展开
-
并查集模板 数据结构与算法实习
#include <iostream> #include<vector> using namespace std; #define MAXL 10000 int parent[MAXL]; int getroot(int a) { if (parent[a] == a) { return a; } else { parent[a] = getroot(pare...原创 2019-12-28 17:22:08 · 107 阅读 · 0 评论 -
Bellman-Ford算法
解决含负权边的带权有向图的单源最短路径问题,也可以判断其中是否有负权值回路 不能处理带负权边的无向图(因可以来回走一条负权边) , 要求图中不能包含权值总和为负值回路(负权值回路) 示例: (1) 3 3 1 1 2 2 1 3 4 2 3 1 3 1 3 (2) 3 2 1 1 2 3 2 3 4 3 1 8 #include <iostream> #include<vecto...原创 2019-12-28 00:48:59 · 195 阅读 · 0 评论 -
有向图强连通分支的Tarjan算法 数据结构与算法实习
该说的都在代码里了,老师给的模板不符合本菜鸡的要求啊只能手动扩充了,用的是邻接矩阵存储图,可以换成邻接表啥的可能快点 #include <iostream> #include<stack> #include<string.h> using namespace std; #define MAXL 1000 /* 例子: 6 7 0 1 0 4 0 5 1 2 2 ...原创 2019-12-27 00:58:33 · 119 阅读 · 0 评论 -
Trie图模板 数据结构与算法实习
#include <iostream> #include<algorithm> #include<queue> using namespace std; #define MAXL 50000 #define LETTERS 26 int node_count; /*危险节点的概念: 1) 终止节点是危险节点 2) 如果一个节点的前缀指针指向危险节点,那么它也是...原创 2019-12-25 15:52:28 · 114 阅读 · 0 评论 -
Difficult Lost Cows 线段树
#include <iostream> using namespace std; #define MAXL 1000000 int Order[MAXL + 10], n; struct node { int l, r; int len; node* left; node* right; }; node C[MAXL * 2 + 100]; int c = 0; int Re...原创 2019-12-24 17:53:29 · 152 阅读 · 0 评论 -
不好做的最长上升子序列 树状数组习题
不好做的最长上升子序列 (数据结构与算法实习期末复习) 题目链接:http://dapractise.openjudge.cn/2019hwall/005/ 这道题因为限制了O(nlogn)所以不能简单的用动态规划来做,树状数组的做法虽然网上也有很多,但是注释或者解释都太少了,本菜鸟决定自己写一个清楚点的解释版本。 在这里插入代码片 ...原创 2019-12-23 20:17:10 · 222 阅读 · 0 评论 -
Apple Tree 树状数组习题
Apple Tree Poj (数据结构与算法期末复习) 题目链接:http://dapractise.openjudge.cn/2019hwall/003/ 树状数组,单点更新,区间求和 代码是看了这位大佬的,https://www.cnblogs.com/gj-Acit/p/3236843.html 所以几乎就是把他的代码理解了一遍,然后自己再用C++写了一遍改动了一丢丢再加了点注释应该...原创 2019-12-23 16:32:55 · 253 阅读 · 0 评论