Ping pong Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2611    Accepted Submission(s): 973 Problem Description N(3<=N<=20000) ping pong players live along a west-east street(consider the str…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2492 Ping pong Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4961    Accepted Submission(s): 1811 Problem Description N(3<=N<=20000) ping pong p…
                                                                      Ping pong Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3139   Accepted: 1157 Description N(3<=N<=20000) ping pong players live along a west-east street(consider th…
N (3N20000)ping pong players live along a west-east street(consider the street as a line segment). Each player has a unique skill rank. To improve their skill rank, they often compete with each other. If two players want to compete, they must choose…
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=13895 题意:一条街上住有n个乒乓选手,每个人都有一个技能值,现在每场比赛需要3个人,两个选手,一个裁判:裁判须住在他们之间,且其技能值必须在两选手之间,求一共能组织多少种比赛. 注意到技能值的范围(1 ≤ ai ≤ 100000),所以我们可以树状数组(O(nlogn))处理得到一个ll数组,ll[x]表示住在x左边的并且技能值小于x的技能值的人数.类似逆着处理…
题意:每个人都有一个独特的排名(数字大小)与独特的位置(从前往后一条线上),求满足排名在两者之间并且位置也在两者之间的三元组的个数 思路:单去枚举哪些数字在两者之间只能用O(n^3)时间太高,但是可以转变思想.我们可以转化为对于每个数字a,求出后面比当前数a大的每个数b,再求出数b后面比当前数b大的数字c的个数,接着对于每个a对应的每个b中c的个数之和就是一半结果,当然还有比他小的是另一半求法类似.其实就是树状数组求逆序数第一次求出每个b,接着再用b求出c,这样求两次就好 #include<se…
主题链接: PKU:http://poj.org/problem?id=3928 HDU:http://acm.hdu.edu.cn/showproblem.php?pid=2492 Description N(3<=N<=20000) ping pong players live along a west-east street(consider the street as a line segment). Each player has a unique skill rank. To im…
题意:从左到右给你n个不同的数值,让你找出三个数值满足中间的数值在两边的数值之间的个数. 析:题意还是比较好理解的,关键是怎么求数量,首先我们分解一下只有两种情况,一个是左边<中间<右边,另一种是左边>中间>右边(因为数值都不相同嘛). 我们考虑第i个数值在中间的情况.假设a1到ai-1中有ci个比ai小的,那么就有(i-1)-ci个比ai大的(因为不包括第i个数).同理,假设有ai+1到an中有di个比ai小,那么有(n-i)-di个比ai大,那么一共就有ci(n-i-di) +…
https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2330 参考资料:<算法入门经典训练指南>刘汝佳 P197 这本书上面写的题目大意.解题思路都写出来了. 在这我贴上自己的 AC代码: #include<stdio.h> #include<string.h> #define PEOPLE 2…
题目大意:有n个数排成一列,问从中能找出几个三元组(ai,aj,ak)满足i<j<k并且这三个数严格单调. 题目分析:枚举中间的数字aj,如果aj前面有c(j)个数a(j)小,后面有d(j)个数比a(j)小,那么aj为中间数时,共有c(j)*(n-j-d(j))+d(j)*(j-1-c(j)).定义x(i)表示 i 出现过几次,当枚举到aj 时,只需统计sum(x(1)~x(a(j)-1)便得c(j),d(j)求法类似. 代码如下: # include<iostream> # in…