(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)数组