码迷,mamicode.com
首页 > 其他好文 > 详细

离散化

时间:2020-01-22 21:32:21      阅读:66      评论:0      收藏:0      [点我收藏+]

标签:lower   math   int   void   n+1   unique   max   lsh   ++i   

\(code :\)

void lsh()
{   
    int s[maxn];
    for(int i=1;i<=n;++i) s[i]=a[i];
    sort(s+1,s+n+1);
    int tot=unique(s+1,s+n+1)-s-1;
    for(int i=1;i<=n;++i) a[i]=lower_bound(s+1,s+tot+1,a[i])-s;
}

借助\(s\)数组来离散化\(a\)数组

离散化

标签:lower   math   int   void   n+1   unique   max   lsh   ++i   

原文地址:https://www.cnblogs.com/lhm-/p/12229492.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!