摘要: 题目没啥说的,赤裸裸的树状数组/* * hdu1166/win.cpp * Created on: 2011-9-6 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>using namespace std;const int MAXN = 50100;int N, M;int array[MAXN];inline int lowbit(int x) { return x & 阅读全文
posted @ 2011-09-06 10:54 moonbay 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 比赛的时候,俊祥一说题目,我就马上意识到是动规,当时我正打着那道悲剧的题目,就让海峰打了,他二十来分钟吧就打完,而且一遍就过了。昨天晚上我再打这题,打了四十分钟,还WA了好几次才过。海峰真是强啊,佩服佩服!/* * hdu4001/linux.cpp * Created on: 2011-9-5 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>using namespace 阅读全文
posted @ 2011-09-06 09:28 moonbay 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 这题就是Floyd变形,只要理解了Floyd算法,题目还是不难的。不过我还是WA了一次,原理是在运行Floyd的时候,误加了两个判断,以为当i,j未被标记的时候,i到j的路径不必更新,其实这是错的,去掉以后就过了。/* * hdu3631/win.cpp * Created on: 2011-9-6 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>using namespa 阅读全文
posted @ 2011-09-06 09:23 moonbay 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 这题题目不难,代码也不长,花了一个小时,主要是之前没用过结构体的构造函数,比较函数与优先队列/* * hdu1242/linux.cpp * Created on: 2011-9-4 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>#include <queue>using namespace std;typedef struct Node { int x, y 阅读全文
posted @ 2011-09-04 22:39 moonbay 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 题目简单,直接贴代码/* * hdu1241/linux.cpp * Created on: 2011-9-4 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>using namespace std;const int MAXN = 105;char map[MAXN][MAXN];int types[MAXN][MAXN], curtype;const int move[ 阅读全文
posted @ 2011-09-04 21:28 moonbay 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 直接二分查找答案即可,我的判断函数没有像大牛们那样优化,但是过是没问题的~/* * hdu4004/linux.cpp * Created on: 2011-9-4 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>using namespace std;const int MAXN = 500010;int stone[MAXN], L, N, M;int step(int 阅读全文
posted @ 2011-09-04 19:49 moonbay 阅读(435) 评论(0) 推荐(0) 编辑
摘要: 这题本来可以不用线段树做的,因为数据比较弱,直接离散化即可。但为了练习线段树,还是用线段树打了,可是却WA了一整天!调了四个小时以后仍没找出错误,让竹子帮我测试,测出了一处错误,又去北大讨论版找了些数据测,终于过了。我的代码如下,第一次写这类题目,写得比较乱,以后再改进吧。/* * hdu1542/linux.cpp * Created on: 2011-9-1 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#includ 阅读全文
posted @ 2011-09-02 22:05 moonbay 阅读(274) 评论(0) 推荐(0) 编辑
摘要: 本来想用线段树做的,仔细看题发现题目数据太弱了,直接用一个数组标记平面上每一个单位方格即可,水题~/* * hdu1264/linux.cpp * Created on: 2011-9-1 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>using namespace std;const int MAX_COR = 105;bool map[MAX_COR][MAX_COR 阅读全文
posted @ 2011-09-01 14:50 moonbay 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 直接枚举Ai, Bj, Ck的复杂度为L×M×N,过不了。先把所有Ai, Bj的和存起来并排序,然后枚举Ck,二分查找Ai, Bj的和,复杂度为L×M×log(L×M)。/* * hdu2141/linux.cpp * Created on: 2011-9-1 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>using na 阅读全文
posted @ 2011-09-01 13:15 moonbay 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 题目没啥说的,赤裸裸的匈牙利算法,可恶的是题目输入描述不清,还以为每组输入后都有一个0呢,害得我RE了一次,鄙视一下出题者,哈哈!/* * hdu2063/linux.cpp * Created on: 2011-9-1 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>usingnamespace std;constint MAXN =555;int n, m, match 阅读全文
posted @ 2011-09-01 09:51 moonbay 阅读(132) 评论(0) 推荐(0) 编辑