摘要:
一开始想到的办法,对每个序列建立二叉排序树后先根遍历看得到的序列是否相同即可。打完后忽然想到,其实既然我用数组存下了二叉树,那么直接比较树是否完全一样就可以了的,算了就这样吧,以后再打……/* * hdu3791/linux.cpp * Created on: 2011-9-6 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>using namespace std;type 阅读全文
摘要:
本来以为是求逆序数,要用归并排序,而且还得用线段树动态维护神马的,睁大眼睛一看,我滴妈呀,n才5000,直接暴力过了~~/* * hdu1394/linux.cpp * Created on: 2011-9-6 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>using namespace std;const int MAXN = 5010;int num[MAXN], r 阅读全文
摘要:
本来想找些树状数组的题做做,看到这题,不知道用树状数组的话应该如何做,就还是用线段树了。/* * hdu1754/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 = 200100;const int MAX_NODE = 400100;int 阅读全文
摘要:
题目没啥说的,赤裸裸的树状数组/* * 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 & 阅读全文
摘要:
比赛的时候,俊祥一说题目,我就马上意识到是动规,当时我正打着那道悲剧的题目,就让海峰打了,他二十来分钟吧就打完,而且一遍就过了。昨天晚上我再打这题,打了四十分钟,还WA了好几次才过。海峰真是强啊,佩服佩服!/* * hdu4001/linux.cpp * Created on: 2011-9-5 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>using namespace 阅读全文
摘要:
这题就是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 阅读全文