自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

林伏案的博客

伏案的学习笔记

  • 博客(12)
  • 收藏
  • 关注

原创 Database uva1592

//1:getline的用法//2:map的巧妙运用//3:只枚举c1 c2,然后从上到下扫描各行,将c1 c2作为二元组,碰到新的行r就把其作为内容存放到map中,如果map中已经//存在,即可求出所要的答案//4:二元组有关#include #include #include #include #include #include #include using name

2016-03-29 09:09:41 287

原创 Alignment of Code id:1593

//1:关键是求出各列单词最长的长度,然后将各行单词保存在vector数组里面。即可根据于此格式化输出,//2:注意最后一列没有输出空格//3:注意此题中有关sstream的用法#include #include #include #include #include #include //#define ONLINEusing namespace std;const i

2016-03-29 08:58:52 367

原创 Team Queue. id:540

Queues and Priority Queues are data structures which are known to most computer scientists. TheTeam Queue, however, is not so well known, though it occurs often in everyday life. At lunch time the q

2016-03-26 16:21:51 1022

原创 The SetStack Computer id:12096

//题中要求的是集合的集合,所以用一个map将集合映射成一个int 类型的ID, 这样就便于编写代码//当然题中还需要用到栈,包含在头文件stack中//用vector来存储集合,stack来存储集合的id,而map主要用来将set转变成id#include #include #include #include #include #include #include #inclu

2016-03-26 11:26:51 256

原创 Ananagrams id:156

Most crossword puzzle fans are used to anagrams--groups of words with the same letters in different orders--for example OPTS, SPOT, STOP, POTS and POST. Some words however do not have this attribute,

2016-03-26 11:09:11 233

原创 Andy's First Divtionary id:10815

分析:题目本身很简单,关键是利用STL中的set,即可轻松解决该问题。set即集合,其中不允许有重复的元素存在常见的set操作如下:(set s)插入元素:s.insert(15)删除元素:s.erase(15)或者s.clear()查找元素:s.find(15)这三个只是最基本的操作,注意查找元素时返回的是迭代器的位置,如果集合中没有该元素,则返回集合最后一位后面

2016-03-24 20:09:39 296

原创 The Block Problem, id:101

分析:可以用C++的STL中的vector来表示每个木块堆。然后用一个数组来存储vector。具体代码如下:#include #include #include #include using namespace std;vector block_vec[25];int block_find(int a, int & h, int n) { int pile ;

2016-03-24 12:30:39 199

原创 Cube painting id: 253

OutputThe output is a file of boolean. For each line of input, output contains TRUE if the second half can be obtained from the first half by rotation as describes above,FALSE otherwise. Sampl

2016-03-22 08:56:03 244

原创 squares id:201

A children’s board game consists of a square array of dots that contains lines connecting some of the pairs of adjacent dots. One part of the game requires that the players count the number of squares

2016-03-21 13:02:54 258

原创 1.3:Union-Find算法-----quick-union算法的改进(加权的quick-union算法)

对于一般情况而言,使用quick-union算法就已经足够满足需求。但是仍然存在着一种情况使得quick-union算法得到的最快的情况。quick-union的最坏情况:当我们要对两个节点进行union操作时,等价于对两个节点所在的分量进行union操作(对于分量,用“树”这个词来表示更为妥当。因为一个节点总是指向它的“父节点”)。此时union(p, q)即将前者(p)的根节点指向后者

2016-03-18 09:15:14 2289

原创 1.3:Union-Find算法-----quick-union算法

1:quick-find算法的不足当我们利用quick-find来解决动态联通性的问题时,至少要调用N-1次union()。而一次union()算法至少需要访问数组N+3次。所以我们访问数组的总次数为(N-1)(N+3)次,为平方级别。用来解决大型问题绝对不可能。因此,考虑对union()算法的优化。2:quick-union算法的数据结构quick-union算法的数据结构与quic

2016-03-15 20:42:06 2215

原创 1.3:Union-Find算法-----quick-find算法

接下来实现Union-Find算法的第一种实现方式:quick-find算法首先是数据结构:我们用一个长度为N的整型数组id[] 来表示图中各个点。一开始初始化id[x] = x,id[x]中x代表点的标号,如果其中两点p, q相连通,则id[p] = id[q]。find()方法:只需检查id[p]和id[q]是否相等。union(p, q)方法:遍历整个数组,将数组里所

2016-03-04 21:54:59 883

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除