题意:给定 n 个数,让你数出 a < b && c < d && a != b != c != d  && Aa < Ab && Ac > Ad. 析:首先,给的数太大了,先要进行离散化处理,然后先算出Aa < Ab 和  Ac > Ad.这可以用树状数组解决,一个正向的,一个反向,同时再求出四种数,然后减去,就好了. 代码如下: #pragma comment(linker, "/STACK:…
http://acm.split.hdu.edu.cn/showproblem.php?pid=5792 题意: 思路: lmin[i]:表示左边比第i个数小的个数. lmax[i]:表示左边比第i个数大的个数. rmin[i]:表示右边比第i个数小的个数. rmax[i]:表示右边比第i个数大的个数. 这些都是可以用树状数组计算出来的,把所有的lmin加起来就是所有(a,b)对的个数,所有lmax加起来就是所有(c,d)对的个数,两者相乘就是所有情况之和了.但是需要注意的是,在这些情况中还存在…
World is Exploding 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5792 Description Given a sequence A with length n,count how many quadruple (a,b,c,d) satisfies: a≠b≠c≠d,1≤a < b≤n,1≤c < d≤n,Aa < Ab,Ac > Ad. Input The input consists of multipl…
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=6318 Problem Description Long long ago, there was an integer sequence a.Tonyfang think this sequence is messy, so he will count the number of inversions in this sequence. Because he is angry, you will ha…
Increasing Speed Limits Time Limit: 2000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 481    Accepted Submission(s): 245 Problem Description You were driving along a highway when you got caught by the road p…
Counting Intersections Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1138    Accepted Submission(s): 347 Problem Description Given some segments which are paralleled to the coordinate axis. Y…
HDU 5862 Counting Intersections(离散化+树状数组) 题目链接http://acm.split.hdu.edu.cn/showproblem.php?pid=5862 Description Given some segments which are paralleled to the coordinate axis. You need to count the number of their intersection. The input data guarant…
Disharmony Trees Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 663    Accepted Submission(s): 307 Problem Description One day Sophia finds a very big square. There are n trees in the square. T…
6318.Swaps and Inversions 这个题就是找逆序对,然后逆序对数*min(x,y)就可以了. 官方题解:注意到逆序对=交换相邻需要交换的次数,那么输出 逆序对个数 即可. 求逆序对有4种操作,线段树 .BIT.归并排序.树状数组. 我敲了线段树.归并排序和树状数组版的. 关于这几种方法求逆序对,自行百度吧,懒了... 代码(线段树版-注意排序): //1010-找逆序对数-线段树求逆序对数 #include<iostream> #include<cstdio>…
花了近5个小时,改的乱七八糟,终于A了. 一个无限数列,1,2,3,4,...,n....,给n个数对<i,j>把数列的i,j两个元素做交换.求交换后数列的逆序对数. 很容易想到离散化+树状数组,但是发现那些没有交换的数也会产生逆序对数,但我没有算. 经明神提示, 把没有用到的数字段化成点.然后用树状数组算一下就好了. 然后我用一个数组记录每个点的长度.比如 <1,2><5,6>,1,2,3,4,5,6只有1,2,5,6用到了,那么离散化为1,2,3,4,5,f[1]=…