POJ 2182】的更多相关文章

POJ 2182 暴力 /* 题意: 一个带有权值[1,n]的序列,给出每个数的前面比该数小的数的个数,当然比一个数前面比第一个数小的个数是0,省略不写,求真正的序列.(拗口) 首先想到的是从前到后暴力枚举暴力枚举.数据量为8000,O(n^2). */ #include<cstdio> #include<iostream> #include<cstring> #include<cstdlib> #include<algorithm> #incl…
Lost Cows POJ 2182 思维 题意 是说有n头牛,它们身高不一但是排成了一队,从左到右编号为1到n,现在告诉你从第二号开始前面的那些牛中身高小于它的个数,一共有n-1个数.然后求出它们按照身高来排序的话从低到高编号会是多少. 解题思路 首先我们需要从它给的数据逆序来进行处理,为什么,比如倒数第一个数据是0的话,说明前面没有比它矮的牛,那么它的编号就是1,然后倒数第二个是2的话,就是说前面有两个比它矮,因为1号已经有了,所以他就是4号,后面以此类推. 根据这个思路我们就可以进行模拟(…
主题链接:http://poj.org/problem? id=2182 Lost Cows Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9152   Accepted: 5879 Description N (2 <= N <= 8,000) cows have unique brands in the range 1..N. In a spectacular display of poor judgment, t…
题目链接:http://poj.org/problem?id=2182 Lost Cows Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12736   Accepted: 8168 Description N (2 <= N <= 8,000) cows have unique brands in the range 1..N. In a spectacular display of poor judgment, t…
[题目链接] http://poj.org/problem?id=2182 [算法] 树状数组 + 二分 [代码] #include <algorithm> #include <bitset> #include <cctype> #include <cerrno> #include <clocale> #include <cmath> #include <complex> #include <cstdio> #…
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 their e…
Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10996   Accepted: 7059 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' a…
题意: 每头牛有编号,他们乱序排成一排,每头牛只知道前边比自己序号小的有几位. 思路: 递推,最后一只牛的编号是确定的,然后不断进行区间更新,直到找到某个空位前方恰好有n个空位. 这题跟某道排队的题思路是一样的,可以线段树,认为树状数组的解法在时间复杂度上比线段树多了一个logN 因为树状数组只能在logn的复杂度内求解出前n个数字的某些特征,所以需要进行二分不断尝试,直到找到某一个位置前方正好有多少个空位,也就是在二分的过程中使得时间复杂度比线段树要高.线段树直接进行查找就好了,复杂度是log…
#include <iostream> #define MAXN 8005 using namespace std; int _m[MAXN]; int main() { //freopen("acm.acm","r",stdin); int n; int i; int j; cin>>n; ; i < n; ++ i) { cin>>_m[i]; } _m[] = ; ; i < n; ++ i) { ; j <…
这题对于O(n^2)的算法有很多,我这随便贴一个烂的,跑了375ms. #include<iostream> #include<algorithm> using namespace std; ]; int main() { int i,j,t,n; scanf("%d",&n); mat[]=; ;i<n;i++) { scanf("%d",&t); mat[i]=t+; ;j<i;j++) if(mat[j]&g…