Ping pong                                                   Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)   链接:pid=2492">hdu 2492 Problem Description N(3<=N<=20000) ping pong players live along a west-ea…
主题链接: 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…
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…
Triple Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 388    Accepted Submission(s): 148 Problem Description Given the finite multi-set A of n pairs of integers, an another finite multi-set B …
题意:给你一串数且每个数都不同,问你(x,y,z)出现 x<z<y 的总次数 首先我们直接想的话不能使用O(n*log2 n)解决,所以可以正难则反 可以求得x<(y,z)的值,减去的x<y<z就好了 x<(y,z):每一位后面比此大的个数V,使用V*(V-1)/2求 x<y<z:前面POJ 3928就是求这个(使用两次树状数组) #include<set> #include<map> #include<queue> #i…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1394 Minimum Inversion Number                        Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)                                            Total Submission(s): 10…
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 guarantee that no two se…
ZYB's Game Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5592 Description ZYB has a premutation P,but he only remeber the reverse log of each prefix of the premutation,now he ask you to restore the premutation…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1394 题目让你求一个数组,这个数组可以不断把最前面的元素移到最后,让你求其中某个数组中的逆序对最小是多少. 一开始就求原来初始数组的逆序对,树状数组求或者归并方法求(可以看<挑战程序设计>P178),然后根据最前面的元素大小递推一下每次移到最后得到的逆序数,取最小值. #include <iostream> #include <cstdio> #include <cs…
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5877 [题目大意] 给出一棵带权有根树,询问有几对存在祖先关系的点对满足权值相乘小于等于k. [题解] 我们沿根节点开始将点权加入权值树状数组,每次处理完子树就回溯,保证每个节点的答案统计是在只包括祖先节点的树状数组中进行. [代码] #include <cstdio> #include <algorithm> #include <vector> #include &l…
A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 97217   Accepted: 30358 Case Time Limit: 2000MS Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of…
Sort it Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4672    Accepted Submission(s): 3244 Problem Description You want to processe a sequence of n distinct integers by swapping two adjacent s…
题目链接 Problem Description Given the finite multi-set A of n pairs of integers, an another finite multi-set B of m triples of integers, we define the product of A and B as a multi-set C=A∗B={⟨a,c,d⟩∣⟨a,b⟩∈A, ⟨c,d,e⟩∈B and b=e} For each ⟨a,b,c⟩∈C, its B…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6447 Problem DescriptionYJJ is a salesman who has traveled through western country. YJJ is always on journey. Either is he at the destination, or on the way to destination.One day, he is going to travel…
http://acm.hdu.edu.cn/showproblem.php?pid=5877 题意: 给出一棵树,每个顶点都有权值,现在要你找出满足要求的点对(u,v)数,u是v的祖先并且a[u]*a[v]<=k. 思路: 转化一下,a[v]<=k/a[u],k/a[u]的最大值也就是k/a[v],也就是寻找<=k/a[v]的个数,到这儿,是不是很像树状数组? 我们只需要从根开始dfs,插入到树状数组中,并且查询即可.注意这道题目需要离散化一下. #include <iostrea…
题目链接:[http://acm.split.hdu.edu.cn/showproblem.php?pid=5517] 题意:定义multi_set A<a , d>,B<c , d , e>,C<x , y , z>,给出 A , B ,定义 C = A * B = ={⟨a,c,d⟩∣⟨a,b⟩∈A, ⟨c,d,e⟩∈B and b=e} .求出C之后,求C中一个元素t[i]<a , b , c>是否存在一个元素tmp<x , y , z>使…
题目链接:id=3468">http://poj.org/problem?id=3468 题目大意:给出一组数组v[i],有两种操作,一种给出两个数a,b.要求输出v[a]到v[b]之间的和.还有一种给出三个数a,b,c,让v[a]到v[b]之间的数全都加上c. 全然是树状数组可以实现的功能,可是假设就这样单纯的套用模板,做另外一种操作是更新每一个值,这种操作就有可能超时. 换一种思路,既然另外一种操作是给某区间上的全部数加上同样的值,那么应该是可以简化的才对. 如果数组sum[i]为原数…
题目链接: http://acm.split.hdu.edu.cn/showproblem.php?pid=5862 Counting Intersections Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) 问题描述 Given some segments which are paralleled to the coordinate axis. You need to coun…
http://acm.hdu.edu.cn/listproblem.php?vol=49 给定一颗树,然后对于每一个节点,找到它的任何一个祖先u,如果num[u] * num[v] <= k.则贡献加1 思路:主要的麻烦就是动态修改前缀和了.因为对于每个数字val.则找它祖先的话, <= k / val的数字,都是合法的.所以问题转化成求你现在dfs中保存的数字,有多少个是  <= k / val的,树状数组即可. 问题就是,数字太大了,这不适合树状数组,那么我们把每个数字离散成他们的下…
Housewife Wind Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 11419   Accepted: 3140 Description After their royal wedding, Jiajia and Wind hid away in XX Village, to enjoy their ordinary happy life. People in XX Village lived in beauti…
http://acm.hdu.edu.cn/showproblem.php?pid=1166 题目大意: 给定n个数的区间N<=50000,还有Q个询问(Q<=40000)求区间和. 每个询问可能增加点k     x的值或者减少x. 思路: 原题描述很有爱啊~ 树状数组好久没写了~ 依旧很熟练,WA了两三次,第一次因为没有输出case,.......第二次发现多组数据没有初始化.T^T ~像这种单点修改求区间和的还是用树状数组比较简单~ 树状数组: #include<cstdio>…
先补充从n个数中求第k小数的理论知识........ 睡觉去~ ------------------------------------------又要睡觉的分割线------------------------------------------ HDU:http://acm.hdu.edu.cn/showproblem.php?pid=2852 题目大意,给定三种操作: 0  a代表插入一个数 1  a代表删除掉a这个数 2 a k 查询比a大的第k个数 跟着大神走~树状数组+二分 树状数组…
题目链接: http://poj.org/problem?id=3468 题目是对一个数组,支持两种操作 操作C:对下标从a到b的每个元素,值增加c: 操作Q:对求下标从a到b的元素值之和. 这道题也可以用线段树解,本文不做描述,下面分析如何用树状数组来解决这道题. /*先把问题简化一点,因为 结果=初值+增量,所以,我们可以只对增量进行分析.然后,这种题有一个特点,就是如果对一般的一个操作C与操作查询前缀和的组合符合条件,那么无论进行多少次任意操作结果都是正确的.故 假设,先进行一次参数分别为…
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=3584 Cube Problem Description Given an N*N*N cube A, whose elements are either 0 or 1. A[i, j, k] means the number in the i-th row , j-th column and k-th layer. Initially we have A[i, j, k] = 0 (1 <= i, …
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5792 World is Exploding Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others) 问题描述 输入 The input consists of multiple test cases. Each test case begin with an integer n in a sin…
题目链接:http://poj.org/problem?id=3468 题意:给出一个数列,两种操作:(1)将区间[L,R]的数字统一加上某个值:(2)查询区间[L,R]的数字之和. 思路:数列A,那么区间[1,x]的和为: struct BIT { i64 a[N]; void clear() { clr(a,0); } void add(int x,int t) { while(x<N) a[x]+=t,x+=x&-x; } i64 get(int x) { i64 ans=0; whi…
题目意思很明白: 给你一棵有n个节点的树,对树有下列操作: I c1 c2 k 意思是把从c1节点到c2节点路径上的点权值加上k D c1 c2 k 意思是把从c1节点到c2节点路径上的点权值减去k Q a 查询节点a的权值 数据大小 节点个数 n[1,50000], 操作次数 op[0,30000]; 不会树链剖分 故只有想其他的方法. 这道题有点类似今年上海网络赛的1003 ,不过那题我没做: 算法思路: 以节点1 为根,求出节点i 的 dfs序列 tim[i][2]; 其中tim[i][0…
HDU 4777 Rabbit Kingdom 题目链接 题意:给定一些序列.每次询问一个区间,求出这个区间和其它数字都互质的数的个数 #include <cstdio> #include <cstring> #include <algorithm> #include <vector> using namespace std; const int INF = 0x3f3f3f3f; typedef long long ll; const ll N = 200…
The inversion number of a given number sequence a1, a2, ..., an is the number of pairs (ai, aj) that satisfy i < j and ai > aj.   For a given sequence of numbers a1, a2, ..., an, if we move the first m >= 0 numbers to the end of the seqence, we w…