- 博客(11)
- 资源 (2)
- 收藏
- 关注
原创 随机化快速排序
#include #include #include #include #include using namespace std; #define RANDOMIZED_PIVOT void quick_sort(int arr[],int left,int right) { if (left<right) { int i=left, j=right;
2014-04-02 22:24:42 480
原创 win8下sshd服务的安装
在安装Hadoop时需要安装sshd服务,此服务安装并非像书上所言那么容易,还是把我的安装经历分享出来吧。 【之前的尝试】 我是在win8 + cygwin64环境下安装sshd服务的,之前每一次安装在创建账户的环节总是会出错,后来才知道是管理员权限的问题,于是乎在cygwin图标上右键点击“以管理员模式运行”,遂解决问题。 【离成功接近的第一次尝试】 $ ssh-host-config
2014-01-15 18:04:49 2023 1
原创 POJ3264-Balanced Lineup RMQ
【题目来源】http://poj.org/problem?id=2418 【题目思路】RMQ问题,我用的ST表来求区间最大和最小值 【ST表代码】 #include #include #include #include #include #include #include #define MAXN 100000 using namespace std; i
2013-09-23 20:39:48 512
原创 POJ1273-Drainage Ditches
#include #include #include #include #include #include #include #include //=================== #include #include #include #define MAXN 300 #define MIN(A,B) ((A<B)?(A):(B)) #define INF 0x1F
2013-09-14 22:35:43 471
原创 POJ1833-排列
【题目来源】http://poj.org/problem?id=1287 【题目思路】生成下一个排列 【题目感想】 Algorithm for generating the next permutation from given one. Given n elements in the permutation a1, a2, a3, …, an . Step 1. Search
2013-09-01 16:27:28 471
原创 POJ1657-Distance on Chessboard
【题目来源】http://poj.org/problem?id=1657 【水题】 #include #include using namespace std; int main() { int t; cin>>t; char x1,x2; int y1,y2; while (t--) { cin>>x1>>y1>>x2>>y2; int dx=abs(x1-x2)
2013-09-01 12:16:55 494
原创 POJ1287-Networking
【题目来源】http://poj.org/problem?id=12587 【题目思路】最小生成树,本题估计不用优化也能过,我还是用堆优化了prim,仅仅作为练手。 【题目感想】 #define INF (~0u)>>2可以用来定义无穷大 堆中元素保存的是节点的编号 【代码】 #include #include #include #define MAXN 100 #def
2013-08-30 19:58:05 661
原创 POJ1251-Jungle Roads
【题目来源】http://poj.org/problem?id=1251 【题目思路】最小生成树,用邻接矩阵和朴素的prim算法都过了,可见水之深切。 【题目感想】在读入时候为了提高速度用了std::ios::sync_with_stdio(false); 来取消cin和stdin的同步特性,这样cin和scanf速度几乎相同,但是就不能混用scanf和cin了。 介绍此点的文章详见https
2013-08-29 21:34:27 651
原创 POJ2418-Hardwood Species
【题目来源】http://poj.org/problem?id=2418 【题目思路】二叉搜索树 【解题感想】题目就是让你统计各种树木占总量的比例,但数据量非常大。本来想用STL的map的,但是听说会超时,还是没有用,自己写了一个BST。这是我第一次写BST,开始时候完全照pascal语言写的模板抄,但是实际实现时候在指针传递的时候发现一些问题,于是放弃了用指针传来传去的函数模板。不过我还
2013-08-04 20:52:57 704
原创 POJ1088-滑雪
【题目来源】http://poj.org/problem?id=1088 【题目思路】深度优先搜索+记忆化 【解题感想】 本题为经典的记忆化入门题,a数组保存各位置高度,f数组保存各位置可达的最长路径长度。特别注意题目的结果需要+1,因为在dfs的边界处,该节点并没有计入路径的长度。我本来想把保存各位置可达的最长路径初始化为1的,但是这样会出毛病,因为f数组初始化为0,并且
2013-07-29 16:04:47 447
原创 ZOJ1004-Anagrams by Stack
[题目来源]http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4 [题目思路]回溯法 [解题感想]在使用回溯法的过程中,用STL中的vector来记录答案,可以直接使用push_back()来保存解,这样避免了使用数组时考虑数组下标的麻烦,使用stack也有同样功效。 题中有几点需要注意,首先是结果需要按字典序排
2013-07-27 13:50:25 878
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人