2013年10月4日

poj3067 Japan 树状数组求逆序对

摘要: 题目链接:http://poj.org/problem?id=3067题目就是让我们求连线后交点的个数很容易想到将左端点从小到大排序,如果左端点相同则右端点从小到大排序那么答案即为逆序对的个数用树状数组求解逆序对代码: 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define maxn 1010 8 int n,m,k; 9 int c[maxn*maxn];10 long long int ans;11 class point12 {13 public:14 i... 阅读全文

posted @ 2013-10-04 13:47 GyyZyp 阅读(136) 评论(0) 推荐(0) 编辑

hdu1556 Color the ball

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1556思路:我自己是用线段树做的后来看了kuangbin的博客,发现用树状数组更简单,而且很妙,就自己也敲了一下对于会树状数组的同学来说理解代码应该很简单,直接贴代码了啊代码: 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 const int MAXN=100010; 9 int c[MAXN];10 int n;11 12 int lowbit(int x)13 {14 ... 阅读全文

posted @ 2013-10-04 10:59 GyyZyp 阅读(160) 评论(0) 推荐(0) 编辑

hdu1556 Color the ball 简单线段树

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1556简单的线段树的应用直接贴代码了:代码: 1 #include 2 #include 3 #include 4 #include 5 #define maxn 100100 6 using names... 阅读全文

posted @ 2013-10-04 10:44 GyyZyp 阅读(175) 评论(0) 推荐(0) 编辑

导航