unique离散化用法

用法类似lower_bound,sort,不过下标从1开始的话和lower_bound减去的东西不一样

用来离散化很好用

pos就是在原数组a中的rank了,根据cnt建线段树啥的。。。

 sort(a2+1, a2+1+n);
 cnt = unique(a2+1, a2+1+n) - (a2+1);
 FOR(n) {
       int pos = lower_bound(a2+1, a2+1+cnt, a[i]) - a2;
 }


posted @ 2017-11-13 15:41  Drenight  阅读(333)  评论(0编辑  收藏  举报