poj2182 Lost Cows[BIT二分]】的更多相关文章

blog题解鸽了许久了..本来说好的切一题写一个题解的说 一个$1 \sim n$数列,已知每个数前面比他小的数个数,试确定该序列. 相当的一道水题.可以发现数列最后一个数是首先可以确定下来的.然后把这个数扔掉,看数列倒数第二个数前面有多少更小的其实就是目前剩下的数中的排名.相当于有一颗$n$个点的$1 \sim n$的平衡树,每次查一个排名,找出这个数,并删掉.但是并不想打平衡树.因为这题的操作只涉及简单的删除和查rank操作,可以考虑用BIT代替平衡树.具体是因为BIT本身就是具有树形二分结…
POJ2182 Lost Cows 题解 描述 有\(N\)(\(2 <= N <= 8,000\))头母牛,每头母牛有自己的独一无二编号(\(1..N\)). 现在\(N\)头母牛站成一列,已知每头母牛前面编号比它小的母牛数量,求每头母牛的编号. 输入格式 第1行 : 一个整数 \(N\) 第2..N行 : 从 第2头母牛到第N头母牛 的 前面编号比它小的母牛数量 样例输入 5 1 2 1 0 样例输出 2 4 5 3 1 题解 先手造一组数据 2 1 5 4 3 // 编号序列 设比第\(…
题目链接:http://poj.org/problem?id=2182 题意:给定1~n个数和n个位置,已知ai表示第i个位置前有ai个数比当前位置的数小,求这个排列. 和刚才YY的题意蛮接近的,用树状数组维护当前数组内数字分别是第几大的,倒着查询,每次查尽可能靠右的位置,可以保证取的数字是未取到并且不会冲突. #include <cstdio> #include <cstring> #include <iostream> #include <cstdlib>…
Aggressive cows Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5436   Accepted: 2720 Description Farmer John has built a new long barn, with N (2 <= N <= 100,000) stalls. The stalls are located along a straight line at positions x1,...…
疯牛 时间限制:1000 ms  |  内存限制:65535 KB 难度:4   描述 农夫 John 建造了一座很长的畜栏,它包括N (2 <= N <= 100,000)个隔间,这些小隔间依次编号为x1,...,xN (0 <= xi <= 1,000,000,000).但是,John的C (2 <= C <= N)头牛们并不喜欢这种布局,而且几头牛放在一个隔间里,他们就要发生争斗.为了不让牛互相伤害.John决定自己给牛分配隔间,使任意两头牛之间的最小距离尽可能的…
题目: Farmer John has built a new long barn, with N (2 <= N <= 100,000) stalls. The stalls are located along a straight line at positions x1,...,xN (0 <= xi <= 1,000,000,000). His C (2 <= C <= N) cows don't like this barn layout and become…
Aggressive cows 直接上中文了 Descriptions 农夫 John 建造了一座很长的畜栏,它包括N (2 <= N <= 100,000)个隔间,这些小隔间依次编号为x1,...,xN (0 <= xi <= 1,000,000,000). 但是,John的X (2 <= X <= N)头牛们并不喜欢这种布局,而且几头牛放在一个隔间里,他们就要发生争斗.为了不让牛互相伤害.John决定自己给牛分配隔间,使任意两头牛之间的最小距离尽可能的大,那么,这个…
题目传送门 POJ 2456 Description Farmer John has built a new long barn, with N (2 <= N <= 100,000) stalls. The stalls are located along a straight line at positions x1,...,xN (0 <= xi <= 1,000,000,000). His C (2 <= C <= N) cows don't like this…
Aggressive cows Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 25944   Accepted: 11982 Description Farmer John has built a new long barn, with N (2 <= N <= 100,000) stalls. The stalls are located along a straight line at positions x1,.…
线段树 Description N (2 <= N <= 8,000) cows have unique brands in the range 1..N. In a spectacular display of poor judgment, they visited the neighborhood 'watering hole' and drank a few too many beers before dinner. When it was time to line up for the…