摘要: 链接:http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=1250这道题是求最小逆序数的题,用树状数组和线段树都可以解决,其实最耗费时间的是求原序列的逆序数的部分View Code 1 #include<stdio.h> 2 #include<string.h> 3 #define N 5005 4 int a[N]; 5 int v[N]; 6 int n; 7 int lowbit(int x) 8 { 9 return x&-x;10 }11 in 阅读全文
posted @ 2012-04-20 22:17 zhenhai 阅读(174) 评论(0) 推荐(0)
摘要: 链接:http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=1189这道题是用线段树去求区间最大值的一道题,树状数组对于这个数据量已经显得无能为力了,这也说明了树状数组和线段树分别适合的不同的题View Code 1 #include<stdio.h> 2 #include<string.h> 3 #define N 100005 4 int max(int a,int b) 5 { 6 return a>b?a:b; 7 } 8 int n; 9 stru 阅读全文
posted @ 2012-04-20 22:10 zhenhai 阅读(219) 评论(0) 推荐(0)
摘要: 链接:http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=1345这道题很明显是一道广搜题,但是搜索的时候相当的麻烦啊,八千多b的代码量,每一行都超长,也确实是自己优化的不够,不过有思路就做了也没想过那么多,只求ac其实很多时候代码长分类仔细速度反而会加快View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<queue> 5 usi 阅读全文
posted @ 2012-04-20 21:56 zhenhai 阅读(331) 评论(0) 推荐(0)