随笔分类 -  数据结构

1
摘要:Phone ListTime Limit:1000MSMemory Limit:65536KTotal Submissions:18122Accepted:5769DescriptionGiven a list of phone numbers, determine if it is consistent in the sense that no number is the prefix of another. Let's say the phone catalogue listed these numbers:Emergency 911Alice 97 625 999Bob 91 1 阅读全文
posted @ 2013-04-18 19:39 free斩 阅读(234) 评论(0) 推荐(0)
摘要:Balanced LineupTime Limit:5000MSMemory Limit:65536KTotal Submissions:26435Accepted:12401Case Time Limit:2000MSDescriptionFor the daily milking, Farmer John'sNcows (1 ≤N≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with some of the 阅读全文
posted @ 2013-03-24 20:34 free斩 阅读(182) 评论(0) 推荐(0)
摘要:下面的源代码是修改的了时间差精确到了纳秒级别的了,但是还是感觉很有误差。无论怎么测,总是快排比归并快,即使是测试数据的数组长度在10以内。 前面一样的程序写的是时间精确到微秒级的,数组长度大概在一万以内的,就是归并排序快了,大于这个长度的快速排序比较快。综合上面的情况,数组小时,二者时间差也不会太多,所以个人认为还是快速排序比较好了,唉还是觉得归并比较简单好写,弱爆了啊。。。#include<cstdio>#include<Windows.h>#include<ctime>#include<cstdlib>#include<cstring& 阅读全文
posted @ 2013-03-21 10:51 free斩 阅读(1542) 评论(0) 推荐(0)
摘要:原题链接:http://poj.org/problem?id=3928我的链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=20357#problem/APing pongTime Limit:1000MSMemory Limit:65536KTotal Submissions:1215Accepted:452DescriptionN(3<=N<=20000) ping pong players live along a west-east street(consider the street as a line se 阅读全文
posted @ 2013-03-12 14:29 free斩 阅读(362) 评论(0) 推荐(0)
摘要:原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1022Train Problem ITime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 13410Accepted Submission(s): 4935Problem DescriptionAs the new term comes, the Ignatius Train Station is very busy nowadays. A lot of 阅读全文
posted @ 2013-03-11 21:14 free斩 阅读(218) 评论(0) 推荐(0)
摘要:原题链接:http://poj.org/problem?id=2299Ultra-QuickSortTime Limit:7000MSMemory Limit:65536KTotal Submissions:31043Accepted:11066DescriptionIn this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping two adjacent sequence eleme 阅读全文
posted @ 2013-03-08 21:56 free斩 阅读(330) 评论(0) 推荐(0)
摘要:原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1166敌兵布阵Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 23954Accepted Submission(s): 10387Problem DescriptionC国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地 阅读全文
posted @ 2013-03-08 19:54 free斩 阅读(196) 评论(0) 推荐(0)
摘要:转载来自:http://blog.csdn.net/zxycode007/article/details/6999984散列表,它是基于快速存取的角度设计的,也是一种典型的“空间换时间”的做法。顾名思义,该数据结构可以理解为一个线性表,但是其中的元素不是紧密排列的,而是可能存在空隙。散列表(Hash table,也叫哈希表),是根据关键码值(Key value)而直接进行访问的数据结构。也就是说,它通过把关键码值映射到表中一个位置来访问记录,以加快查找的速度。这个映射函数叫做散列函数,存放记录的数组叫做散列表。比如我们存储70个元素,但我们可能为这70个元素申请了100个元素的空间。70/10 阅读全文
posted @ 2013-01-03 11:38 free斩 阅读(284) 评论(0) 推荐(0)
摘要:原题链接:http://poj.org/problem?id=3041题目来源:http://acm.hust.edu.cn:8080/judge/contest/view.action?cid=16967#problem/E算法:匈牙利算法(二分匹配,求最小点覆盖数)AsteroidsTime Limit:1000MSMemory Limit:65536KTotal Submissions:10768Accepted:5823DescriptionBessie wants to navigate her spaceship through a dangerous asteroid field 阅读全文
posted @ 2012-11-23 01:13 free斩 阅读(594) 评论(0) 推荐(0)
摘要:原题链接:http://poj.org/problem?id=3041题目来源:http://acm.hust.edu.cn:8080/judge/contest/view.action?cid=16967#problem/E算法:匈牙利算法(二分匹配,求最小点覆盖数)AsteroidsTime Limit:1000MSMemory Limit:65536KTotal Submissions:10768Accepted:5823DescriptionBessie wants to navigate her spaceship through a dangerous asteroid field 阅读全文
posted @ 2012-11-23 01:13 free斩 阅读(255) 评论(0) 推荐(0)
摘要:转载来源:http://www.cnblogs.com/kuangbin/archive/2012/08/26/2657446.html无限膜拜kb神啊!!!二分图匹配(匈牙利算法)1。一个二分图中的最大匹配数等于这个图中的最小点覆盖数König定理是一个二分图中很重要的定理,它的意思是,一个二分图中的最大匹配数等于这个图中的最小点覆盖数。如果你还不知道什么是最小点覆盖,我也在这里说一下:假如选了一个点就相当于覆盖了以它为端点的所有边,你需要选择最少的点来覆盖所有的边。2。最小路径覆盖=最小路径覆盖=|G|-最大匹配数在一个N*N的有向图中,路径覆盖就是在图中找一些路经,使之覆盖了图 阅读全文
posted @ 2012-11-20 22:59 free斩 阅读(172) 评论(0) 推荐(0)
摘要:原题链接:http://poj.org/problem?id=1258周四上了节数据结构终于知道何为最小生成树,晚上回寝,遂得此题!Agri-NetTime Limit:1000MSMemory Limit:10000KTotal Submissions:29613Accepted:11750Description Farmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms in the area. He 阅读全文
posted @ 2012-11-16 02:49 free斩 阅读(211) 评论(0) 推荐(0)
摘要:原题链接:http://poj.org/problem?id=1258周四上了节数据结构终于知道何为最小生成树,晚上回寝,遂得此题!Agri-NetTime Limit:1000MSMemory Limit:10000KTotal Submissions:29613Accepted:11750DescriptionFarmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms in the area. He n 阅读全文
posted @ 2012-11-16 02:49 free斩 阅读(194) 评论(0) 推荐(0)
摘要:原题链接:http://poj.org/problem?id=3278算法:bfs+队列+STL(C++)PS:bfs入门题目,好高兴啊,终于会用bfs了。Catch That CowTime Limit:2000MSMemory Limit:65536KTotal Submissions:32679Accepted:10060DescriptionFarmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a pointN(0 阅读全文
posted @ 2012-11-10 00:52 free斩 阅读(213) 评论(0) 推荐(0)
摘要:原题链接:http://poj.org/problem?id=3278算法:bfs+队列+STL(C++)PS:bfs入门题目,好高兴啊,终于会用bfs了。Catch That CowTime Limit:2000MSMemory Limit:65536KTotal Submissions:32679Accepted:10060DescriptionFarmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a pointN(0 阅读全文
posted @ 2012-11-10 00:52 free斩 阅读(217) 评论(0) 推荐(0)
摘要:仿写的一个简单而傻逼的程序,线性表入门。。。希望把这几个程序弄完了,能搞出个简单的系统来O(∩_∩)O/******************************************* 实验内容二: 1.用C语言定义线性表的链式存储结构(单链表)类型; 2.编制链式存储结构下的线性表的输入程序; 3.编制链式存储结构下线性表的插入算法程序或删除算法程序; 4.编制链式存储结构下的线性表的输出程序; 5.在链式存储结构下编制主程序:输入一个具体的线性表, 然后随意地在表中的任意位置执行插入一个元素 或删除一个元素的操作,最后输出线性表的操作结果。 **********... 阅读全文
posted @ 2012-09-23 16:48 free斩 阅读(236) 评论(0) 推荐(0)
摘要:原创链接:http://blog.163.com/zhaohai_1988/blog/static/209510085201263011135062/感谢作者,感谢kb神的推荐~~~~~~问题描述RMQ问题是求给定区间中的最值问题。对于长度为n的数列A,回答若干查询RMQ(A, i, j)。返回数组A中下标在[i,j]里的最小值的下标。比如数列 5,8,1,3,6,4,9,5,7 那么RMQ(2,4) = 3, RMQ(6,9) = 6.解决问题最简单的解法时间复杂度是O(n),就是对于每一个查询遍历一遍数组。但是当n非常大的时候,并且查询次数非常多的时候,这个解决方案就不是那么高效了。使.. 阅读全文
posted @ 2012-08-22 20:50 free斩 阅读(249) 评论(0) 推荐(0)
摘要:唉,我的入门“hash”题目链接:http://poj.org/problem?id=1840CSUST 2012年暑假8月组队后第十二次个人赛:http://acm.hust.edu.cn:8080/judge/contest/view.action?cid=11900#problem/BEqsTime Limit:5000MSMemory Limit:65536KTotal Submissions:8973Accepted:4446DescriptionConsider equations having the following form:a1x13+ a2x23+ a3x33+ a4x 阅读全文
posted @ 2012-08-22 16:35 free斩 阅读(186) 评论(0) 推荐(0)
摘要:题目链接: http://poj.org/problem?id=31252012年8月7日,暑假组队后个人训练赛第一场Printer QueueTime Limit:1000MSMemory Limit:65536KTotal Submissions:3082Accepted:1655DescriptionThe only printer in the computer science students' union is experiencing an extremely heavy workload. Sometimes there are a hundred jobs in th 阅读全文
posted @ 2012-08-14 16:47 free斩 阅读(549) 评论(0) 推荐(0)
摘要:经典的模拟队列题目题目链接: http://poj.org/problem?id=31252012年8月7日,暑假组队后个人训练赛第一场Printer QueueTime Limit:1000MSMemory Limit:65536KTotal Submissions:3082Accepted:1655DescriptionThe only printer in the computer science students' union is experiencing an extremely heavy workload. Sometimes there are a hundred j 阅读全文
posted @ 2012-08-14 16:47 free斩 阅读(208) 评论(0) 推荐(0)

1