- 博客(10)
- 收藏
- 关注
原创 求最长公共子串的长度代码
#include<iostream>#include<string>#include<vector>using namespace std;string str1, str2;typedef long long ll;const ll maxn = 1000;const ll MOD = 1000000007;const ll P = 100...
2018-08-23 16:26:37
207
原创 AOE网上的关键路径长度求解代码(输出相关数组以及关键路径)
题目图如下所示: 代码:#include<iostream>#include<algorithm>#include<vector>#include<queue>#include<stack>#define maxn 1000using namespace std;struct node{ int...
2018-08-22 15:59:59
1002
原创 dijkstra算法求单源最短路径长度并输出最短路径 代码
代码/*6 8 00 1 10 3 40 4 41 3 22 5 13 2 23 4 34 5 3*/#include<iostream>#include<algorithm>using namespace std;const int maxv = 1000;const int INF = 1000000000;int n, m,...
2018-08-18 14:39:52
2419
原创 求连通块的个数代码 dfs/并查集
dfs代码://求连通块的个数#include<iostream>#include<cstdio>#include<vector>#define maxn 1000using namespace std;vector<int> G[maxn];bool vis[maxn] = {false};int m, n;void ...
2018-08-17 19:01:10
676
原创 动态规划求解数塔问题 代码
/*558 312 7 164 10 11 69 5 3 9 4*/#include<iostream>#define maxn 1000using namespace std;int dp[maxn][maxn]; //dp[i][j]表示第i行第j列出发到达最底层的所有路径中的最大和int maze[maxn][maxn]; //这里若是ma...
2018-08-14 19:35:04
1194
原创 PAT - A1034 - Head of a Gang代码
#include<iostream>#include<string>#include<map>using namespace std;const int maxn = 2010;const int INF = 1000000000;map<int, string> intToString;map<string, int>...
2018-08-14 19:09:26
121
原创 用优先级队列来实现树的带权路径最小值的求解
反复选择两个最小的元素合并, 直到只剩下一个元素代码:#include<iostream>#include<queue>using namespace std;priority_queue<int, vector<int>, greater<int>> q;int main(){ int n, temp;...
2018-08-13 15:49:56
245
原创 哈夫曼编码与解码代码
#include<stdio.h>#include<stdlib.h>#include<string.h>#include<queue>using namespace std;typedef struct node{ char ch; //存储该节点表示的字符,只有叶子节点用的到 i...
2018-08-12 20:58:14
620
原创 堆的定义和基本操作代码
//85 55 82 57 68 92 99 98 66 56#include<iostream>#define maxn 1000using namespace std;int heap[maxn];int n = 10;//big - topvoid downjust(int low, int high){ int i = low, j = 2*i;...
2018-08-12 20:12:23
142
原创 平衡二叉树代码
先将平衡二叉树代码存在这里,具体的原理解释,以后有时间再补充代码:#include<iostream>#define maxn 1000using namespace std;struct node{ int data; int height; node *lchild, *rchild;};int key[maxn];int n;...
2018-08-11 16:47:53
281
空空如也
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人 TA的粉丝