
数据结构
文章平均质量分 61
幽静
这个作者很懒,什么都没留下…
展开
-
HDU 1870
#include #include using namespace std;char str[1010];stackq;int main(){ while(cin>>str) { int sum(0); while(!q.empty()) q.pop(); int len=strlen(str); for(int i=0;i<len;i++)原创 2013-07-15 20:57:48 · 496 阅读 · 0 评论 -
hdu 1022
栈学的不是很好,发现现在又不会了,拿这个经典题目来练练手~~这里要注意的就是,i和j的细节控制。#include#includeusing namespace std;int main(){ int n,i,j,k; bool t[1010]; char a[1010],b[1010]; while(cin>>n>>a>>b) { stacktrain原创 2013-08-03 22:22:59 · 633 阅读 · 0 评论 -
二叉排序树
如果你了解二叉树的特性,和二叉排序树的排序原理的话就比较好写了,不懂的话可以 看看资料~~#include #include using namespace std;struct tree{ int date; struct tree *left; struct tree *right; };void init (tree *&t){ t=(tre原创 2013-07-28 17:39:50 · 511 阅读 · 0 评论 -
hdu 2527
哈夫曼树的初级应用~~忘记了,可以看看算法导论,里面讲的很详细~~很经典的一个处理方法,利用优先队列来处理。值得思考#include #include #include using namespace std;struct tr{ int t; friend bool operator <(tr a,tr b){ //自定义优先级 return a原创 2013-08-01 16:53:02 · 586 阅读 · 0 评论 -
并查集
并查集:是数据结构里面比较简单的一种~~稍微看看,你应该就会懂,现在我来总结一下,并查集,是一种树型的数据结构,用于处理一些不相交集合(Disjoint Sets)的合并及查询问题。如果忘了,可以看自己的收集的资料~~不多讲述.入门题:hdu 1232 1272 1274 1213 1856现在详细讲解一下,省的到时候忘记了~~hdu 1232 入门题原创 2013-07-23 22:03:28 · 447 阅读 · 0 评论 -
hdu 2544(bellman算法)
bellman 算法; 这个算法可以处理负边,如果存在含负边的回路 会返回 0;如果有负权回路,那么第 |v| 遍松弛操作仍然会成功,这时,负权回路上的顶点不会收敛,// 也就是说low[v]>low[u]+weight[u][v]; 算法的时间复杂度是:n(VE); 还可以进行优化~分析 Bellman-Ford算法,不难看出,外层循环(迭代次数)|v|-1实际上取得是上限。由原创 2013-07-22 20:08:45 · 554 阅读 · 0 评论 -
hdu 2544(spfa)
新学的spfa算法, spfa算法,就是利用更新的点来更新其他点。被更新的点,放在队列里面,当做其他点到源点的跳板,看看通过被更新的点是否可以缩短到源点的距离~~ #include #include #include const int size=99999999;using namespace std;int n,m;int map[101][1原创 2013-07-22 11:38:09 · 479 阅读 · 0 评论 -
hdu 2544 (dijkstra)
复习算法,最短路径。单源点的最短路径问题: 给定的带权有向图G和源点v,求从v到G中其余各顶点的最短路径。dijkstra算法是解决:从某个源点到其余各顶点的最短距离。其实,说明这个是不能,,,,map[x][y]=map[y][x];有向图,带有方向的~~~#include #define size 999999999using namespace std;int原创 2013-07-20 18:17:23 · 435 阅读 · 0 评论 -
HDU1233 prim算法
普利姆算法入门题。 贴个水题,入门。 这道题目没有什么要注意的~。 想类似这种算法,一般都是先有个大概的思路,然后按照你想到的思路来写,顺便优化优化,最后总结一下,以后就可以一直按照你的风格来写了。思路最重要,代码只是实现。#include #include #define size 99999999using namespace std;int map[1原创 2013-07-20 11:44:26 · 547 阅读 · 0 评论 -
poj 3692(二分匹配)
感觉说不上来,二分匹配~~#include using namespace std;const int size=202;bool vis[size];bool g[size][size];int linker[size];int vnum,unum;bool dfs( int u ){ for (int v=1;v<=vnum;v++) { if原创 2013-08-15 20:24:48 · 608 阅读 · 0 评论