离散化模板
2016-07-06 10:03
435 查看
离散化处理
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int maxn=100000; int a[maxn]; int b[maxn]; int n; int main() { int m=0; cin>>n;//元素个数 for(int i=1;i<=n;++i) { scanf("%d",&a[i]); b[++m]=a[i];//b[]作为离散化的数组 } sort(b+1,b+1+m);//将b数组排序,因为是从b[1]开始存储的,所以要b+1 m=unique(b+1,b+1+m)-b-1;//去重操作,返回不同元素的个数 for(int i=1;i<=n;++i) cout<<lower_bound(b+1,b+1+m,a[i])-b<<" "; // while(1); return 0; }
相关文章推荐
- 数据挖掘:基于卡方的ChiMerge方法对数值离散化(稀有数据挖掘答案代码)
- poj 2528
- Sicily 1045 Space Management
- hihocoder 1079离散化 java实现
- [离散化+树状数组]逆序对
- [离散化]图形面积
- TopCoder - SRM521 div1 500 RangeSquaredSubsets
- HDU 1542 Atlantis (线段树 +离散化+ 扫描线)
- hdu 1856 离散化+并查集
- poj 3368 离散化+线段树+二分
- hiho #1079 离散化
- lightoj 1085
- HDU3436[离散化splay]
- 【SGU 180】Inversions —— 归并排序或树形数组计算逆序对
- CodeForces 85D Sum of Medians(线段树 + 离散化)
- POJ 2546 Circular Area
- vijos 1056 图形面积
- UVAlive3532 Nuclear Plants
- POJ 2528 Mayor's posters
- codeforces 29C Mail Stamps(dfs)